fixyoutube/constants.py (view raw)
1from dotenv import load_dotenv
2from os import getenv
3from requests import get
4load_dotenv()
5
6MAX_SIZE_MB = getenv("MAX_SIZE_MB", "50")
7YT_TTL_MINUTES = int(getenv("YT_TTL_MINUTES", 60 * 6))
8DB_URL = getenv("DB_URL", "cache.db")
9INVIDIOUS_INSTANCE = getenv("INVIDIOUS_INSTANCE", None)
10REPO_URL = getenv("REPO_URL", "https://github.com/BiRabittoh/FixYouTube")
11
12if INVIDIOUS_INSTANCE is None:
13 instances = get("https://api.invidious.io/instances.json?pretty=1&sort_by=api,type").json()
14 INVIDIOUS_INSTANCE = instances[0][0]
15
16UA_REGEX = r"bot|facebook|embed|got|firefox\/92|firefox\/38|curl|wget|go-http|yahoo|generator|whatsapp|preview|link|proxy|vkshare|images|analyzer|index|crawl|spider|python|cfnetwork|node"
17BASE_URL = "https://www.youtube.com/watch?v="
18PROXY_HEADERS_REQUEST = { "Range": f"bytes=0-{MAX_SIZE_MB}000000" }
19PROXY_HEADERS_RESPONSE = { "Content-Type": "video/mp4" }
20INVIDIOUS_ENDPOINT = "https://" + INVIDIOUS_INSTANCE + "/api/v1/videos/{}?fields=videoId,title,description,author,lengthSeconds,size,formatStreams"
21
22# test stuff
23TELEGRAM_USER_AGENT = "TelegramBot (like TwitterBot)"
24GOOD_VIDEO_ID = "crF2AIDlo54"
25BAD_VIDEO_ID = GOOD_VIDEO_ID[:-1]