Ejemplo n.º 1
0
def tvol(no_cache, config_name):
    """Download and manage tv shows.

    Use `tvol COMMAND -h` to get help for each command.

    \b
       \/    TVOverlord source code is available at:
      [. ]   https://github.com/8cylinder/tv-overlord
       ^
      /^\\    Any feature requests or bug reports should go there.
     //^\\\\
    -^-._.--.-^^-.____._^-.^._
    """
    Config.get_config_data(config_name)
    DB.configure()

    if Config.version_notification:
        if v.new_version():
            msg = tvu.style(v.message, fg='green')
            click.secho(msg, err=True)

    te.ask()

    if no_cache:
        Config.use_cache = False
    else:
        Config.use_cache = True
Ejemplo n.º 2
0
def tvol(no_cache, config_name):
    """Download and manage tv shows.

    Use `tvol COMMAND -h` to get help for each command.

    \b
       \/    TVOverlord source code is available at:
      [. ]   https://github.com/8cylinder/tv-overlord
       ^
      /^\\    Any feature requests or bug reports should go there.
     //^\\\\
    -^-._.--.-^^-.____._^-.^._
    """
    Config.get_config_data(config_name)
    DB.configure()

    if Config.version_notification:
        if v.new_version():
            msg = tvu.style(v.message, fg='green')
            click.secho(msg, err=True)

    te.ask()

    if no_cache:
        Config.use_cache = False
    else:
        Config.use_cache = True
Ejemplo n.º 3
0
def transmission(debug):
    """This script passes the enviroment variables from transmission to
    tvoverlord.

    Transmission exports these enviroment variables:

    \b
    X TR_TORRENT_DIR
    X TR_TORRENT_HASH
    X TR_TORRENT_NAME
      TR_APP_VERSION
      TR_TIME_LOCALTIME
      TR_TORRENT_ID

    This script uses the ones marked with an X.  This information is
    used to manage the torrent after its been downloaded.

    """
    Config.get_config_data()
    DB.configure()
    telemetry('transmission_done')

    try:
        torrent_dir = os.environ['TR_TORRENT_DIR']
        torrent_hash = os.environ['TR_TORRENT_HASH']
        torrent_name = os.environ['TR_TORRENT_NAME']
    except KeyError:
        sys.exit('Enviroment variables not set')

    if debug:
        click.echo('torrent_hash: %s' % torrent_hash)
        click.echo('torrent_dir: %s' % torrent_dir)
        click.echo('torrent_name: %s' % torrent_name)

    DownloadManager(torrent_hash, torrent_dir, torrent_name, debug=debug)
Ejemplo n.º 4
0
def qbittorrent(info_hash, torrent_name, torrent_dir, debug):
    """Manage torrents downloaded by qBittorrent.

    \b
    In tools > options > downloads > Run external program
    Add: /absolute/path/to/qbittorrent_done %I %N %D
    """
    Config.get_config_data()
    DB.configure()
    telemetry('qbittorrent_done')

    if debug:
        click.echo('info_hash: %s' % info_hash)
        click.echo('torrent_dir: %s' % torrent_dir)
        click.echo('torrent_name: %s' % torrent_name)

    DownloadManager(info_hash, torrent_dir, torrent_name, debug=debug)
Ejemplo n.º 5
0
def qbittorrent(info_hash, torrent_name, torrent_dir, debug):
    """Manage torrents downloaded by qBittorrent.

    \b
    In tools > options > downloads > Run external program
    Add: /absolute/path/to/qbittorrent_done %I %N %D
    """
    Config.get_config_data()
    DB.configure()
    telemetry('qbittorrent_done')

    if debug:
        click.echo('info_hash: %s' % info_hash)
        click.echo('torrent_dir: %s' % torrent_dir)
        click.echo('torrent_name: %s' % torrent_name)

    DownloadManager(info_hash, torrent_dir,
                    torrent_name, debug=debug)
Ejemplo n.º 6
0
def deluge(torrent_hash, torrent_name, torrent_dir, debug):
    """Manage torrents downloaded by deluge.

    Deluge will call this script when the torrent has been downloaded.
    It will pass TORRENT_HASH, TORRENT_NAME and TORRENT_DIR as arguements.

    \b
    The execute plugin is needed for this to work.
    http://dev.deluge-torrent.org/wiki/Plugins/Execute
    """
    Config.get_config_data()
    DB.configure()
    telemetry('deluge_done')

    if debug:
        click.echo('torrent_hash: %s' % torrent_hash)
        click.echo('torrent_dir: %s' % torrent_dir)
        click.echo('torrent_name: %s' % torrent_name)

    DownloadManager(torrent_hash, torrent_dir, torrent_name, debug=debug)
