示例#1
0
 def playlists(self, authorId):
     params = {
         "view": "1",
         "sort": "lad",
         "hl": getSetting("youtube.hl", unicode),
         "gl": getSetting("youtube.gl", unicode)
     }
     return self.get("".join(
         (self.__baseUrl__, "/channel/{}/playlists".format(authorId))),
                     params=params)
示例#2
0
 def onSettingsChanged(self):
     if self.__history__ and not getSetting("search_history", bool):
         update = ((self.__query__.get("action") == "search")
                   and (len(self.__query__) > 1))
         clearSearchHistory(update=update)
     self.__setup__()
     containerRefresh()
示例#3
0
def selectInstance():
    instance = getSetting("instance", unicode)
    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], unicode)
示例#4
0
def selectLocation():
    gl = getSetting("youtube.gl", unicode)
    keys = list(iterkeys(locations))
    values = list(itervalues(locations))
    preselect = keys.index(gl) if gl in locations else -1
    index = selectDialog(values, heading=30127, preselect=preselect)
    if index >= 0:
        setSetting("youtube.gl", keys[index], unicode)
        setSetting("youtube.gl.text", values[index], unicode)
示例#5
0
def selectLanguage():
    hl = getSetting("youtube.hl", unicode)
    keys = list(iterkeys(languages))
    values = list(itervalues(languages))
    preselect = keys.index(hl) if hl in languages else -1
    index = selectDialog(values, heading=30125, preselect=preselect)
    if index >= 0:
        setSetting("youtube.hl", keys[index], unicode)
        setSetting("youtube.hl.text", values[index], unicode)
示例#6
0
 def search(self, **kwargs):
     history = getSetting("search_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)
     self.__searches__.clear()
     return self.addDirectory(
         self.getSubfolders("search", new=(not history)))
示例#7
0
def addTorrent(item_meta, torrent_objects):
    try:
        if tools.getSetting('general.torrentCache') == 'false':
            return

        if 'showInfo' in item_meta:
            season = item_meta['info']['season']
            episode = item_meta['info']['episode']
            trakt_id = item_meta['showInfo']['ids']['trakt']
        else:
            season = 0
            episode = 0
            trakt_id = item_meta['ids']['trakt']

        tools.torrentScrapeCacheFile_lock.acquire()
        cursor = _get_connection_cursor(tools.torrentScrapeCacheFile)

        try:
            # Confirm we are on the newer version of the torrent cache database
            columns = [i['name'] for i in cursor.execute("PRAGMA table_info(cache);").fetchall()]
            if 'trakt_id' not in columns:
                raise Exception
        except:
            cursor.execute("DROP TABLE IF EXISTS cache")

        _try_create_torrent_cache(cursor)
        for torrent_object in torrent_objects:
            try:
                hash = torrent_object['hash']
                pack = torrent_object['package']
                cursor.execute("REPLACE INTO %s (trakt_id, meta, hash, season, episode, package) "
                               "VALUES (?, ?, ?, ?, ?, ?)" % cache_table,
                               (trakt_id, str(torrent_object), hash, season, episode, pack))
            except:
                import traceback
                traceback.print_exc()

        cursor.connection.commit()
        cursor.close()
    except:
        try:
            cursor.close()
        except:
            pass
        import traceback
        traceback.print_exc()
        return []
    finally:
        tools.try_release_lock(tools.torrentScrapeCacheFile_lock)
示例#8
0
 def _new_search(self, history=False, **kwargs):
     try:
         query, kwargs = self.__searches__.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
示例#9
0
def getTorrents(item_meta):
    if tools.getSetting('general.torrentCache') == 'false':
        return []
    tools.torrentScrapeCacheFile_lock.acquire()
    try:
        cursor = _get_connection_cursor(tools.torrentScrapeCacheFile)
        _try_create_torrent_cache(cursor)
        if 'showInfo' in item_meta:
            season = item_meta['info']['season']
            episode = item_meta['info']['episode']
            trakt_id = item_meta['showInfo']['ids']['trakt']

            cursor.execute("SELECT * FROM %s WHERE trakt_id=? AND package=?" % cache_table, (trakt_id, 'show'))
            torrent_list = cursor.fetchall()
            cursor.execute("SELECT * FROM %s WHERE trakt_id=? AND package=? AND season=?" % cache_table,
                           (trakt_id, 'season', season))
            torrent_list += cursor.fetchall()
            cursor.execute("SELECT * FROM %s WHERE trakt_id=? AND package=? AND season=? AND episode=?" % cache_table,
                           (trakt_id, 'single', season, episode))
            torrent_list += cursor.fetchall()
        else:
            trakt_id = item_meta['ids']['trakt']

            cursor.execute("SELECT * FROM %s WHERE trakt_id=?" % cache_table, (trakt_id,))
            torrent_list = cursor.fetchall()

        cursor.close()

        torrent_list = [ast.literal_eval(torrent['meta']) for torrent in torrent_list]

        return torrent_list

    except:
        try:
            cursor.close()
        except:
            pass
        import traceback
        traceback.print_exc()
        return []
    finally:
        tools.try_release_lock(tools.torrentScrapeCacheFile_lock)
示例#10
0
 def __setup__(self):
     timeout = getSetting("timeout", float)
     if timeout <= 0:
         self.__timeout__ = None
     else:
         self.__timeout__ = (((timeout - (timeout % 3)) + 0.05), timeout)
     self.__region__ = getSetting("youtube.gl", unicode)
     self.__history__ = getSetting("search_history", bool)
     self.__scheme__ = "https" if getSetting("ssl", bool) else "http"
     self.__netloc__ = getSetting("instance", unicode)
     path = "{}/".format(getSetting("path", unicode).strip("/"))
     self.__url__ = urlunsplit(
         (self.__scheme__, self.__netloc__, path, "", ""))
     log("service.url: '{}'".format(self.__url__))
     log("service.timeout: {}".format(self.__timeout__))
示例#11
0
 def video(self, videoId):
     params = {"v": videoId, "hl": getSetting("youtube.hl", unicode)}
     return self.get("".join((self.__baseUrl__, "/watch")), params=params)
示例#12
0
 def video(self, **kwargs):
     args = client.video(proxy=getSetting("proxy", bool), **kwargs)
     return self.playItem(*args) if args else False
示例#13
0
 def addSettings(self):
     if getSetting("settings", bool):
         return self.addItem(settingsItem(self.url, action="settings"))
     return True
示例#14
0
 def enabled(self):
     return (getSetting(self.type, bool)
             if self.get("optional", False) else True)