Пример #1
0
def handle_tv_show_episode(data):
    type, filename, show_name = data[0], data[1], data[2]
    assert type == 'tv show'
    if Show.objects.filter(canonical_name__exact=canonical_format(show_name)).count():
        add_episode(data)
        print 'added episode', data
        return True
    else:
        if show_name in is_not_tv_show_cache:
            return False
        matches = tvdb.get_series(show_name)
        match = None
        for m in matches:
            if canonical_format(m['name']) == canonical_format(show_name):
                match = m
                break
        if match:
            if not SuggestedShow.objects.filter(name=match['name']).count():
                SuggestedShow.objects.create(name=match['name'])
                print 'found potential new show "%s"' % canonical_format(show_name)
                return True
        else:
            print 'did not find', show_name, 'on tvdb, ignoring...'
            is_not_tv_show_cache.add(show_name)
    return False
Пример #2
0
def _my_shows():
    with plugin.get_storage('myshows.pcl') as storage:
        myshows = storage.get('myshows', [])
    with plugin.get_storage('tvshows.pcl') as tvshows:
        for index, show in enumerate(myshows):
            if show not in tvshows:
                tvshows[show] = tvdb.get_series(show)
            list_item = {
                'label':
                tvshows[show]['SeriesName'],
                'url':
                plugin.get_url(action='episodes',
                               mode='search',
                               search_imdb=tvshows[show]['IMDB_ID'],
                               myshows='true'),
                'context_menu':
                [('Show info', 'Action(Info)'),
                 ('Remove from "My Shows"...',
                  'RunScript({commands},myshows_remove,{index})'.format(
                      commands=commands, index=index))]
            }
            _set_info(list_item, {
                'show_info': tvshows[show],
                'tvdb_episode_info': None
            })
            _set_art(list_item, {
                'show_info': tvshows[show],
                'tvdb_episode_info': None
            })
            list_item['info']['video']['mediatype'] = 'tvshow'
            yield list_item
Пример #3
0
 def _validate(self):
     if not (self._tvdb_edit.getText()
             and self._select_folder_button.getLabel()):
         dialog.ok(
             'Invalid input!',
             '"TheTVDB ID" and "Download folder" fields must not be empty.')
         return False
     elif not re.search(r'^\d+$', self._tvdb_edit.getText()):
         dialog.ok('Invalid TheTVDB ID!',
                   '"TheTVDB ID" field must contain only numbers.')
         return False
     else:
         with plugin.get_storage('tvshows.pcl') as tvshows:
             show = tvshows.get(self.filter['tvdb'])
             if show is None:
                 try:
                     show = get_series(self.filter['tvdb'])
                 except TvdbError:
                     dialog.ok(
                         'Invalid TheTVDB ID!',
                         'TheTVDB does not have a TV show with such ID.')
                     return False
                 else:
                     tvshows[self.filter['tvdb']] = show
             self.filter['name'] = show['SeriesName']
             self._filter_name.setLabel(show['SeriesName'])
             return True
Пример #4
0
def get_series_data(series_name):
    series_name = series_name.lower()
    global series_data
    if series_name not in series_data:
        #print 'getting data for', series_name
        if series_name == 'the daily show':
            series = tvdb.get_series('The Daily Show with Jon Stewart')[0]
        else:
            series = tvdb.get_series(series_name)[0]
        raw_data = tvdb.get_series_all(series['id'])
        series_data[series_name] = {'season_episode': {}, 'aired': {}}
        for data in raw_data['episodes']:
            if 'season_number' in data and 'episode_number' in data:
                series_data[series_name]['season_episode']['%s %s' % (data['season_number'], data['episode_number'])] = data
            if 'first_aired' in data and data['first_aired']:
                dt = data['first_aired']
                series_data[series_name]['aired'][date(dt.year, dt.month, dt.day)] = data
    return series_data[series_name]
Пример #5
0
def add_suggested_show(request, suggested_show_id, option):
    s = SuggestedShow.objects.get(pk=suggested_show_id)
    tvdb_result = tvdb.get_series(s.name)
    description = tvdb_result[0]['overview'] if len(tvdb_result) else ''
    Show.objects.create(name=s.name, description=description, canonical_name=canonical_format(s.name), auto_erase=(option=='erase'))
    s.delete()
    if SuggestedShow.objects.filter(ignored=False).count():
        return HttpResponse(':back')
    else:
        return HttpResponse(':back2')
Пример #6
0
 def get_series(self, nome, limite=5):
     """busca no cache, se não houver referencia, adiciona no cache e retorna"""
     tvdb.API_KEY = self.key
     def teste(reg):
             return nome.lower() in reg['name'].lower()
     
     sublist = self.search(teste, self.cached_series, limite)
     if len(sublist) < limite:
         sublist = tvdb.get_series(nome)[:limite]
         self.cached_series += sublist
     return sublist
