Esempio n. 1
0
def main(argv):
    program, _ = os.path.splitext(os.path.basename(argv[0]))
    usage = "Usage: %s <announce> [--announce_list <arg>] " \
            "file1.torrent [file2.torrent...]" % program
    helpmsg = '\n'.join(
        (usage, announce_details,
         '\n'.join(' ' * 4 + l
                   for l in announcelist_details.split('\n')[:-2])))

    try:
        opts, args = getopt.getopt(argv[1:], "ha:v",
                                   ("help", "announce_list=", "verbose"))
    except getopt.error as msg:
        print(msg)
        return 1

    if len(args) < 2:
        print(helpmsg)
        return 2

    announce = args[0]
    announce_list = None
    verbose = False

    for opt, arg in opts:
        if opt in ('-h', '--help'):
            print(helpmsg)
            return 0
        elif opt in ('-a', '--announce_list'):
            announce_list = arg
        elif opt in ('-v', '--verbose'):
            verbose = True

    for fname in args[1:]:
        reannounce(fname, announce, announce_list, verbose)
Esempio n. 2
0
def main(argv):
    program, _ = os.path.splitext(os.path.basename(argv[0]))
    usage = "Usage: %s <announce> [--announce_list <arg>] " \
            "file1.torrent [file2.torrent...]" % program
    helpmsg = '\n'.join((usage, announce_details, '\n'.join(' ' * 4 + l
                        for l in announcelist_details.split('\n')[:-2])))

    try:
        opts, args = getopt.getopt(argv[1:], "hav",
                                   ("help", "announce_list", "verbose"))
    except getopt.error as msg:
        print msg
        return 1

    if len(args) < 2:
        print helpmsg
        return 2

    announce = args[0]
    announce_list = None
    verbose = False

    for opt, arg in opts:
        if opt in ('-h', '--help'):
            print helpmsg
            return 0
        elif opt in ('-a', '--announce_list'):
            announce_list = [tier.split(',') for tier in arg.split('|')]
        elif opt in ('-v', '--verbose'):
            verbose = True

    for fname in args[1:]:
        reannounce(fname, announce, announce_list, verbose)
Esempio n. 3
0
def main(argv):
    """Copy announce information from source to all specified torrents"""
    program, _ = os.path.splitext(os.path.basename(argv[0]))
    usage = "Usage: %s <source.torrent> <file1.torrent> " \
            "[file2.torrent...]" % program
    try:
        opts, args = getopt.getopt(argv[1:], "hv",
                                   ("help", "verbose"))
    except getopt.error as msg:
        print msg
        return 1

    if len(args) < 2:
        print "%s\n%s\n" % (usage, main.__doc__)
        return 2

    source_metainfo = MetaInfo.read(args[0])

    verbose = False

    for opt, _ in opts:
        if opt in ('-h', '--help'):
            print "%s\n%s\n" % (usage, main.__doc__)
            return 0
        elif opt in ('-v', '--verbose'):
            verbose = True

    announce = source_metainfo['announce']
    announce_list = source_metainfo.get('announce-list')

    if verbose:
        print 'new announce: ' + announce
        if announce_list:
            print 'new announce-list: ' + \
                '|'.join(','.join(tier) for tier in announce_list)

    for fname in args[1:]:
        reannounce(fname, announce, announce_list, verbose)

    return 0
Esempio n. 4
0
def main(argv):
    """Copy announce information from source to all specified torrents"""
    program, _ = os.path.splitext(os.path.basename(argv[0]))
    usage = "Usage: %s <source.torrent> <file1.torrent> " \
            "[file2.torrent...]" % program
    try:
        opts, args = getopt.getopt(argv[1:], "hv", ("help", "verbose"))
    except getopt.error as msg:
        print msg
        return 1

    if len(args) < 2:
        print "%s\n%s\n" % (usage, main.__doc__)
        return 2

    source_metainfo = MetaInfo.read(args[0])

    verbose = False

    for opt, _ in opts:
        if opt in ('-h', '--help'):
            print "%s\n%s\n" % (usage, main.__doc__)
            return 0
        elif opt in ('-v', '--verbose'):
            verbose = True

    announce = source_metainfo['announce']
    announce_list = source_metainfo.get('announce-list')

    if verbose:
        print 'new announce: ' + announce
        if announce_list:
            print 'new announce-list: ' + \
                '|'.join(','.join(tier) for tier in announce_list)

    for fname in args[1:]:
        reannounce(fname, announce, announce_list, verbose)

    return 0