diff --git a/src/music_kraken/__main__.py b/src/music_kraken/__main__.py index 4aa30ef..776622b 100644 --- a/src/music_kraken/__main__.py +++ b/src/music_kraken/__main__.py @@ -67,9 +67,9 @@ if __name__ == "__main__": ) parser.add_argument( - "--invidious", - "-i", - help="Set a good and fast invidious instance from your homecountry, to reduce the latency.", + "--frontend", + "-f", + help="Set a good and fast invidious/piped instance from your homecountry, to reduce the latency.", action="store_true" ) @@ -102,9 +102,9 @@ if __name__ == "__main__": os.remove(music_kraken.shared.CONFIG_FILE) music_kraken.read() - if arguments.invidious: - from .cli.options import invidious - invidious() + if arguments.frontend: + from .cli.options.frontend import set_frontend + set_frontend() exit() # getting the genre diff --git a/src/music_kraken/cli/__init__.py b/src/music_kraken/cli/__init__.py index b4e57ef..c21af81 100644 --- a/src/music_kraken/cli/__init__.py +++ b/src/music_kraken/cli/__init__.py @@ -1,2 +1 @@ -from .download.shell import Shell -from .options import invidious \ No newline at end of file +from .download.shell import Shell \ No newline at end of file diff --git a/src/music_kraken/cli/options/__init__.py b/src/music_kraken/cli/options/__init__.py index 0ab4d7f..e69de29 100644 --- a/src/music_kraken/cli/options/__init__.py +++ b/src/music_kraken/cli/options/__init__.py @@ -1,4 +0,0 @@ -from .invidious.shell import InvidiousShell - -def invidious(): - shell = InvidiousShell() \ No newline at end of file diff --git a/src/music_kraken/cli/options/frontend.py b/src/music_kraken/cli/options/frontend.py new file mode 100644 index 0000000..34395f4 --- /dev/null +++ b/src/music_kraken/cli/options/frontend.py @@ -0,0 +1,181 @@ +from typing import Dict, List +import requests +from dataclasses import dataclass +from collections import defaultdict + +from ...objects import Country +from ...utils import config, write +from ...connection import Connection + + +@dataclass +class Instance: + """ + Attributes which influence the quality of an instance: + + - users + """ + name: str + uri: str + regions: List[Country] + users: int = 0 + + def __str__(self) -> str: + return f"{self.name} with {self.users} users." + + +class FrontendInstance: + SETTING_NAME = "placeholder" + + def __init__(self) -> None: + self.region_instances: Dict[Country, List[Instance]] = defaultdict(list) + self.all_instances: List[Instance] = [] + + def add_instance(self, instance: Instance): + self.all_instances.append(instance) + + for region in instance.regions: + self.region_instances[region].append(instance) + + def fetch(self, silent: bool = False): + if not silent: + print(f"Downloading {type(self).__name__} instances...") + + def set_instance(self, instance: Instance): + config.set_name_to_value(self.SETTING_NAME, instance.uri) + write() + + def _choose_country(self) -> List[Instance]: + print("Input the country code, an example would be \"US\"") + print('\n'.join(f'{region.name} ({region.alpha_2})' for region in self.region_instances)) + print() + + + available_instances = set(i.alpha_2 for i in self.region_instances) + + chosen_region = "" + + while chosen_region not in available_instances: + chosen_region = input("nearest country: ").strip().upper() + + return self.region_instances[Country.by_alpha_2(chosen_region)] + + def choose(self, silent: bool = False): + instances = self.all_instances if silent else self._choose_country() + instances.sort(key=lambda x: x.users, reverse=True) + + if silent: + self.set_instance(instances[0]) + return + + # output the options + print("Choose your instance (input needs to be a digit):") + for i, instance in enumerate(instances): + print(f"{i}) {instance}") + + print() + + # ask for index + index = "" + while not index.isdigit() or int(index) >= len(instances): + index = input("> ").strip() + + instance = instances[int(index)] + print() + print(f"Setting the instance to {instance}") + + self.set_instance(instance) + + +class Invidious(FrontendInstance): + SETTING_NAME = "invidious_instance" + + def __init__(self) -> None: + self.connection = Connection(host="https://api.invidious.io/") + self.endpoint = "https://api.invidious.io/instances.json" + + super().__init__() + + + def _process_instance(self, all_instance_data: dict): + instance_data = all_instance_data[1] + stats = instance_data["stats"] + + if not instance_data["api"]: + return + if instance_data["type"] != "https": + return + + region = instance_data["region"] + + instance = Instance( + name=all_instance_data[0], + uri=instance_data["uri"], + regions=[Country.by_alpha_2(region)], + users=stats["usage"]["users"]["total"] + ) + + self.add_instance(instance) + + def fetch(self, silent: bool): + print("jhdflashfรถ") + r = self.connection.get(self.endpoint) + if r is None: + return + + for instance in r.json(): + self._process_instance(all_instance_data=instance) + + +class Piped(FrontendInstance): + SETTING_NAME = "piped_instance" + + def __init__(self) -> None: + self.connection = Connection(host="https://raw.githubusercontent.com") + + super().__init__() + + def process_instance(self, instance_data: str): + cells = instance_data.split(" | ") + + instance = Instance( + name=cells[0].strip(), + uri=cells[1].strip(), + regions=[Country.by_emoji(flag) for flag in cells[2].split(", ")] + ) + + self.add_instance(instance) + + def fetch(self, silent: bool = False): + r = self.connection.get("https://raw.githubusercontent.com/wiki/TeamPiped/Piped-Frontend/Instances.md") + if r is None: + return + + process = False + + for line in r.content.decode("utf-8").split("\n"): + line = line.strip() + + if line != "" and process: + self.process_instance(line) + + if line.startswith("---"): + process = True + + +class FrontendSelection: + def __init__(self): + self.invidious = Invidious() + self.piped = Piped() + + def choose(self, silent: bool = False): + self.invidious.fetch(silent) + self.invidious.choose(silent) + + self.piped.fetch(silent) + self.piped.choose(silent) + + +def set_frontend(silent: bool = False): + shell = FrontendSelection() + shell.choose(silent=silent) diff --git a/src/music_kraken/cli/options/invidious/shell.py b/src/music_kraken/cli/options/invidious/shell.py deleted file mode 100644 index 131a9d8..0000000 --- a/src/music_kraken/cli/options/invidious/shell.py +++ /dev/null @@ -1,101 +0,0 @@ -from typing import Dict, List -import requests -from dataclasses import dataclass -from collections import defaultdict - -from ....utils import config, write - - -INSTANCES_ENDPOINT = "https://api.invidious.io/instances.json" - -@dataclass -class Instance: - """ - Attributes which influence the quality of an instance: - - - users - """ - name: str - uri: str - region: str - users: int - - def __str__(self) -> str: - return f"{self.name} with {self.users} users." - - -class InvidiousShell: - def __init__(self): - self.region_flags = dict() - self.region_instances: Dict[str, List[Instance]] = defaultdict(list) - - self.download_instances() - self.region = self.get_country() - print() - self.choose_instance() - - - def process_instance(self, all_instance_data: dict): - instance_data = all_instance_data[1] - stats = instance_data["stats"] - - if not instance_data["api"]: - return - if instance_data["type"] != "https": - return - - region = instance_data["region"] - flag = instance_data["flag"] - - self.region_flags[region] = flag - - instance = Instance( - name=all_instance_data[0], - uri=instance_data["uri"], - region=region, - users=stats["usage"]["users"]["total"] - ) - - self.region_instances[region].append(instance) - - def download_instances(self): - print("Download idonvidious instances...") - r = requests.get(INSTANCES_ENDPOINT) - - for instance in r.json(): - self.process_instance(all_instance_data=instance) - - def get_country(self): - print("Input the country code, an example would be \"US\"") - print(f"({' | '.join(f'{region}-{flag}' for region, flag in self.region_flags.items())})") - - chosen_region = "" - - while chosen_region.upper() not in self.region_instances: - chosen_region = input("nearest country: ").strip().upper() - - return chosen_region - - def choose_instance(self): - instance_list = self.region_instances[self.region] - instance_list.sort(key=lambda x: x.users, reverse=True) - - # output the options - print("Choose your instance (input needs to be a digit):") - for i, instance in enumerate(instance_list): - print(f"{i}) {instance}") - - print() - - # ask for index - index = "" - while not index.isdigit() or int(index) >= len(instance_list): - index = input("> ").strip() - - instance = instance_list[int(index)] - print() - print(f"Setting the instance to {instance}") - - config.set_name_to_value("invidious_instance", instance.uri) - write() - \ No newline at end of file diff --git a/src/music_kraken/objects/__init__.py b/src/music_kraken/objects/__init__.py index f458303..4a17b9b 100644 --- a/src/music_kraken/objects/__init__.py +++ b/src/music_kraken/objects/__init__.py @@ -16,3 +16,5 @@ from .song import ( from .formatted_text import FormattedText from .collection import Collection + +from .country import Country diff --git a/src/music_kraken/objects/country.py b/src/music_kraken/objects/country.py new file mode 100644 index 0000000..aed4842 --- /dev/null +++ b/src/music_kraken/objects/country.py @@ -0,0 +1,66 @@ +from dataclasses import dataclass + +import pycountry + + +CountryTyping = type(list(pycountry.countries)[0]) + + +emoji_map = {'AD': '๐Ÿ‡ฆ๐Ÿ‡ฉ', 'AE': '๐Ÿ‡ฆ๐Ÿ‡ช', 'AF': '๐Ÿ‡ฆ๐Ÿ‡ซ', 'AG': '๐Ÿ‡ฆ๐Ÿ‡ฌ', 'AI': '๐Ÿ‡ฆ๐Ÿ‡ฎ', 'AL': '๐Ÿ‡ฆ๐Ÿ‡ฑ', 'AM': '๐Ÿ‡ฆ๐Ÿ‡ฒ', 'AO': '๐Ÿ‡ฆ๐Ÿ‡ด', 'AQ': '๐Ÿ‡ฆ๐Ÿ‡ถ', 'AR': '๐Ÿ‡ฆ๐Ÿ‡ท', 'AS': '๐Ÿ‡ฆ๐Ÿ‡ธ', 'AT': '๐Ÿ‡ฆ๐Ÿ‡น', 'AU': '๐Ÿ‡ฆ๐Ÿ‡บ', 'AW': '๐Ÿ‡ฆ๐Ÿ‡ผ', 'AX': '๐Ÿ‡ฆ๐Ÿ‡ฝ', 'AZ': '๐Ÿ‡ฆ๐Ÿ‡ฟ', 'BA': '๐Ÿ‡ง๐Ÿ‡ฆ', 'BB': '๐Ÿ‡ง๐Ÿ‡ง', 'BD': '๐Ÿ‡ง๐Ÿ‡ฉ', 'BE': '๐Ÿ‡ง๐Ÿ‡ช', 'BF': '๐Ÿ‡ง๐Ÿ‡ซ', 'BG': '๐Ÿ‡ง๐Ÿ‡ฌ', 'BH': '๐Ÿ‡ง๐Ÿ‡ญ', 'BI': '๐Ÿ‡ง๐Ÿ‡ฎ', 'BJ': '๐Ÿ‡ง๐Ÿ‡ฏ', 'BL': '๐Ÿ‡ง๐Ÿ‡ฑ', 'BM': '๐Ÿ‡ง๐Ÿ‡ฒ', 'BN': '๐Ÿ‡ง๐Ÿ‡ณ', 'BO': '๐Ÿ‡ง๐Ÿ‡ด', 'BQ': '๐Ÿ‡ง๐Ÿ‡ถ', 'BR': '๐Ÿ‡ง๐Ÿ‡ท', 'BS': '๐Ÿ‡ง๐Ÿ‡ธ', 'BT': '๐Ÿ‡ง๐Ÿ‡น', 'BV': '๐Ÿ‡ง๐Ÿ‡ป', 'BW': '๐Ÿ‡ง๐Ÿ‡ผ', 'BY': '๐Ÿ‡ง๐Ÿ‡พ', 'BZ': '๐Ÿ‡ง๐Ÿ‡ฟ', 'CA': '๐Ÿ‡จ๐Ÿ‡ฆ', 'CC': '๐Ÿ‡จ๐Ÿ‡จ', 'CD': '๐Ÿ‡จ๐Ÿ‡ฉ', 'CF': '๐Ÿ‡จ๐Ÿ‡ซ', 'CG': '๐Ÿ‡จ๐Ÿ‡ฌ', 'CH': '๐Ÿ‡จ๐Ÿ‡ญ', 'CI': '๐Ÿ‡จ๐Ÿ‡ฎ', 'CK': '๐Ÿ‡จ๐Ÿ‡ฐ', 'CL': '๐Ÿ‡จ๐Ÿ‡ฑ', 'CM': '๐Ÿ‡จ๐Ÿ‡ฒ', 'CN': '๐Ÿ‡จ๐Ÿ‡ณ', 'CO': '๐Ÿ‡จ๐Ÿ‡ด', 'CR': '๐Ÿ‡จ๐Ÿ‡ท', 'CU': '๐Ÿ‡จ๐Ÿ‡บ', 'CV': '๐Ÿ‡จ๐Ÿ‡ป', 'CW': '๐Ÿ‡จ๐Ÿ‡ผ', 'CX': '๐Ÿ‡จ๐Ÿ‡ฝ', 'CY': '๐Ÿ‡จ๐Ÿ‡พ', 'CZ': '๐Ÿ‡จ๐Ÿ‡ฟ', 'DE': '๐Ÿ‡ฉ๐Ÿ‡ช', 'DJ': '๐Ÿ‡ฉ๐Ÿ‡ฏ', 'DK': '๐Ÿ‡ฉ๐Ÿ‡ฐ', 'DM': '๐Ÿ‡ฉ๐Ÿ‡ฒ', 'DO': '๐Ÿ‡ฉ๐Ÿ‡ด', 'DZ': '๐Ÿ‡ฉ๐Ÿ‡ฟ', 'EC': '๐Ÿ‡ช๐Ÿ‡จ', 'EE': '๐Ÿ‡ช๐Ÿ‡ช', 'EG': '๐Ÿ‡ช๐Ÿ‡ฌ', 'EH': '๐Ÿ‡ช๐Ÿ‡ญ', 'ER': '๐Ÿ‡ช๐Ÿ‡ท', 'ES': '๐Ÿ‡ช๐Ÿ‡ธ', 'ET': '๐Ÿ‡ช๐Ÿ‡น', 'FI': '๐Ÿ‡ซ๐Ÿ‡ฎ', 'FJ': '๐Ÿ‡ซ๐Ÿ‡ฏ', 'FK': '๐Ÿ‡ซ๐Ÿ‡ฐ', 'FM': '๐Ÿ‡ซ๐Ÿ‡ฒ', 'FO': '๐Ÿ‡ซ๐Ÿ‡ด', 'FR': '๐Ÿ‡ซ๐Ÿ‡ท', 'GA': '๐Ÿ‡ฌ๐Ÿ‡ฆ', 'GB': '๐Ÿ‡ฌ๐Ÿ‡ง', 'GD': '๐Ÿ‡ฌ๐Ÿ‡ฉ', 'GE': '๐Ÿ‡ฌ๐Ÿ‡ช', 'GF': '๐Ÿ‡ฌ๐Ÿ‡ซ', 'GG': '๐Ÿ‡ฌ๐Ÿ‡ฌ', 'GH': '๐Ÿ‡ฌ๐Ÿ‡ญ', 'GI': '๐Ÿ‡ฌ๐Ÿ‡ฎ', 'GL': '๐Ÿ‡ฌ๐Ÿ‡ฑ', 'GM': '๐Ÿ‡ฌ๐Ÿ‡ฒ', 'GN': '๐Ÿ‡ฌ๐Ÿ‡ณ', 'GP': '๐Ÿ‡ฌ๐Ÿ‡ต', 'GQ': '๐Ÿ‡ฌ๐Ÿ‡ถ', 'GR': '๐Ÿ‡ฌ๐Ÿ‡ท', 'GS': '๐Ÿ‡ฌ๐Ÿ‡ธ', 'GT': '๐Ÿ‡ฌ๐Ÿ‡น', 'GU': '๐Ÿ‡ฌ๐Ÿ‡บ', 'GW': '๐Ÿ‡ฌ๐Ÿ‡ผ', 'GY': '๐Ÿ‡ฌ๐Ÿ‡พ', 'HK': '๐Ÿ‡ญ๐Ÿ‡ฐ', 'HM': '๐Ÿ‡ญ๐Ÿ‡ฒ', 'HN': '๐Ÿ‡ญ๐Ÿ‡ณ', 'HR': '๐Ÿ‡ญ๐Ÿ‡ท', 'HT': '๐Ÿ‡ญ๐Ÿ‡น', 'HU': '๐Ÿ‡ญ๐Ÿ‡บ', 'ID': '๐Ÿ‡ฎ๐Ÿ‡ฉ', 'IE': '๐Ÿ‡ฎ๐Ÿ‡ช', 'IL': '๐Ÿ‡ฎ๐Ÿ‡ฑ', 'IM': '๐Ÿ‡ฎ๐Ÿ‡ฒ', 'IN': '๐Ÿ‡ฎ๐Ÿ‡ณ', 'IO': '๐Ÿ‡ฎ๐Ÿ‡ด', 'IQ': '๐Ÿ‡ฎ๐Ÿ‡ถ', 'IR': '๐Ÿ‡ฎ๐Ÿ‡ท', 'IS': '๐Ÿ‡ฎ๐Ÿ‡ธ', 'IT': '๐Ÿ‡ฎ๐Ÿ‡น', 'JE': '๐Ÿ‡ฏ๐Ÿ‡ช', 'JM': '๐Ÿ‡ฏ๐Ÿ‡ฒ', 'JO': '๐Ÿ‡ฏ๐Ÿ‡ด', 'JP': '๐Ÿ‡ฏ๐Ÿ‡ต', 'KE': '๐Ÿ‡ฐ๐Ÿ‡ช', 'KG': '๐Ÿ‡ฐ๐Ÿ‡ฌ', 'KH': '๐Ÿ‡ฐ๐Ÿ‡ญ', 'KI': '๐Ÿ‡ฐ๐Ÿ‡ฎ', 'KM': '๐Ÿ‡ฐ๐Ÿ‡ฒ', 'KN': '๐Ÿ‡ฐ๐Ÿ‡ณ', 'KP': '๐Ÿ‡ฐ๐Ÿ‡ต', 'KR': '๐Ÿ‡ฐ๐Ÿ‡ท', 'KW': '๐Ÿ‡ฐ๐Ÿ‡ผ', 'KY': '๐Ÿ‡ฐ๐Ÿ‡พ', 'KZ': '๐Ÿ‡ฐ๐Ÿ‡ฟ', 'LA': '๐Ÿ‡ฑ๐Ÿ‡ฆ', 'LB': '๐Ÿ‡ฑ๐Ÿ‡ง', 'LC': '๐Ÿ‡ฑ๐Ÿ‡จ', 'LI': '๐Ÿ‡ฑ๐Ÿ‡ฎ', 'LK': '๐Ÿ‡ฑ๐Ÿ‡ฐ', 'LR': '๐Ÿ‡ฑ๐Ÿ‡ท', 'LS': '๐Ÿ‡ฑ๐Ÿ‡ธ', 'LT': '๐Ÿ‡ฑ๐Ÿ‡น', 'LU': '๐Ÿ‡ฑ๐Ÿ‡บ', 'LV': '๐Ÿ‡ฑ๐Ÿ‡ป', 'LY': '๐Ÿ‡ฑ๐Ÿ‡พ', 'MA': '๐Ÿ‡ฒ๐Ÿ‡ฆ', 'MC': '๐Ÿ‡ฒ๐Ÿ‡จ', 'MD': '๐Ÿ‡ฒ๐Ÿ‡ฉ', 'ME': '๐Ÿ‡ฒ๐Ÿ‡ช', 'MF': '๐Ÿ‡ฒ๐Ÿ‡ซ', 'MG': '๐Ÿ‡ฒ๐Ÿ‡ฌ', 'MH': '๐Ÿ‡ฒ๐Ÿ‡ญ', 'MK': '๐Ÿ‡ฒ๐Ÿ‡ฐ', 'ML': '๐Ÿ‡ฒ๐Ÿ‡ฑ', 'MM': '๐Ÿ‡ฒ๐Ÿ‡ฒ', 'MN': '๐Ÿ‡ฒ๐Ÿ‡ณ', 'MO': '๐Ÿ‡ฒ๐Ÿ‡ด', 'MP': '๐Ÿ‡ฒ๐Ÿ‡ต', 'MQ': '๐Ÿ‡ฒ๐Ÿ‡ถ', 'MR': '๐Ÿ‡ฒ๐Ÿ‡ท', 'MS': '๐Ÿ‡ฒ๐Ÿ‡ธ', 'MT': '๐Ÿ‡ฒ๐Ÿ‡น', 'MU': '๐Ÿ‡ฒ๐Ÿ‡บ', 'MV': '๐Ÿ‡ฒ๐Ÿ‡ป', 'MW': '๐Ÿ‡ฒ๐Ÿ‡ผ', 'MX': '๐Ÿ‡ฒ๐Ÿ‡ฝ', 'MY': '๐Ÿ‡ฒ๐Ÿ‡พ', 'MZ': '๐Ÿ‡ฒ๐Ÿ‡ฟ', 'NA': '๐Ÿ‡ณ๐Ÿ‡ฆ', 'NC': '๐Ÿ‡ณ๐Ÿ‡จ', 'NE': '๐Ÿ‡ณ๐Ÿ‡ช', 'NF': '๐Ÿ‡ณ๐Ÿ‡ซ', 'NG': '๐Ÿ‡ณ๐Ÿ‡ฌ', 'NI': '๐Ÿ‡ณ๐Ÿ‡ฎ', 'NL': '๐Ÿ‡ณ๐Ÿ‡ฑ', 'NO': '๐Ÿ‡ณ๐Ÿ‡ด', 'NP': '๐Ÿ‡ณ๐Ÿ‡ต', 'NR': '๐Ÿ‡ณ๐Ÿ‡ท', 'NU': '๐Ÿ‡ณ๐Ÿ‡บ', 'NZ': '๐Ÿ‡ณ๐Ÿ‡ฟ', 'OM': '๐Ÿ‡ด๐Ÿ‡ฒ', 'PA': '๐Ÿ‡ต๐Ÿ‡ฆ', 'PE': '๐Ÿ‡ต๐Ÿ‡ช', 'PF': '๐Ÿ‡ต๐Ÿ‡ซ', 'PG': '๐Ÿ‡ต๐Ÿ‡ฌ', 'PH': '๐Ÿ‡ต๐Ÿ‡ญ', 'PK': '๐Ÿ‡ต๐Ÿ‡ฐ', 'PL': '๐Ÿ‡ต๐Ÿ‡ฑ', 'PM': '๐Ÿ‡ต๐Ÿ‡ฒ', 'PN': '๐Ÿ‡ต๐Ÿ‡ณ', 'PR': '๐Ÿ‡ต๐Ÿ‡ท', 'PS': '๐Ÿ‡ต๐Ÿ‡ธ', 'PT': '๐Ÿ‡ต๐Ÿ‡น', 'PW': '๐Ÿ‡ต๐Ÿ‡ผ', 'PY': '๐Ÿ‡ต๐Ÿ‡พ', 'QA': '๐Ÿ‡ถ๐Ÿ‡ฆ', 'RE': '๐Ÿ‡ท๐Ÿ‡ช', 'RO': '๐Ÿ‡ท๐Ÿ‡ด', 'RS': '๐Ÿ‡ท๐Ÿ‡ธ', 'RU': '๐Ÿ‡ท๐Ÿ‡บ', 'RW': '๐Ÿ‡ท๐Ÿ‡ผ', 'SA': '๐Ÿ‡ธ๐Ÿ‡ฆ', 'SB': '๐Ÿ‡ธ๐Ÿ‡ง', 'SC': '๐Ÿ‡ธ๐Ÿ‡จ', 'SD': '๐Ÿ‡ธ๐Ÿ‡ฉ', 'SE': '๐Ÿ‡ธ๐Ÿ‡ช', 'SG': '๐Ÿ‡ธ๐Ÿ‡ฌ', 'SH': '๐Ÿ‡ธ๐Ÿ‡ญ', 'SI': '๐Ÿ‡ธ๐Ÿ‡ฎ', 'SJ': '๐Ÿ‡ธ๐Ÿ‡ฏ', 'SK': '๐Ÿ‡ธ๐Ÿ‡ฐ', 'SL': '๐Ÿ‡ธ๐Ÿ‡ฑ', 'SM': '๐Ÿ‡ธ๐Ÿ‡ฒ', 'SN': '๐Ÿ‡ธ๐Ÿ‡ณ', 'SO': '๐Ÿ‡ธ๐Ÿ‡ด', 'SR': '๐Ÿ‡ธ๐Ÿ‡ท', 'SS': '๐Ÿ‡ธ๐Ÿ‡ธ', 'ST': '๐Ÿ‡ธ๐Ÿ‡น', 'SV': '๐Ÿ‡ธ๐Ÿ‡ป', 'SX': '๐Ÿ‡ธ๐Ÿ‡ฝ', 'SY': '๐Ÿ‡ธ๐Ÿ‡พ', 'SZ': '๐Ÿ‡ธ๐Ÿ‡ฟ', 'TC': '๐Ÿ‡น๐Ÿ‡จ', 'TD': '๐Ÿ‡น๐Ÿ‡ฉ', 'TF': '๐Ÿ‡น๐Ÿ‡ซ', 'TG': '๐Ÿ‡น๐Ÿ‡ฌ', 'TH': '๐Ÿ‡น๐Ÿ‡ญ', 'TJ': '๐Ÿ‡น๐Ÿ‡ฏ', 'TK': '๐Ÿ‡น๐Ÿ‡ฐ', 'TL': '๐Ÿ‡น๐Ÿ‡ฑ', 'TM': '๐Ÿ‡น๐Ÿ‡ฒ', 'TN': '๐Ÿ‡น๐Ÿ‡ณ', 'TO': '๐Ÿ‡น๐Ÿ‡ด', 'TR': '๐Ÿ‡น๐Ÿ‡ท', 'TT': '๐Ÿ‡น๐Ÿ‡น', 'TV': '๐Ÿ‡น๐Ÿ‡ป', 'TW': '๐Ÿ‡น๐Ÿ‡ผ', 'TZ': '๐Ÿ‡น๐Ÿ‡ฟ', 'UA': '๐Ÿ‡บ๐Ÿ‡ฆ', 'UG': '๐Ÿ‡บ๐Ÿ‡ฌ', 'UM': '๐Ÿ‡บ๐Ÿ‡ฒ', 'US': '๐Ÿ‡บ๐Ÿ‡ธ', 'UY': '๐Ÿ‡บ๐Ÿ‡พ', 'UZ': '๐Ÿ‡บ๐Ÿ‡ฟ', 'VA': '๐Ÿ‡ป๐Ÿ‡ฆ', 'VC': '๐Ÿ‡ป๐Ÿ‡จ', 'VE': '๐Ÿ‡ป๐Ÿ‡ช', 'VG': '๐Ÿ‡ป๐Ÿ‡ฌ', 'VI': '๐Ÿ‡ป๐Ÿ‡ฎ', 'VN': '๐Ÿ‡ป๐Ÿ‡ณ', 'VU': '๐Ÿ‡ป๐Ÿ‡บ', 'WF': '๐Ÿ‡ผ๐Ÿ‡ซ', 'WS': '๐Ÿ‡ผ๐Ÿ‡ธ', 'YE': '๐Ÿ‡พ๐Ÿ‡ช', 'YT': '๐Ÿ‡พ๐Ÿ‡น', 'ZA': '๐Ÿ‡ฟ๐Ÿ‡ฆ', 'ZM': '๐Ÿ‡ฟ๐Ÿ‡ฒ', 'ZW': '๐Ÿ‡ฟ๐Ÿ‡ผ', '๐Ÿ‡ฆ๐Ÿ‡ฉ': 'AD', '๐Ÿ‡ฆ๐Ÿ‡ช': 'AE', '๐Ÿ‡ฆ๐Ÿ‡ซ': 'AF', '๐Ÿ‡ฆ๐Ÿ‡ฌ': 'AG', '๐Ÿ‡ฆ๐Ÿ‡ฎ': 'AI', '๐Ÿ‡ฆ๐Ÿ‡ฑ': 'AL', '๐Ÿ‡ฆ๐Ÿ‡ฒ': 'AM', '๐Ÿ‡ฆ๐Ÿ‡ด': 'AO', '๐Ÿ‡ฆ๐Ÿ‡ถ': 'AQ', '๐Ÿ‡ฆ๐Ÿ‡ท': 'AR', '๐Ÿ‡ฆ๐Ÿ‡ธ': 'AS', '๐Ÿ‡ฆ๐Ÿ‡น': 'AT', '๐Ÿ‡ฆ๐Ÿ‡บ': 'AU', '๐Ÿ‡ฆ๐Ÿ‡ผ': 'AW', '๐Ÿ‡ฆ๐Ÿ‡ฝ': 'AX', '๐Ÿ‡ฆ๐Ÿ‡ฟ': 'AZ', '๐Ÿ‡ง๐Ÿ‡ฆ': 'BA', '๐Ÿ‡ง๐Ÿ‡ง': 'BB', '๐Ÿ‡ง๐Ÿ‡ฉ': 'BD', '๐Ÿ‡ง๐Ÿ‡ช': 'BE', '๐Ÿ‡ง๐Ÿ‡ซ': 'BF', '๐Ÿ‡ง๐Ÿ‡ฌ': 'BG', '๐Ÿ‡ง๐Ÿ‡ญ': 'BH', '๐Ÿ‡ง๐Ÿ‡ฎ': 'BI', '๐Ÿ‡ง๐Ÿ‡ฏ': 'BJ', '๐Ÿ‡ง๐Ÿ‡ฑ': 'BL', '๐Ÿ‡ง๐Ÿ‡ฒ': 'BM', '๐Ÿ‡ง๐Ÿ‡ณ': 'BN', '๐Ÿ‡ง๐Ÿ‡ด': 'BO', '๐Ÿ‡ง๐Ÿ‡ถ': 'BQ', '๐Ÿ‡ง๐Ÿ‡ท': 'BR', '๐Ÿ‡ง๐Ÿ‡ธ': 'BS', '๐Ÿ‡ง๐Ÿ‡น': 'BT', '๐Ÿ‡ง๐Ÿ‡ป': 'BV', '๐Ÿ‡ง๐Ÿ‡ผ': 'BW', '๐Ÿ‡ง๐Ÿ‡พ': 'BY', '๐Ÿ‡ง๐Ÿ‡ฟ': 'BZ', '๐Ÿ‡จ๐Ÿ‡ฆ': 'CA', '๐Ÿ‡จ๐Ÿ‡จ': 'CC', '๐Ÿ‡จ๐Ÿ‡ฉ': 'CD', '๐Ÿ‡จ๐Ÿ‡ซ': 'CF', '๐Ÿ‡จ๐Ÿ‡ฌ': 'CG', '๐Ÿ‡จ๐Ÿ‡ญ': 'CH', '๐Ÿ‡จ๐Ÿ‡ฎ': 'CI', '๐Ÿ‡จ๐Ÿ‡ฐ': 'CK', '๐Ÿ‡จ๐Ÿ‡ฑ': 'CL', '๐Ÿ‡จ๐Ÿ‡ฒ': 'CM', '๐Ÿ‡จ๐Ÿ‡ณ': 'CN', '๐Ÿ‡จ๐Ÿ‡ด': 'CO', '๐Ÿ‡จ๐Ÿ‡ท': 'CR', '๐Ÿ‡จ๐Ÿ‡บ': 'CU', '๐Ÿ‡จ๐Ÿ‡ป': 'CV', '๐Ÿ‡จ๐Ÿ‡ผ': 'CW', '๐Ÿ‡จ๐Ÿ‡ฝ': 'CX', '๐Ÿ‡จ๐Ÿ‡พ': 'CY', '๐Ÿ‡จ๐Ÿ‡ฟ': 'CZ', '๐Ÿ‡ฉ๐Ÿ‡ช': 'DE', '๐Ÿ‡ฉ๐Ÿ‡ฏ': 'DJ', '๐Ÿ‡ฉ๐Ÿ‡ฐ': 'DK', '๐Ÿ‡ฉ๐Ÿ‡ฒ': 'DM', '๐Ÿ‡ฉ๐Ÿ‡ด': 'DO', '๐Ÿ‡ฉ๐Ÿ‡ฟ': 'DZ', '๐Ÿ‡ช๐Ÿ‡จ': 'EC', '๐Ÿ‡ช๐Ÿ‡ช': 'EE', '๐Ÿ‡ช๐Ÿ‡ฌ': 'EG', '๐Ÿ‡ช๐Ÿ‡ญ': 'EH', '๐Ÿ‡ช๐Ÿ‡ท': 'ER', '๐Ÿ‡ช๐Ÿ‡ธ': 'ES', '๐Ÿ‡ช๐Ÿ‡น': 'ET', '๐Ÿ‡ซ๐Ÿ‡ฎ': 'FI', '๐Ÿ‡ซ๐Ÿ‡ฏ': 'FJ', '๐Ÿ‡ซ๐Ÿ‡ฐ': 'FK', '๐Ÿ‡ซ๐Ÿ‡ฒ': 'FM', '๐Ÿ‡ซ๐Ÿ‡ด': 'FO', '๐Ÿ‡ซ๐Ÿ‡ท': 'FR', '๐Ÿ‡ฌ๐Ÿ‡ฆ': 'GA', '๐Ÿ‡ฌ๐Ÿ‡ง': 'GB', '๐Ÿ‡ฌ๐Ÿ‡ฉ': 'GD', '๐Ÿ‡ฌ๐Ÿ‡ช': 'GE', '๐Ÿ‡ฌ๐Ÿ‡ซ': 'GF', '๐Ÿ‡ฌ๐Ÿ‡ฌ': 'GG', '๐Ÿ‡ฌ๐Ÿ‡ญ': 'GH', '๐Ÿ‡ฌ๐Ÿ‡ฎ': 'GI', '๐Ÿ‡ฌ๐Ÿ‡ฑ': 'GL', '๐Ÿ‡ฌ๐Ÿ‡ฒ': 'GM', '๐Ÿ‡ฌ๐Ÿ‡ณ': 'GN', '๐Ÿ‡ฌ๐Ÿ‡ต': 'GP', '๐Ÿ‡ฌ๐Ÿ‡ถ': 'GQ', '๐Ÿ‡ฌ๐Ÿ‡ท': 'GR', '๐Ÿ‡ฌ๐Ÿ‡ธ': 'GS', '๐Ÿ‡ฌ๐Ÿ‡น': 'GT', '๐Ÿ‡ฌ๐Ÿ‡บ': 'GU', '๐Ÿ‡ฌ๐Ÿ‡ผ': 'GW', '๐Ÿ‡ฌ๐Ÿ‡พ': 'GY', '๐Ÿ‡ญ๐Ÿ‡ฐ': 'HK', '๐Ÿ‡ญ๐Ÿ‡ฒ': 'HM', '๐Ÿ‡ญ๐Ÿ‡ณ': 'HN', '๐Ÿ‡ญ๐Ÿ‡ท': 'HR', '๐Ÿ‡ญ๐Ÿ‡น': 'HT', '๐Ÿ‡ญ๐Ÿ‡บ': 'HU', '๐Ÿ‡ฎ๐Ÿ‡ฉ': 'ID', '๐Ÿ‡ฎ๐Ÿ‡ช': 'IE', '๐Ÿ‡ฎ๐Ÿ‡ฑ': 'IL', '๐Ÿ‡ฎ๐Ÿ‡ฒ': 'IM', '๐Ÿ‡ฎ๐Ÿ‡ณ': 'IN', '๐Ÿ‡ฎ๐Ÿ‡ด': 'IO', '๐Ÿ‡ฎ๐Ÿ‡ถ': 'IQ', '๐Ÿ‡ฎ๐Ÿ‡ท': 'IR', '๐Ÿ‡ฎ๐Ÿ‡ธ': 'IS', '๐Ÿ‡ฎ๐Ÿ‡น': 'IT', '๐Ÿ‡ฏ๐Ÿ‡ช': 'JE', '๐Ÿ‡ฏ๐Ÿ‡ฒ': 'JM', '๐Ÿ‡ฏ๐Ÿ‡ด': 'JO', '๐Ÿ‡ฏ๐Ÿ‡ต': 'JP', '๐Ÿ‡ฐ๐Ÿ‡ช': 'KE', '๐Ÿ‡ฐ๐Ÿ‡ฌ': 'KG', '๐Ÿ‡ฐ๐Ÿ‡ญ': 'KH', '๐Ÿ‡ฐ๐Ÿ‡ฎ': 'KI', '๐Ÿ‡ฐ๐Ÿ‡ฒ': 'KM', '๐Ÿ‡ฐ๐Ÿ‡ณ': 'KN', '๐Ÿ‡ฐ๐Ÿ‡ต': 'KP', '๐Ÿ‡ฐ๐Ÿ‡ท': 'KR', '๐Ÿ‡ฐ๐Ÿ‡ผ': 'KW', '๐Ÿ‡ฐ๐Ÿ‡พ': 'KY', '๐Ÿ‡ฐ๐Ÿ‡ฟ': 'KZ', '๐Ÿ‡ฑ๐Ÿ‡ฆ': 'LA', '๐Ÿ‡ฑ๐Ÿ‡ง': 'LB', '๐Ÿ‡ฑ๐Ÿ‡จ': 'LC', '๐Ÿ‡ฑ๐Ÿ‡ฎ': 'LI', '๐Ÿ‡ฑ๐Ÿ‡ฐ': 'LK', '๐Ÿ‡ฑ๐Ÿ‡ท': 'LR', '๐Ÿ‡ฑ๐Ÿ‡ธ': 'LS', '๐Ÿ‡ฑ๐Ÿ‡น': 'LT', '๐Ÿ‡ฑ๐Ÿ‡บ': 'LU', '๐Ÿ‡ฑ๐Ÿ‡ป': 'LV', '๐Ÿ‡ฑ๐Ÿ‡พ': 'LY', '๐Ÿ‡ฒ๐Ÿ‡ฆ': 'MA', '๐Ÿ‡ฒ๐Ÿ‡จ': 'MC', '๐Ÿ‡ฒ๐Ÿ‡ฉ': 'MD', '๐Ÿ‡ฒ๐Ÿ‡ช': 'ME', '๐Ÿ‡ฒ๐Ÿ‡ซ': 'MF', '๐Ÿ‡ฒ๐Ÿ‡ฌ': 'MG', '๐Ÿ‡ฒ๐Ÿ‡ญ': 'MH', '๐Ÿ‡ฒ๐Ÿ‡ฐ': 'MK', '๐Ÿ‡ฒ๐Ÿ‡ฑ': 'ML', '๐Ÿ‡ฒ๐Ÿ‡ฒ': 'MM', '๐Ÿ‡ฒ๐Ÿ‡ณ': 'MN', '๐Ÿ‡ฒ๐Ÿ‡ด': 'MO', '๐Ÿ‡ฒ๐Ÿ‡ต': 'MP', '๐Ÿ‡ฒ๐Ÿ‡ถ': 'MQ', '๐Ÿ‡ฒ๐Ÿ‡ท': 'MR', '๐Ÿ‡ฒ๐Ÿ‡ธ': 'MS', '๐Ÿ‡ฒ๐Ÿ‡น': 'MT', '๐Ÿ‡ฒ๐Ÿ‡บ': 'MU', '๐Ÿ‡ฒ๐Ÿ‡ป': 'MV', '๐Ÿ‡ฒ๐Ÿ‡ผ': 'MW', '๐Ÿ‡ฒ๐Ÿ‡ฝ': 'MX', '๐Ÿ‡ฒ๐Ÿ‡พ': 'MY', '๐Ÿ‡ฒ๐Ÿ‡ฟ': 'MZ', '๐Ÿ‡ณ๐Ÿ‡ฆ': 'NA', '๐Ÿ‡ณ๐Ÿ‡จ': 'NC', '๐Ÿ‡ณ๐Ÿ‡ช': 'NE', '๐Ÿ‡ณ๐Ÿ‡ซ': 'NF', '๐Ÿ‡ณ๐Ÿ‡ฌ': 'NG', '๐Ÿ‡ณ๐Ÿ‡ฎ': 'NI', '๐Ÿ‡ณ๐Ÿ‡ฑ': 'NL', '๐Ÿ‡ณ๐Ÿ‡ด': 'NO', '๐Ÿ‡ณ๐Ÿ‡ต': 'NP', '๐Ÿ‡ณ๐Ÿ‡ท': 'NR', '๐Ÿ‡ณ๐Ÿ‡บ': 'NU', '๐Ÿ‡ณ๐Ÿ‡ฟ': 'NZ', '๐Ÿ‡ด๐Ÿ‡ฒ': 'OM', '๐Ÿ‡ต๐Ÿ‡ฆ': 'PA', '๐Ÿ‡ต๐Ÿ‡ช': 'PE', '๐Ÿ‡ต๐Ÿ‡ซ': 'PF', '๐Ÿ‡ต๐Ÿ‡ฌ': 'PG', '๐Ÿ‡ต๐Ÿ‡ญ': 'PH', '๐Ÿ‡ต๐Ÿ‡ฐ': 'PK', '๐Ÿ‡ต๐Ÿ‡ฑ': 'PL', '๐Ÿ‡ต๐Ÿ‡ฒ': 'PM', '๐Ÿ‡ต๐Ÿ‡ณ': 'PN', '๐Ÿ‡ต๐Ÿ‡ท': 'PR', '๐Ÿ‡ต๐Ÿ‡ธ': 'PS', '๐Ÿ‡ต๐Ÿ‡น': 'PT', '๐Ÿ‡ต๐Ÿ‡ผ': 'PW', '๐Ÿ‡ต๐Ÿ‡พ': 'PY', '๐Ÿ‡ถ๐Ÿ‡ฆ': 'QA', '๐Ÿ‡ท๐Ÿ‡ช': 'RE', '๐Ÿ‡ท๐Ÿ‡ด': 'RO', '๐Ÿ‡ท๐Ÿ‡ธ': 'RS', '๐Ÿ‡ท๐Ÿ‡บ': 'RU', '๐Ÿ‡ท๐Ÿ‡ผ': 'RW', '๐Ÿ‡ธ๐Ÿ‡ฆ': 'SA', '๐Ÿ‡ธ๐Ÿ‡ง': 'SB', '๐Ÿ‡ธ๐Ÿ‡จ': 'SC', '๐Ÿ‡ธ๐Ÿ‡ฉ': 'SD', '๐Ÿ‡ธ๐Ÿ‡ช': 'SE', '๐Ÿ‡ธ๐Ÿ‡ฌ': 'SG', '๐Ÿ‡ธ๐Ÿ‡ญ': 'SH', '๐Ÿ‡ธ๐Ÿ‡ฎ': 'SI', '๐Ÿ‡ธ๐Ÿ‡ฏ': 'SJ', '๐Ÿ‡ธ๐Ÿ‡ฐ': 'SK', '๐Ÿ‡ธ๐Ÿ‡ฑ': 'SL', '๐Ÿ‡ธ๐Ÿ‡ฒ': 'SM', '๐Ÿ‡ธ๐Ÿ‡ณ': 'SN', '๐Ÿ‡ธ๐Ÿ‡ด': 'SO', '๐Ÿ‡ธ๐Ÿ‡ท': 'SR', '๐Ÿ‡ธ๐Ÿ‡ธ': 'SS', '๐Ÿ‡ธ๐Ÿ‡น': 'ST', '๐Ÿ‡ธ๐Ÿ‡ป': 'SV', '๐Ÿ‡ธ๐Ÿ‡ฝ': 'SX', '๐Ÿ‡ธ๐Ÿ‡พ': 'SY', '๐Ÿ‡ธ๐Ÿ‡ฟ': 'SZ', '๐Ÿ‡น๐Ÿ‡จ': 'TC', '๐Ÿ‡น๐Ÿ‡ฉ': 'TD', '๐Ÿ‡น๐Ÿ‡ซ': 'TF', '๐Ÿ‡น๐Ÿ‡ฌ': 'TG', '๐Ÿ‡น๐Ÿ‡ญ': 'TH', '๐Ÿ‡น๐Ÿ‡ฏ': 'TJ', '๐Ÿ‡น๐Ÿ‡ฐ': 'TK', '๐Ÿ‡น๐Ÿ‡ฑ': 'TL', '๐Ÿ‡น๐Ÿ‡ฒ': 'TM', '๐Ÿ‡น๐Ÿ‡ณ': 'TN', '๐Ÿ‡น๐Ÿ‡ด': 'TO', '๐Ÿ‡น๐Ÿ‡ท': 'TR', '๐Ÿ‡น๐Ÿ‡น': 'TT', '๐Ÿ‡น๐Ÿ‡ป': 'TV', '๐Ÿ‡น๐Ÿ‡ผ': 'TW', '๐Ÿ‡น๐Ÿ‡ฟ': 'TZ', '๐Ÿ‡บ๐Ÿ‡ฆ': 'UA', '๐Ÿ‡บ๐Ÿ‡ฌ': 'UG', '๐Ÿ‡บ๐Ÿ‡ฒ': 'UM', '๐Ÿ‡บ๐Ÿ‡ธ': 'US', '๐Ÿ‡บ๐Ÿ‡พ': 'UY', '๐Ÿ‡บ๐Ÿ‡ฟ': 'UZ', '๐Ÿ‡ป๐Ÿ‡ฆ': 'VA', '๐Ÿ‡ป๐Ÿ‡จ': 'VC', '๐Ÿ‡ป๐Ÿ‡ช': 'VE', '๐Ÿ‡ป๐Ÿ‡ฌ': 'VG', '๐Ÿ‡ป๐Ÿ‡ฎ': 'VI', '๐Ÿ‡ป๐Ÿ‡ณ': 'VN', '๐Ÿ‡ป๐Ÿ‡บ': 'VU', '๐Ÿ‡ผ๐Ÿ‡ซ': 'WF', '๐Ÿ‡ผ๐Ÿ‡ธ': 'WS', '๐Ÿ‡พ๐Ÿ‡ช': 'YE', '๐Ÿ‡พ๐Ÿ‡น': 'YT', '๐Ÿ‡ฟ๐Ÿ‡ฆ': 'ZA', '๐Ÿ‡ฟ๐Ÿ‡ฒ': 'ZM', '๐Ÿ‡ฟ๐Ÿ‡ผ': 'ZW'} + + + +@dataclass +class Country: + alpha_2: str + alpha_3: str + name: str + numeric: int + emoji: str + + @classmethod + def by_pycountry(cls, country: CountryTyping, emoji: str = "") -> "Country": + emoji = "" + alpha_2 = country.alpha_2.upper() + + if alpha_2 in emoji_map: + emoji=emoji_map[alpha_2] + + + return cls( + alpha_2=country.alpha_2, + alpha_3=country.alpha_3, + name=country.name, + numeric=country.numeric, + emoji=emoji + ) + + @classmethod + def by_alpha_2(cls, alpha_2: str) -> "Country": + return cls.by_pycountry(pycountry.countries.get(alpha_2=alpha_2)) + + @classmethod + def by_apha_3(cls, alpha_3: str) -> "Country": + return cls.by_pycountry(pycountry.countries.get(alpha_3=alpha_3)) + + @classmethod + def by_numeric(cls, numeric: int) -> "Country": + return cls.by_pycountry(pycountry.countries.get(numeric=numeric)) + + @classmethod + def by_name(cls, name: str) -> "Country": + return cls.by_pycountry(pycountry.countries.get(name=name)) + + @classmethod + def by_emoji(cls, flag: str) -> "Country": + return cls.by_alpha_2(emoji_map[flag]) + + @classmethod + def by_official_name(cls, official_name: str) -> "Country": + return cls.by_pycountry(pycountry.countries.get(official_name=official_name)) + + def __hash__(self) -> int: + return hash(self.alpha_3) + + def __eq__(self, __value: object) -> bool: + return self.__hash__() == __value.__hash__() \ No newline at end of file diff --git a/src/music_kraken/pages/__init__.py b/src/music_kraken/pages/__init__.py index b562686..f8d82bb 100644 --- a/src/music_kraken/pages/__init__.py +++ b/src/music_kraken/pages/__init__.py @@ -1,5 +1,5 @@ from .encyclopaedia_metallum import EncyclopaediaMetallum from .musify import Musify -from .youtube import YouTube +from .youtube.youtube import YouTube from .abstract import Page, INDEPENDENT_DB_OBJECTS diff --git a/src/music_kraken/cli/options/invidious/__init__.py b/src/music_kraken/pages/youtube/__init__.py similarity index 100% rename from src/music_kraken/cli/options/invidious/__init__.py rename to src/music_kraken/pages/youtube/__init__.py diff --git a/src/music_kraken/pages/youtube/piped.py b/src/music_kraken/pages/youtube/piped.py new file mode 100644 index 0000000..e69de29 diff --git a/src/music_kraken/pages/youtube.py b/src/music_kraken/pages/youtube/youtube.py similarity index 97% rename from src/music_kraken/pages/youtube.py rename to src/music_kraken/pages/youtube/youtube.py index 40c62b5..5c7eba1 100644 --- a/src/music_kraken/pages/youtube.py +++ b/src/music_kraken/pages/youtube/youtube.py @@ -5,9 +5,9 @@ from enum import Enum import sponsorblock from sponsorblock.errors import HTTPException, NotFoundException -from ..objects import Source, DatabaseObject, Song, Target -from .abstract import Page -from ..objects import ( +from ...objects import Source, DatabaseObject, Song, Target +from ..abstract import Page +from ...objects import ( Artist, Source, SourcePages, @@ -18,9 +18,9 @@ from ..objects import ( FormattedText, ID3Timestamp ) -from ..connection import Connection -from ..utils.support_classes import DownloadResult -from ..utils.shared import YOUTUBE_LOGGER, INVIDIOUS_INSTANCE, BITRATE, ENABLE_SPONSOR_BLOCK +from ...connection import Connection +from ...utils.support_classes import DownloadResult +from ...utils.shared import YOUTUBE_LOGGER, INVIDIOUS_INSTANCE, BITRATE, ENABLE_SPONSOR_BLOCK """ diff --git a/src/music_kraken/utils/config/connection.py b/src/music_kraken/utils/config/connection.py index d6e8225..8996f38 100644 --- a/src/music_kraken/utils/config/connection.py +++ b/src/music_kraken/utils/config/connection.py @@ -67,18 +67,22 @@ class ConnectionSection(Section): # INVIDIOUS INSTANCES LIST self.INVIDIOUS_INSTANCE = UrlStringAttribute( name="invidious_instance", - description="This is a List, where you can define the invidious instances,\n" + description="This is an attribute, where you can define the invidious instances,\n" "the youtube downloader should use.\n" "Here is a list of active ones: https://docs.invidious.io/instances/\n" "Instances that use cloudflare or have source code changes could cause issues.\n" "Hidden instances (.onion) will only work, when setting 'tor=true'.", value="https://yt.artemislena.eu/" ) - # INVIDIOUS PROXY - self.INVIDIOUS_PROXY_VIDEOS = BoolAttribute( - name="invidious_proxy_video", - value="false", - description="Downloads the videos using the given instances." + + self.PIPED_INSTANCE = UrlStringAttribute( + name="piped_instance", + description="This is an attribute, where you can define the pioed instances,\n" + "the youtube downloader should use.\n" + "Here is a list of active ones: https://github.com/TeamPiped/Piped/wiki/Instances\n" + "Instances that use cloudflare or have source code changes could cause issues.\n" + "Hidden instances (.onion) will only work, when setting 'tor=true'.", + value="https://pipedapi.kavin.rocks" ) self.SPONSOR_BLOCK = BoolAttribute( @@ -93,7 +97,7 @@ class ConnectionSection(Section): self.CHUNK_SIZE, self.SHOW_DOWNLOAD_ERRORS_THRESHOLD, self.INVIDIOUS_INSTANCE, - self.INVIDIOUS_PROXY_VIDEOS, + self.PIPED_INSTANCE, self.SPONSOR_BLOCK ]