Ejemplo n.º 1
0
 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)
Ejemplo n.º 2
0
 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__()
Ejemplo n.º 3
0
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)
Ejemplo n.º 4
0
 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()
Ejemplo n.º 5
0
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)
Ejemplo n.º 6
0
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)
Ejemplo n.º 7
0
 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)))
Ejemplo n.º 8
0
 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
Ejemplo n.º 9
0
 def __setup__(self):
     self.__first__ = getSetting("first", int)
     self.__nsfw__ = getSetting("nsfw", bool)
     self.__language__ = getLanguage()
     self.__session__.__setup__()
Ejemplo n.º 10
0
 def __setup__(self, init=False):
     if (timeout := getSetting("timeout", float)) <= 0.0:
         self.timeout = None
Ejemplo n.º 11
0
 def video(self, **kwargs):
     args, kwargs = client.video(proxy=getSetting("proxy", bool), **kwargs)
     return self.playItem(*args, **kwargs) if args else False
Ejemplo n.º 12
0
 def addSettings(self):
     if getSetting("settings", bool):
         return self.addItem(settingsItem(self.url, action="settings"))
     return True
Ejemplo n.º 13
0
 def enabled(self):
     return (getSetting(self.type, bool)
             if self.get("optional", False) else True)
Ejemplo n.º 14
0
 def video(self, videoId):
     params = {"v": videoId, "hl": getSetting("hl", str)}
     return self.get(f"{self.__url__}/watch", params=params)