def get_id_list(path): id_list = [] if os.path.exists(path): with open(path, 'r') as file: for line in file: url = parse_twitch_url(line) if url is None: print('Incorrect: %s' % line) else: id_list.append(url['id']) else: print('Path can not be resolved.') return id_list
help='maximal size of cache list, 1 corresponds to ~1MB (default: %(default)s)') parser.add_argument('--urls_file', metavar='FILE', help='path to file with a list of urls, one per line.') args = vars(parser.parse_args()) start = time.clock() if args['url'] is None and args['ids'] is None and args['urls_file'] is None and args['channel_name'] is None: print('Require at least a broadcast url.\nShort manual: %s -h' % sys.argv[0]) sys.exit(1) try: if args['path']: os.chdir(args['path']) if args['url']: info = parse_twitch_url(args['url']) if info is None: print('Incorrect url passed.') sys.exit(1) else: if info['type'] == 'b': print('Old format broadcasts is not supported.') sys.exit(1) elif info['type'] == 'c': print('Old format highlights is not supported.') sys.exit(1) elif info['type'] == 'v': print('Downloading /v/%s...' % info['id']) download_ids([info['id']], resume=not args['reload'], num_threads=args['threads'],