Ejemplo n.º 7
0
def deluge(torrent_hash, torrent_name, torrent_dir, debug):
    """Manage torrents downloaded by deluge.

    Deluge will call this script when the torrent has been downloaded.
    It will pass TORRENT_HASH, TORRENT_NAME and TORRENT_DIR as arguements.

    \b
    The execute plugin is needed for this to work.
    http://dev.deluge-torrent.org/wiki/Plugins/Execute
    """
    Config.get_config_data()
    DB.configure()
    telemetry('deluge_done')

    if debug:
        click.echo('torrent_hash: %s' % torrent_hash)
        click.echo('torrent_dir: %s' % torrent_dir)
        click.echo('torrent_name: %s' % torrent_name)

    DownloadManager(torrent_hash, torrent_dir,
                    torrent_name, debug=debug)
Ejemplo n.º 8
0
def transmission(debug):
    """This script passes the enviroment variables from transmission to
    tvoverlord.

    Transmission exports these enviroment variables:

    \b
    X TR_TORRENT_DIR
    X TR_TORRENT_HASH
    X TR_TORRENT_NAME
      TR_APP_VERSION
      TR_TIME_LOCALTIME
      TR_TORRENT_ID

    This script uses the ones marked with an X.  This information is
    used to manage the torrent after its been downloaded.

    """
    Config.get_config_data()
    DB.configure()
    telemetry('transmission_done')

    try:
        torrent_dir = os.environ['TR_TORRENT_DIR']
        torrent_hash = os.environ['TR_TORRENT_HASH']
        torrent_name = os.environ['TR_TORRENT_NAME']
    except KeyError:
        sys.exit('Enviroment variables not set')

    if debug:
        click.echo('torrent_hash: %s' % torrent_hash)
        click.echo('torrent_dir: %s' % torrent_dir)
        click.echo('torrent_name: %s' % torrent_name)

    DownloadManager(torrent_hash, torrent_dir,
                    torrent_name, debug=debug)
Ejemplo n.º 9
0
def config(edit, test_se, show, create_config_name):
    """tvol's config information.

    Show information of where various files are, (config.ini,
    database) and a list of the search engines and the url's they use.
    """
    send(te, v)

    if create_config_name:
        Config.create_config(create_config_name, create=True)
        return

    if edit:
        click.edit(filename=Config.user_config)
        return

    if test_se:
        search = Search()
        search.test_each(test_se, show)
        return

    import shutil

    title = 'green'
    bold = True
    ul = True

    # file locations
    click.echo()
    click.secho('File locations:', fg=title, bold=bold, underline=ul)
    click.echo()

    click.echo('config file:     %s' % Config.user_config)
    click.echo('Database file:   %s' % Config.db_file)
    click.echo('NZB staging dir: %s' % Config.staging)
    click.echo('TV dir:          %s' % Config.tv_dir)
    click.echo('Alt client:      %s' % Config.client)
    click.echo('Magnet dir:      %s' % Config.magnet_dir)
    click.echo('Template:        %s' % Config.template)

    click.echo()
    for script in ['tvol', 'transmission_done', 'deluge_done']:
        loc = shutil.which(script)
        script = script + ':'
        click.echo('%s %s' % (script.ljust(18), loc))

    # config sets
    files = [f for f in os.listdir(Config.user_dir)
             if re.match('^.*\..*\.(sqlite3|ini)', f)]
    files.sort(key=lambda f: f.split('.')[1])
    if files:
        click.echo()
        click.secho('Config sets', fg=title, bold=bold, underline=ul)
        click.echo()
        count = 1
        for gr, items in groupby(files, key=lambda f: f.split('.')[1]):
            config_set = ', '.join(list(items))
            click.echo('%s. %s' % (count, config_set))
            count += 1

    # search engines
    click.echo()
    click.secho('Search engines:', fg=title, bold=bold, underline=ul)
    search = Search()
    engines_types = [search.torrent_engines, search.newsgroup_engines]
    for engines in engines_types:
        for engine in engines:
            click.echo()
            click.secho(engine.name, bold=True, nl=False)
            click.echo(' (%s)' % engine.shortname)
            try:
                for url in engine.provider_urls:
                    click.echo('  %s' % url)
            except AttributeError:
                # there is no provider_urls.  Most likely an nzb
                # search engine which only uses one url: engine.url.
                click.echo('  %s' % engine.url)

    # blacklisted search engines
    if Config.blacklist:
        click.echo()
        click.secho('Search engine blacklist:',
                    fg=title, bold=bold, underline=ul)
        click.echo()
        for bl in Config.blacklist:
            click.echo(bl)

    # ip addresses
    click.echo()
    click.secho('Ip address information:',
                fg=title, bold=bold, underline=ul)
    click.echo()

    l = Location()
    click.echo('Your public ip address:')
    click.secho('  %s' % l.ip, bold=True)
    if Config.warnvpn:
        click.echo()
        click.echo('Your whitelisted ip addresses:')
        whitelist = DB.get_config('ip_whitelist')
        short = '.'.join(l.ip.split('.')[:Config.parts_to_match])
        for ip in whitelist:
            color = None
            if ip.startswith(short):
                color = 'green'
            click.secho('  %s' % ip, fg=color)
