Пример #1
0
    def _tvrageGetInfo(self):

        _shows = feeds.search(self.series.titleBase)
        if not _shows:
            raise SeriesNotFound
        if len(_shows) == 1:
            _series = Series(tvrage=etree_to_dict(_shows[0])["show"])
            if matching(self.series.title.lower(), _series.title.lower(), factor=85):
                _series = Series(tvrage=_shows[0])
                self.series.update(_series)
                self.series.source = "tvrage"
                self.series.tvrage_info = _series
                return
            else:
                raise SeriesNotFound

        _rankings = {}
        for _show in _shows:
            _series = Series(tvrage=etree_to_dict(_show)["show"])
            _score = matching(self.series.title.lower(), self.decode(_series.titleBase.lower()))
            if _score < 85:
                continue

            if _score in _rankings[_series.status]:
                _rankings[_series.status][_score][_series.title] = _series
            else:
                _rankings[_series.status][_score] = {_series.title: _series}

        if not _rankings:
            raise SeriesNotFound

        self._reviewShowData(_rankings, "tvrage")

        return
Пример #2
0
def fuzzy_search(show_name):
    '''
    This method searches the TVRage database for a given showname. The search is
    fuzzy, so looking for "doctor" will return Doctor Who (2005) as well. The
    result is a list of (name, sid) tuples.
    '''
    tree = ET.ElementTree(feeds.search(show_name))
    names = tree.findall(tvrpath.SEARCH_NAME)
    ids = tree.findall(tvrpath.SEARCH_ID)
    results = map(lambda (x, y) : (x.text, y.text), zip(names, ids))
    return results
Пример #3
0
def search():
    query = ''
    if 'query' in request.args:
        query = request.args['query']

    feed = feeds.search(query)

    shows = []
    for s in feed:
        show_info = parse_show_info(s)
        show_info['saved'] = db.show_exists(show_info['showid'])
        shows.append(show_info)

    return render_template('search.html', query=query, shows=shows)
Пример #4
0
    def _tvrageGetInfo(self):

        _shows = feeds.search(self.series.titleBase)
        if not _shows: raise SeriesNotFound
        if len(_shows) == 1:
            _series = Series(tvrage=etree_to_dict(_shows[0])['show'])
            if matching(self.series.title.lower(),
                        _series.title.lower(),
                        factor=85):
                _series = Series(tvrage=_shows[0])
                self.series.update(_series)
                self.series.source = 'tvrage'
                self.series.tvrage_info = _series
                return
            else:
                raise SeriesNotFound

        _rankings = {}
        for _show in _shows:
            _series = Series(tvrage=etree_to_dict(_show)['show'])
            _score = matching(self.series.title.lower(),
                              self.decode(_series.titleBase.lower()))
            if _score < 85:
                continue

            if _score in _rankings[_series.status]:
                _rankings[_series.status][_score][_series.title] = _series
            else:
                _rankings[_series.status][_score] = {_series.title: _series}

        if not _rankings:
            raise SeriesNotFound

        self._reviewShowData(_rankings, 'tvrage')

        return
Пример #5
0
    for idx, col in enumerate(cursor.description):
        d[col[0]] = row[idx]
    return d


db_file = '/home/sm/.nzb/shows.v2.sqlite3'
sql = "SELECT name, season, episode, thetvdb_series_id, search_engine_name, ragetv_series_id, status \
    FROM shows ORDER BY replace (name, 'The ', '');"
conn = sqlite3.connect(db_file)
conn.row_factory = dict_factory
curs = conn.cursor()
# ddata = curs.execute(sql)
curs.execute(sql)
ddata = curs.fetchall()
for x in ddata:
    s = feeds.search(x['name'])
    rage_name = s.getchildren()[0].getchildren()[1].text
    rage_id = s.getchildren()[0].getchildren()[0].text

    print x['name'], '---', rage_name
    # print x['thetvdb_series_id'], rage_id

    # for title in s:
    #    print '    ', title.getchildren()[1].text,
    #    print '-', title.getchildren()[0].text

    # correct = ask ('Correct?')

    update_sql = 'update shows set ragetv_series_id=:ragetv_series_id where thetvdb_series_id=:thetvdb_series_id'
    update_vals = {'ragetv_series_id': rage_id, 'thetvdb_series_id': x['thetvdb_series_id']}
    curs.execute(update_sql, update_vals)