2023-10-21 23:38:15 +02:00
|
|
|
#!/usr/bin/python3
|
|
|
|
# -*- coding: utf-8 -*-
|
|
|
|
import requests
|
|
|
|
import time
|
|
|
|
import locale
|
|
|
|
from datetime import date
|
|
|
|
from tabulate import tabulate
|
|
|
|
import argparse
|
|
|
|
|
|
|
|
loc = locale.getlocale()
|
|
|
|
locale.setlocale(locale.LC_ALL, loc)
|
|
|
|
dt = f"{date.today():%-d.%B %Y}"
|
|
|
|
table = []
|
|
|
|
|
|
|
|
dictList = {
|
|
|
|
'ard': 71, 'zdf': 37, 'zdf neo': 659, 'zdf info': 276, 'arte': 58, 'wdr': 46, 'ndr': 47,
|
|
|
|
'mdr': 48, 'hr': 49, 'swr': 10142, 'br': 51, 'rbb': 52, '3sat': 56, 'alpha': 104,
|
|
|
|
'kika': 57, 'phoenix': 194, 'tagesschau 24': 100, 'one': 146, 'rtl': 38, 'sat 1': 39,
|
|
|
|
'pro 7': 40, 'rtl plus': 12033, 'kabel 1': 44, 'rtl 2': 41, 'vox': 42, 'rtl nitro': 763,
|
|
|
|
'n24 doku': 12045, 'kabel 1 doku': 12043, 'sport 1': 64, 'super rtl': 43,
|
|
|
|
'sat 1 gold': 774, 'vox up': 12125, 'sixx': 694, 'servus tv': 660,
|
|
|
|
'welt': 175, 'orf 1': 54, 'orf 2': 55, 'orf 3': 56, 'tele 5': 277, '7maxx': 783,
|
|
|
|
'dmaxx': 507, 'dw': 300, 'fox': 565, 'srf 1': 59, 'srf 2': 60
|
|
|
|
}
|
|
|
|
|
|
|
|
myday = f"{date.today():%d}"
|
|
|
|
print("Day:", myday)
|
|
|
|
|
|
|
|
# Define the time range (modify as needed)
|
2023-10-22 18:23:03 +02:00
|
|
|
default_start_time = "20:15" # 8:15 PM
|
|
|
|
default_end_time = "20:30" # 8:30 PM
|
2023-10-21 23:38:15 +02:00
|
|
|
|
|
|
|
# Create an argument parser
|
|
|
|
parser = argparse.ArgumentParser(description="TV Program Viewer")
|
|
|
|
parser.add_argument(
|
|
|
|
"--start-time",
|
2023-10-22 18:23:03 +02:00
|
|
|
type=str,
|
2023-10-21 23:38:15 +02:00
|
|
|
default=default_start_time,
|
2023-10-22 18:23:03 +02:00
|
|
|
help="Start time in HH:MM format (e.g., 05:30 for 5:30 AM)",
|
2023-10-21 23:38:15 +02:00
|
|
|
)
|
|
|
|
parser.add_argument(
|
|
|
|
"--end-time",
|
2023-10-22 18:23:03 +02:00
|
|
|
type=str,
|
2023-10-21 23:38:15 +02:00
|
|
|
default=default_end_time,
|
2023-10-22 18:23:03 +02:00
|
|
|
help="End time in HH:MM format (e.g., 20:30 for 8:30 PM)",
|
2023-10-21 23:38:15 +02:00
|
|
|
)
|
|
|
|
args = parser.parse_args()
|
|
|
|
|
|
|
|
response = requests.get('http://mobile.hoerzu.de/programbystation')
|
|
|
|
response_json = response.json()
|
|
|
|
|
|
|
|
def getValues(id, start_time, end_time):
|
|
|
|
for i in response_json:
|
|
|
|
if i['id'] == id:
|
|
|
|
pr = i['broadcasts']
|
|
|
|
data = []
|
|
|
|
for a in pr:
|
|
|
|
title = a.get('title')
|
|
|
|
st = a.get('startTime')
|
|
|
|
d = a.get('duration')
|
2023-10-22 18:27:06 +02:00
|
|
|
start = time.strftime("%H:%M", time.localtime(st))
|
2023-10-22 18:23:03 +02:00
|
|
|
# Split the start time into hours and minutes
|
|
|
|
start_hours, start_minutes = map(int, start.split(":"))
|
2023-10-21 23:38:15 +02:00
|
|
|
day = time.strftime("%d", time.localtime(int(st)))
|
2023-10-22 18:23:03 +02:00
|
|
|
if day == myday and start_time <= f"{start_hours:02}:{start_minutes:02}" <= end_time:
|
2023-10-21 23:38:15 +02:00
|
|
|
data.append([start, title])
|
|
|
|
return data
|
|
|
|
|
|
|
|
def makeList(start_time, end_time):
|
2023-10-22 18:23:03 +02:00
|
|
|
print("Channels:", len(dictList))
|
|
|
|
table.append(["Channel", f"TV Shows from {start_time} to {end_time}"])
|
2023-10-21 23:38:15 +02:00
|
|
|
for ch in dictList:
|
|
|
|
data = [ch.upper()]
|
|
|
|
channel_data = getValues(dictList.get(ch), start_time, end_time)
|
|
|
|
if channel_data:
|
|
|
|
for item in channel_data:
|
|
|
|
data.extend(item)
|
|
|
|
table.append(data)
|
|
|
|
|
|
|
|
print(tabulate(table, headers="firstrow", tablefmt="pretty"))
|
|
|
|
|
|
|
|
makeList(args.start_time, args.end_time)
|