示例#1
0
    def test_tvrage(self):
        friends = lookup_series("Friends")
        assert friends.genres == ["Comedy", "Romance/Dating"]
        s1e22 = friends.find_episode(1, 22)
        log.info("s1e22 %s " % s1e22)

        # Testing next
        s1e23 = s1e22.next()
        log.info("s1e23 %s " % s1e23)
        assert s1e23.episode == 23 and s1e23.season == 1

        s1e24 = s1e23.next()
        assert s1e24.episode == 24 and s1e24.season == 1
        log.info("s1e24 %s " % s1e24)

        s2e1 = s1e24.next()
        assert s2e1.episode == 1 and s2e1.season == 2
        log.info("s2e1 %s " % s2e1)

        s31e1 = friends.find_episode(31, 1)
        assert not s31e1
        log.info("s31e1 %s " % s31e1)
        s1e1 = friends.find_episode(1, 1)
        assert s1e1
        log.info("s1e1 %s " % s1e1)
        s1e32 = friends.find_episode(1, 32)
        log.info("s1e32 %s " % s1e32)
        assert not s1e32
        assert friends.finished()
    def estimate(self, entry):
        season = entry['series_season']
        if entry.get('series_id_type') == 'sequence':
            # Tvrage has absolute numbered shows under season 1
            season = 1
        log.debug("Querying release estimation for %s S%02dE%02d ..." %
                  (entry['series_name'], season, entry['series_episode']))
        with Session(expire_on_commit=False) as session:
            try:
                series_info = lookup_series(name=entry['series_name'], session=session)
            except LookupError as e:
                log.debug('tvrage lookup error: %s' % e)
            except OverflowError:
                # There is a bug in tvrage library on certain platforms if an episode is marked as airing
                # before 1970. We can safely assume the episode has been released. See #2739
                log.debug('tvrage library crash due to date before 1970, assuming released')
                return datetime(1970, 1, 1)
            else:
                if series_info:
                    try:
                        episode_info = series_info.find_episode(season, entry['series_episode'])
                        if episode_info:
                            return episode_info.airdate
                        else:
                            # If episode does not exist in tvrage database, we always return a future date
                            log.verbose('%s S%02dE%02d does not exist in tvrage database, assuming unreleased',
                                        series_info.name, season, entry['series_episode'])
                            return datetime.now() + timedelta(weeks=4)
                    except Exception as e:
                        log.exception(e)
                else:
                    log.debug('No series info obtained from TVRage to %s' % entry['series_name'])

        log.debug('No episode info obtained from TVRage for %s season %s episode %s' %
                  (entry['series_name'], entry['series_season'], entry['series_episode']))
示例#3
0
    def test_tvrage(self):
        friends = lookup_series("Friends")
        assert friends.genres == ['Comedy', 'Romance/Dating']
        s1e22 = friends.find_episode(1, 22)
        log.info("s1e22 %s " % s1e22)

        # Testing next
        s1e23 = s1e22.next()
        log.info("s1e23 %s " % s1e23)
        assert s1e23.episode == 23 and s1e23.season == 1

        s1e24 = s1e23.next()
        assert s1e24.episode == 24 and s1e24.season == 1
        log.info("s1e24 %s " % s1e24)

        s2e1 = s1e24.next()
        assert s2e1.episode == 1 and s2e1.season == 2
        log.info("s2e1 %s " % s2e1)

        s31e1 = friends.find_episode(31, 1)
        assert not s31e1
        log.info("s31e1 %s " % s31e1)
        s1e1 = friends.find_episode(1, 1)
        assert s1e1
        log.info("s1e1 %s " % s1e1)
        s1e32 = friends.find_episode(1, 32)
        log.info("s1e32 %s " % s1e32)
        assert not s1e32
        assert friends.finished()