Пример #7
0
def get_series_data(series_name):
    series_name = series_name.lower()
    global series_data
    if series_name not in series_data:
        # print 'getting data for', series_name
        if series_name == "the daily show":
            series = tvdb.get_series("The Daily Show with Jon Stewart")[0]
        else:
            series = tvdb.get_series(series_name)[0]
        raw_data = tvdb.get_series_all(series["id"])
        series_data[series_name] = {"season_episode": {}, "aired": {}}
        for data in raw_data["episodes"]:
            if "season_number" in data and "episode_number" in data:
                series_data[series_name]["season_episode"][
                    "%s %s" % (data["season_number"], data["episode_number"])
                ] = data
            if "first_aired" in data and data["first_aired"]:
                dt = data["first_aired"]
                series_data[series_name]["aired"][date(dt.year, dt.month, dt.day)] = data
    return series_data[series_name]
Пример #8
0
Файл: views.py Проект: boxed/CMi
def add_suggested_show(request, suggested_show_id, option):
    s = SuggestedShow.objects.get(pk=suggested_show_id)
    tvdb_result = tvdb.get_series(s.name)
    description = tvdb_result[0]['overview'] if len(tvdb_result) else ''
    try:
        Show.objects.create(name=s.name,
                            description=description,
                            canonical_name=canonical_format(s.name),
                            auto_erase=(option == 'erase'))
    except IntegrityError:
        pass
    s.delete()
    if SuggestedShow.objects.filter(ignored=False).count():
        return HttpResponse(':back')
    else:
        return HttpResponse(':back2')
Пример #9
0
Файл: views.py Проект: boxed/CMi
def add_suggested_show(request, suggested_show_id, option):
    s = SuggestedShow.objects.get(pk=suggested_show_id)
    tvdb_result = tvdb.get_series(s.name)
    description = tvdb_result[0]["overview"] if len(tvdb_result) else ""
    try:
        Show.objects.create(
            name=s.name,
            description=description,
            canonical_name=canonical_format(s.name),
            auto_erase=(option == "erase"),
        )
    except IntegrityError:
        pass
    s.delete()
    if SuggestedShow.objects.filter(ignored=False).count():
        return HttpResponse(":back")
    else:
        return HttpResponse(":back2")
Пример #10
0
def get_series_data(series_name):
    series_name = series_name.lower()
    global series_data
    if series_name not in series_data:
        tvdb_series_name = get_tvdb_name(series_name)
        matches = tvdb.get_series(tvdb_series_name)
        if not matches:
            series_data[tvdb_series_name] = None
            return None
        series = matches[0]
        raw_data = tvdb.get_series_all(series['id'])
        series_data[series_name] = {'season_episode': {}, 'aired': {}}
        for data in raw_data['episodes']:
            if 'season_number' in data and 'episode_number' in data:
                series_data[series_name]['season_episode']['%s %s' % (data['season_number'], data['episode_number'])] = data
            if 'first_aired' in data and data['first_aired']:
                dt = data['first_aired']
                series_data[series_name]['aired'][date(dt.year, dt.month, dt.day)] = data
    return series_data.get(series_name)
Пример #11
0
def get_series_data(series_name):
    series_name = series_name.lower()
    global series_data
    if series_name not in series_data:
        tvdb_series_name = get_tvdb_name(series_name)
        matches = tvdb.get_series(tvdb_series_name)
        if not matches:
            series_data[tvdb_series_name] = None
            return None
        series = matches[0]
        raw_data = tvdb.get_series_all(series['id'])
        series_data[series_name] = {'season_episode': {}, 'aired': {}}
        for data in raw_data['episodes']:
            if 'season_number' in data and 'episode_number' in data:
                series_data[series_name]['season_episode'][
                    '%s %s' %
                    (data['season_number'], data['episode_number'])] = data
            if 'first_aired' in data and data['first_aired']:
                dt = data['first_aired']
                series_data[series_name]['aired'][date(dt.year, dt.month,
                                                       dt.day)] = data
    return series_data.get(series_name)
Пример #12
0
def add_show_info(torrent, tvshows):
    """
    Add show info from TheTVDB to the torrent

    :param torrent: a torrent object from Rarbg
    :type torrent: dict
    :param tvshows: TV shows database with info from TheTVDB
    :type tvshows: dict
    """
    tvdbid = torrent['episode_info']['tvdb']
    show_info = tvshows.get(tvdbid)
    if show_info is None:
        try:
            show_info = tvdb.get_series(tvdbid)
        except RarbgError:
            plugin.log_error(
                'TheTVDB rerturned no data for ID {0}, torrent {1}'.format(
                    tvdbid, torrent['title']))
            show_info = None
        else:
            show_info['IMDB_ID'] = torrent['episode_info'][
                'imdb']  # This fix is mostly for the new "The X-Files"
        tvshows[tvdbid] = show_info
    torrent['show_info'] = show_info
Пример #13
0
 def GET(self, name):
     return json.dumps(get_series(name))
 def searchTvShow(self, title):
     log.info("Searching TVDB for '%s'" % title)
     series = tvdb.get_series(title)
     log.debug("Found series '%s'" % str(series))
     return self.choose(series, "Select Tv show...")
Пример #15
0
 def GET(self, name):
   return json.dumps(get_series(name))