add is_short standalone helper function

This commit is contained in:
simon 2023-01-02 21:36:08 +07:00
parent 14d5a7ee1a
commit ce4288ff66
No known key found for this signature in database
GPG Key ID: 2C15AA5E89985DD4

View File

@ -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"""