コード例 #1
0
def feed_update(args):
    """Usage:
    recorder feed update

Generate rss feed files.

    """
    config = Configuration()
    root = Station(config, 'root', None, 'All recordings')
    root.filename = config.destination
    root.slug = ''
    root.shows = config.stations.values()

    config.icons_db = database.open('icons_db')
    with database.open('episodes_db') as db:
        _cleanup_database(db)
        db.sync()

        generate_feed(config, db, root)
        generate_page(config, db, root)
        for station in config.stations.values():
            generate_feed(config, db, station)
            generate_page(config, db, station)
            for show in station.shows:
                generate_feed(config, db, show)
                generate_page(config, db, show)
コード例 #2
0
def _migrate_files_to_episodesdb(config):
    "Method to import files residing in the filesystem into the episodes_db"

    show_mappings = {}
    for show in config.shows.values():
        old_path = os.path.join(
            slugify(show.author),
            slugify(show.name)
        )
        show_mappings[old_path] = show
        show_mappings[show.slug] = show

    import glob

    with database.open('episodes_db') as db:
        episode_filenames = db.keys()
        for filename in glob.glob(os.path.join(config.destination, "*", "*", "*.*")):
            relative_filename = filename.replace(config.destination + '/', '')
            if filename.endswith('.xml'):
                continue

            if relative_filename in episode_filenames:
                continue

            show_slug = os.path.dirname(relative_filename)
            if show_slug not in show_mappings.keys():
                logging.warning(
                    "Could not migrate {} to episode_db".format(filename))
                continue

            logging.info("Migrate {}".format(filename))

            show = show_mappings[show_slug]
            episode = migrate_mediafile_to_episode(config, filename, show)
            db[episode.slug] = episode
コード例 #3
0
def feed_list(args):
    """Usage:
    recorder feed list

    List all episodes containes in any rss feeds.
    """
    with database.open('episodes_db') as db:
        for episode in sorted(db.values()):
            print("{}: {}".format(episode.slug, episode))
コード例 #4
0
def config_update(args):
    """Usage:
    recorder config update

Update program settings and episodes database.

    """
    config = Configuration()

    show_mappings = {}
    for show in config.shows.values():
        old_path = os.path.join(slugify(show.author), slugify(show.name))
        show_mappings[old_path] = show
        show_mappings[show.slug] = show

    import glob

    with database.open('episodes_db') as db:
        episode_filenames = db.keys()
        for filename in glob.glob(
                os.path.join(config.destination, "*", "*", "*.*")):
            relative_filename = filename.replace(config.destination + '/', '')
            if filename.endswith('.xml'):
                continue

            if relative_filename in episode_filenames:
                continue

            show_slug = os.path.dirname(relative_filename)
            if show_slug not in show_mappings.keys():
                logging.warning(
                    "Could not migrate {} to episode_db".format(filename))
                continue

            logging.info("Migrate {}".format(filename))

            show = show_mappings[show_slug]
            episode = migrate_mediafile_to_episode(config, filename, show)
            db[episode.slug] = episode
コード例 #5
0
def show_capture(*args):
    """Usage:
    recorder show capture [--duration=<duration>] [options]

Capture a show.

Options:
    --duration,-d=<duration> Set the duration, overrides show setting

Examples:
    1. Capture an episode of the show 'nighttalk'
        recorder show capture nighttalk

    2. Capture an episode of the show 'nighttalk', but only 35 minutes
        recorder show capture nighttalk -d 35m

    """
    config = Configuration()
    if len(config.stations) == 0:
        print('No stations defined, add stations at first!')
        sys.exit(0)

    if len(config.shows) == 0:
        print('No shows defined, add shows at first!')
        sys.exit(0)
    args = args[0]
    if args['<show>'] in config.shows:
        show = config.shows[args['<show>']]
        try:
            recorder = Recorder()
            episode = recorder.capture(config, show)
            db = database.open('episodes_db')
            db[episode.slug] = episode
            db.close()
        except Exception as e:
            logging.error('Unable to capture recording: {}'.format(e))
    else:
        print('Unknown show %r' % args['<show>'])