示例#4
0
    def estimate(self, entry):
        if all(field in entry for field in ['series_name', 'series_season', 'series_episode']):
            # Try to get airdate from tvrage first
            if api_tvrage:
                season = entry['series_season']
                if entry.get('series_id_type') == 'sequence':
                    # Tvrage has absolute numbered shows under season 1
                    season = 1
                log.debug("Querying release estimation for %s S%02dE%02d ..." %
                          (entry['series_name'], season, entry['series_episode']))
                try:
                    series_info = lookup_series(name=entry['series_name'])
                except LookupError as e:
                    log.debug('tvrage lookup error: %s' % e)
                else:
                    if series_info:
                        try:
                            episode_info = series_info.find_episode(season, entry['series_episode'])
                            if episode_info:
                                return episode_info.airdate
                            else:
                                # If episode does not exist in tvrage database, we always return a future date
                                log.verbose('%s S%02dE%02d does not exist in tvrage database, assuming unreleased',
                                          series_info.name, season, entry['series_episode'])
                                return datetime.now() + timedelta(weeks=4)
                        except Exception as e:
                            log.exception(e)
                    else:
                        log.debug('No series info obtained from TVRage to %s' % entry['series_name'])

                log.debug('No episode info obtained from TVRage for %s season %s episode %s' %
                          (entry['series_name'], entry['series_season'], entry['series_episode']))

            # If no results from tvrage, estimate a date based on series history
            session = Session()
            series = session.query(Series).filter(Series.name == entry['series_name']).first()
            if not series:
                return
            episodes = (session.query(Episode).join(Episode.series).
                        filter(Episode.season != None).
                        filter(Series.id == series.id).
                        filter(Episode.season == func.max(Episode.season).select()).
                        order_by(desc(Episode.number)).limit(2).all())
            if len(episodes) < 2:
                return
            # If last two eps were not contiguous, don't guess
            if episodes[0].number != episodes[1].number + 1:
                return
            last_diff = episodes[0].first_seen - episodes[1].first_seen
            # If last eps were grabbed close together, we might be catching up, don't guess
            # Or, if last eps were too far apart, don't guess
            # TODO: What range?
            if last_diff < timedelta(days=2) or last_diff > timedelta(days=10):
                return
            # Estimate next season somewhat more than a normal episode break
            if entry['series_season'] > episodes[0].season:
                # TODO: How big should this be?
                return episodes[0].first_seen + multiply_timedelta(last_diff, 2)
            # Estimate next episode comes out about same length as last ep span, with a little leeway
            return episodes[0].first_seen + multiply_timedelta(last_diff, 0.9)
示例#5
0
    def test_tvrage(self):
        with Session(expire_on_commit=False) as session:
            friends = lookup_series("Friends", session=session)
            assert friends.genres == ['Comedy', 'Romance/Dating']
            s1e22 = friends.find_episode(1, 22)
            log.info("s1e22 %s " % s1e22)

            # Testing next
            s1e23 = s1e22.next()
            log.info("s1e23 %s " % s1e23)
            assert s1e23.episode == 23 and s1e23.season == 1

            s1e24 = s1e23.next()
            assert s1e24.episode == 24 and s1e24.season == 1
            log.info("s1e24 %s " % s1e24)

            s2e1 = s1e24.next()
            assert s2e1.episode == 1 and s2e1.season == 2
            log.info("s2e1 %s " % s2e1)

            s31e1 = friends.find_episode(31, 1)
            assert not s31e1
            log.info("s31e1 %s " % s31e1)
            s1e1 = friends.find_episode(1, 1)
            assert s1e1
            log.info("s1e1 %s " % s1e1)
            s1e32 = friends.find_episode(1 ,32)
            log.info("s1e32 %s " % s1e32)
            assert not s1e32
            assert friends.finished()
