mirror of
https://github.com/NohamR/OqeeRewind.git
synced 2026-07-11 22:41:14 +00:00
Times + logging changes
This commit is contained in:
4
main.py
4
main.py
@@ -26,6 +26,7 @@ from utils.times import (
|
||||
convert_sec_to_date,
|
||||
find_nearest_tick_by_hour,
|
||||
bruteforce,
|
||||
TIMESCALE,
|
||||
)
|
||||
from utils.stream import (
|
||||
save_segments,
|
||||
@@ -38,7 +39,6 @@ from utils.stream import (
|
||||
from utils.logging_config import setup_logging, logger
|
||||
|
||||
load_dotenv()
|
||||
TIMESCALE = 90000
|
||||
DURATION = 288000
|
||||
|
||||
|
||||
@@ -71,7 +71,7 @@ def parse_arguments():
|
||||
parser.add_argument(
|
||||
"--title",
|
||||
type=str,
|
||||
default="title",
|
||||
default=None,
|
||||
help="Title for the download (default: channel_id_start_date)",
|
||||
)
|
||||
parser.add_argument("--username", type=str, help="Oqee username for authentication")
|
||||
|
||||
@@ -9,6 +9,7 @@ from InquirerPy.base.control import Choice
|
||||
|
||||
from utils.stream import get_manifest, parse_mpd_manifest, organize_by_content_type
|
||||
from utils.logging_config import logger
|
||||
from utils.times import FRANCE_TZ
|
||||
|
||||
SERVICE_PLAN_API_URL = "https://api.oqee.net/api/v6/service_plan"
|
||||
EPG_API_URL = "https://api.oqee.net/api/v1/epg/all/{unix}"
|
||||
@@ -484,7 +485,7 @@ def get_epg_data_at(dt: datetime.datetime):
|
||||
else:
|
||||
dt_aligned = dt.replace(minute=0, second=0, microsecond=0)
|
||||
|
||||
unix_time = int(dt_aligned.timestamp())
|
||||
unix_time = int(dt_aligned.replace(tzinfo=FRANCE_TZ).timestamp())
|
||||
logger.info("Fetching EPG for aligned time: %s (unix=%d)", dt_aligned, unix_time)
|
||||
|
||||
try:
|
||||
@@ -533,8 +534,8 @@ def select_program_from_epg(programs, original_start_date, original_end_date):
|
||||
# Extract the live data from the program
|
||||
live_data = program.get("live", program)
|
||||
title = live_data.get("title", "Untitled")
|
||||
start_time = datetime.datetime.fromtimestamp(live_data.get("start", 0))
|
||||
end_time = datetime.datetime.fromtimestamp(live_data.get("end", 0))
|
||||
start_time = datetime.datetime.fromtimestamp(live_data.get("start", 0), tz=FRANCE_TZ).replace(tzinfo=None)
|
||||
end_time = datetime.datetime.fromtimestamp(live_data.get("end", 0), tz=FRANCE_TZ).replace(tzinfo=None)
|
||||
duration_min = (end_time - start_time).total_seconds() / 60
|
||||
|
||||
choice_name = (
|
||||
@@ -586,8 +587,8 @@ def select_program_from_epg(programs, original_start_date, original_end_date):
|
||||
|
||||
# Extract live data and convert program timestamps to datetime objects
|
||||
live_data = selected_program.get("live", selected_program)
|
||||
program_start = datetime.datetime.fromtimestamp(live_data.get("start", 0))
|
||||
program_end = datetime.datetime.fromtimestamp(live_data.get("end", 0))
|
||||
program_start = datetime.datetime.fromtimestamp(live_data.get("start", 0), tz=FRANCE_TZ).replace(tzinfo=None)
|
||||
program_end = datetime.datetime.fromtimestamp(live_data.get("end", 0), tz=FRANCE_TZ).replace(tzinfo=None)
|
||||
program_title = live_data.get("title", "Untitled")
|
||||
|
||||
logger.info("Selected program:")
|
||||
|
||||
@@ -12,6 +12,7 @@ from utils.stream import fetch_segment
|
||||
from utils.logging_config import logger
|
||||
|
||||
FRANCE_TZ = ZoneInfo("Europe/Paris")
|
||||
TIMESCALE = 90000
|
||||
|
||||
|
||||
def convert_ticks_to_sec(ticks, timescale):
|
||||
@@ -59,7 +60,7 @@ async def bruteforce(track_id, date, batch_size=20000):
|
||||
valid_ticks = []
|
||||
total_requests = 288000
|
||||
|
||||
logger.debug("Starting bruteforce for %s near %s", track_id, date)
|
||||
logger.debug("Starting bruteforce for %s near (%s) %s", track_id, date, convert_sec_to_date(convert_ticks_to_sec(date, TIMESCALE)))
|
||||
|
||||
start_time = time.time()
|
||||
|
||||
|
||||
Reference in New Issue
Block a user