def playlists(self, authorId): params = { "view": "1", "sort": "lad", "hl": getSetting("hl", str), "gl": getSetting("gl", str) } return self.get(f"{self.__url__}/channel/{authorId}/playlists", params=params)
def __setup__(self): self.__region__ = getSetting("gl", str) self.__history__ = getSetting("history", bool) self.__scheme__ = "https" if getSetting("ssl", bool) else "http" self.__netloc__ = getSetting("instance", str) path = f"{getSetting('path', str).strip('/')}/" self.__url__ = urlunsplit( (self.__scheme__, self.__netloc__, path, "", "") ) self.logger.info(f"instance: {self.__url__!r}") self.__session__.__setup__()
def selectInstance(): instance = getSetting("instance", str) instances = client.instances(sort_by="health") if instances: preselect = instances.index(instance) if instance in instances else -1 index = selectDialog(instances, heading=30105, preselect=preselect) if index >= 0: setSetting("instance", instances[index], str)
def onSettingsChanged(self): if self.__history__ and not getSetting("history", bool): update = ( (self.__query__.get("action") == "search") and (len(self.__query__) > 1) ) clearSearchHistory(update=update) self.__setup__() containerRefresh()
def selectLocation(): gl = getSetting("gl", str) keys = list(locations.keys()) values = list(locations.values()) preselect = keys.index(gl) if gl in locations else -1 if (index := selectDialog(values, heading=30127, preselect=preselect)) >= 0: setSetting("gl", keys[index], str) setSetting("gl.text", values[index], str)
def selectLanguage(): hl = getSetting("hl", str) keys = list(languages.keys()) values = list(languages.values()) preselect = keys.index(hl) if hl in languages else -1 if (index := selectDialog(values, heading=30125, preselect=preselect)) >= 0: setSetting("hl", keys[index], str) setSetting("hl.text", values[index], str)
def search(self, **kwargs): history = getSetting("history", bool) if "type" in kwargs: query = kwargs.pop("query", "") new = kwargs.pop("new", False) if query: return self.__search__(query, **kwargs) if new: return self.__new_search__(history=history, **kwargs) return self.__history__(**kwargs) search_cache.clear() return self.addDirectory( self.getSubfolders("search", new=(not history)))
def __new_search__(self, history=False, **kwargs): try: query, kwargs = search_cache.pop() except IndexError: index = getSetting("sort_by", int) try: sort_by = sortBy[index] except IndexError: sort_by = None query, kwargs["sort_by"] = newSearch(kwargs["type"], sort_by=sort_by, history=history) if query: return self.__search__(query, **kwargs) return False
def __setup__(self): self.__first__ = getSetting("first", int) self.__nsfw__ = getSetting("nsfw", bool) self.__language__ = getLanguage() self.__session__.__setup__()
def __setup__(self, init=False): if (timeout := getSetting("timeout", float)) <= 0.0: self.timeout = None
def video(self, **kwargs): args, kwargs = client.video(proxy=getSetting("proxy", bool), **kwargs) return self.playItem(*args, **kwargs) if args else False
def addSettings(self): if getSetting("settings", bool): return self.addItem(settingsItem(self.url, action="settings")) return True
def enabled(self): return (getSetting(self.type, bool) if self.get("optional", False) else True)
def video(self, videoId): params = {"v": videoId, "hl": getSetting("hl", str)} return self.get(f"{self.__url__}/watch", params=params)