From ce4288ff66cd40dc185289f255e9c4f810ddb726 Mon Sep 17 00:00:00 2001 From: simon Date: Mon, 2 Jan 2023 21:36:08 +0700 Subject: [PATCH] add is_short standalone helper function --- tubearchivist/home/src/ta/helper.py | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/tubearchivist/home/src/ta/helper.py b/tubearchivist/home/src/ta/helper.py index af17fc06..45e4190f 100644 --- a/tubearchivist/home/src/ta/helper.py +++ b/tubearchivist/home/src/ta/helper.py @@ -13,6 +13,7 @@ import unicodedata from datetime import datetime from urllib.parse import parse_qs, urlparse +import requests from home.src.download.yt_dlp_base import YtWrap @@ -136,6 +137,16 @@ def get_mapping(): return index_config +def is_short(youtube_id): + """check if youtube_id is a shorts video, bot not it it's not a shorts""" + shorts_url = f"https://www.youtube.com/shorts/{youtube_id}" + response = requests.head( + shorts_url, headers=requests_headers(), timeout=10 + ) + + return response.status_code == 200 + + class UrlListParser: """take a multi line string and detect valid youtube ids"""