コード例 #1
0
ファイル: scheduler.py プロジェクト: xealot/avsnatch
    def run(self):
        session = get_session()
        beanstalk = beanstalkc.Connection(host='localhost', port=11300)

        while self.active:
            # Look for episodes that we want, that should be or become available shortly and set to searching.
            waiting_episodes = Episode.get_waiting(session)
            for ep in waiting_episodes:
                print 'Set to {} :: {}'.format(ESTATE_SEARCHING, unicode(ep))
                ep.state = ESTATE_SEARCHING
            session.commit()

            print beanstalk.peek_ready()

            # The basic way this works is that we will peek at various job queues and make sure
            # spawn subprocesses to manage those queues.

            # Any episodes that require searching, spawn a process to search NZB repository.
            # SPAWN SEARCH PROCESS

            # Any episode that has a candidate NZB, spawn a download process.
            # SPAWN DOWNLOAD PROCESS

            # Any episode that has completed download, begin stitching of file.
            # SPAWN FILE STITCHER/REPAIR/UNCOMPRESS

            # Any episode that is complete but for post processing...
            # SPAWN post processor.

            time.sleep(self.sleep_time)
        beanstalk.close()
コード例 #2
0
ファイル: show.py プロジェクト: xealot/avsnatch
    def start(self, args, config):
        #:TODO: Move this logic into the CORE so it can be used via library access.
        today = datetime.today()
        session = get_session()

        # Lookup Series Information
        tv = load_info_source('tv', config['TVDB_API_KEY'])
        series = tv.get_series(args.series_id)
        episodes = series.pop('episodes')

        # Add series and episode data to database.
        series = Series(**series)
        session.merge(series)

        for e in episodes:
            episode = Episode(**e)
            episode.state = ESTATE_SKIPPED if episode.air_date < today else ESTATE_WANTED
            session.merge(episode)

        session.commit()

        print 'The series, "{}" has been added/updated along with {} episodes.'.format(series.name, len(episodes))