minor fixes
Marco Andronaco andronacomarco@gmail.com
Wed, 23 Aug 2023 11:35:10 +0200
3 files changed,
12 insertions(+),
19 deletions(-)
M
docker-compose.yaml
→
docker-compose.yaml
@@ -3,5 +3,6 @@ app:
build: . image: birabittoh/fxyoutube:latest container_name: fxyoutube + restart: unless-stopped ports: - 127.0.0.1:1111:80
M
fxyoutube/db.py
→
fxyoutube/db.py
@@ -32,14 +32,13 @@ def get_video_from_cache(video):
result = get_video_db(video) try: temp = result[0] + timestamp = datetime.strptime(temp[8], c.TS_FORMAT) + delta = datetime.now() - timestamp + if delta > timedelta(minutes=c.YT_TTL_MINUTES): + raise IndexError except IndexError: return None - timestamp = datetime.strptime(temp[8], c.TS_FORMAT) - delta = datetime.now() - timestamp - - if delta > timedelta(minutes=c.YT_TTL_MINUTES): - raise IndexError - + return { "id": temp[0], "title": temp[1],
M
fxyoutube/yt_info.py
→
fxyoutube/yt_info.py
@@ -38,24 +38,17 @@ "title": info["title"],
"description": truncate_lines(info["description"]), "uploader": info["uploader"], "duration": info["duration"], + "height": 0, + "width": 0, + "url": None } formats = map(handle_format, info["formats"]) formats = filter(lambda x: x is not None, formats) try: max_format = max(formats, key=lambda x:x["quality"]) + yt_info.update({ k: max_format[k] for k in ["height", "width", "url"] }) except ValueError: - yt_info.update({ - "height": 0, - "width": 0, - "url": None - }) + pass + finally: return yt_info - - yt_info.update({ - "height": max_format["height"], - "width": max_format["width"], - "url": max_format["url"], - }) - - return yt_info