示例#6
0
    def do_search_tvsearch(self, arg_entry, config=None):
        log.info('Searching for %s' % (arg_entry['title']))
        # normally this should be used with emit_series who has provided season and episodenumber
        if 'series_name' not in arg_entry or 'series_season' not in arg_entry or 'series_episode' not in arg_entry:
            return []
        serie_info = lookup_series(arg_entry['series_name'])
        if not serie_info:
            return []

        url = (config['url'] + '&rid=%s&season=%s&ep=%s' %
               (serie_info.showid, arg_entry['series_season'], arg_entry['series_episode']))
        return self.fill_entries_for_url(url, config)
示例#7
0
    def do_search_tvsearch(self, arg_entry, config=None):
        log.info('Searching for %s' % (arg_entry['title']))
        # normally this should be used with emit_series who has provided season and episodenumber
        if 'series_name' not in arg_entry or 'series_season' not in arg_entry or 'series_episode' not in arg_entry:
            return []
        serie_info = lookup_series(arg_entry['series_name'])
        if not serie_info:
            return []

        url = (config['url'] + '&rid=%s&season=%s&ep=%s' %
               (serie_info.showid, arg_entry['series_season'], arg_entry['series_episode']))
        return self.fill_entries_for_url(url, config)
 def get_series_info(self, series_name):
     return lookup_series(name=series_name)
示例#9
0
    def estimate(self, entry):
        if all(field in entry for field in ['series_name', 'series_season', 'series_episode']):
            # Try to get airdate from tvrage first
            if api_tvrage:
                season = entry['series_season']
                if entry.get('series_id_type') == 'sequence':
                    # Tvrage has absolute numbered shows under season 1
                    season = 1
                log.debug("Querying release estimation for %s S%02dE%02d ..." %
                          (entry['series_name'], season, entry['series_episode']))
                try:
                    series_info = lookup_series(name=entry['series_name'])
                except LookupError as e:
                    log.debug('tvrage lookup error: %s' % e)
                else:
                    if series_info:
                        try:
                            episode_info = series_info.find_episode(season, entry['series_episode'])
                            if episode_info:
                                return episode_info.airdate
                            else:
                                # If episode does not exist in tvrage database, we always return a future date
                                log.verbose('%s S%02dE%02d does not exist in tvrage database, assuming unreleased',
                                          series_info.name, season, entry['series_episode'])
                                return datetime.now() + timedelta(weeks=4)
                        except Exception as e:
                            log.exception(e)
                    else:
                        log.debug('No series info obtained from TVRage to %s' % entry['series_name'])

                log.debug('No episode info obtained from TVRage for %s season %s episode %s' %
                          (entry['series_name'], entry['series_season'], entry['series_episode']))

            # If no results from tvrage, estimate a date based on series history
            with contextlib.closing(Session()) as session:
                series = session.query(Series).filter(Series.name == entry['series_name']).first()
                if not series:
                    return
                episodes = (session.query(Episode).join(Episode.series).
                            filter(Episode.season != None).
                            filter(Series.id == series.id).
                            filter(Episode.season == func.max(Episode.season).select()).
                            order_by(desc(Episode.number)).limit(2).all())

                if len(episodes) < 2:
                    return
                # If last two eps were not contiguous, don't guess
                if episodes[0].number != episodes[1].number + 1:
                    return
                last_diff = episodes[0].first_seen - episodes[1].first_seen
                # If last eps were grabbed close together, we might be catching up, don't guess
                # Or, if last eps were too far apart, don't guess
                # TODO: What range?
                if last_diff < timedelta(days=2) or last_diff > timedelta(days=10):
                    return
                # Estimate next season somewhat more than a normal episode break
                if entry['series_season'] > episodes[0].season:
                    # TODO: How big should this be?
                    return episodes[0].first_seen + multiply_timedelta(last_diff, 2)
                # Estimate next episode comes out about same length as last ep span, with a little leeway
                return episodes[0].first_seen + multiply_timedelta(last_diff, 0.9)
示例#10
0
 def get_series_info(self, series_name):
     return lookup_series(name=series_name)