Ejemplo n.º 10
0
def config(edit, test_se, show, create_config_name):
    """tvol's config information.

    Show information of where various files are, (config.ini,
    database) and a list of the search engines and the url's they use.
    """
    send(te, v)

    if create_config_name:
        Config.create_config(create_config_name, create=True)
        return

    if edit:
        click.edit(filename=Config.user_config)
        return

    if test_se:
        search = Search()
        search.test_each(test_se, show)
        return

    import shutil

    title = 'green'
    bold = True
    ul = True

    # file locations
    click.echo()
    click.secho('File locations:', fg=title, bold=bold, underline=ul)
    click.echo()

    click.echo('config file:     %s' % Config.user_config)
    click.echo('Database file:   %s' % Config.db_file)
    click.echo('NZB staging dir: %s' % Config.staging)
    click.echo('TV dir:          %s' % Config.tv_dir)
    click.echo('Alt client:      %s' % Config.client)
    click.echo('Magnet dir:      %s' % Config.magnet_dir)
    click.echo('Template:        %s' % Config.template)

    click.echo()
    for script in ['tvol', 'transmission_done', 'deluge_done']:
        loc = shutil.which(script)
        script = script + ':'
        click.echo('%s %s' % (script.ljust(18), loc))

    # config sets
    files = [f for f in os.listdir(Config.user_dir)
             if re.match('^.*\..*\.(sqlite3|ini)', f)]
    files.sort(key=lambda f: f.split('.')[1])
    if files:
        click.echo()
        click.secho('Config sets', fg=title, bold=bold, underline=ul)
        click.echo()
        count = 1
        for gr, items in groupby(files, key=lambda f: f.split('.')[1]):
            config_set = ', '.join(list(items))
            click.echo('%s. %s' % (count, config_set))
            count += 1

    # search engines
    click.echo()
    click.secho('Search engines:', fg=title, bold=bold, underline=ul)
    search = Search()
    engines_types = [search.torrent_engines, search.newsgroup_engines]
    for engines in engines_types:
        for engine in engines:
            click.echo()
            click.secho(engine.Provider.name, bold=True, nl=False)
            click.echo(' (%s)' % engine.Provider.shortname)
            for url in engine.Provider.provider_urls:
                click.echo('  %s' % url)

    # blacklisted search engines
    if Config.blacklist:
        click.echo()
        click.secho('Search engine blacklist:',
                    fg=title, bold=bold, underline=ul)
        click.echo()
        for bl in Config.blacklist:
            click.echo(bl)

    # ip addresses
    click.echo()
    click.secho('Ip address information:',
                fg=title, bold=bold, underline=ul)
    click.echo()

    l = Location()
    click.echo('Your public ip address:')
    click.secho('  %s' % l.ip, bold=True)
    if Config.warnvpn:
        click.echo()
        click.echo('Your whitelisted ip addresses:')
        whitelist = DB.get_config('ip_whitelist')
        short = '.'.join(l.ip.split('.')[:Config.parts_to_match])
        for ip in whitelist:
            color = None
            if ip.startswith(short):
                color = 'green'
            click.secho('  %s' % ip, fg=color)