예제 #1
0
def main(argv):
    if argv[0] == 'settoken':
        print_dash()
        con.set_token(argv[1])
    else:
        return

    if not con.active:
        return
    print_dash()
    print_desc()
    while True:
        print_dash()
        s = input('>> ')
        if s == 'list':
            thread = threading.Thread(target=print_tracks)
            thread.start()
            if print_waiting(thread):
                if len(get_completed_tracks()) == 0:
                    continue
                (s, v) = wait_download()
                if s is not None:
                    path, nums = split_download_command(s)
                    for i in nums:
                        track = list(
                            filter(lambda x: x.id == int(i),
                                   get_completed_tracks()))[0]
                        download_track(track, path, v)
        elif s == 'listc':
            thread = threading.Thread(target=print_courses)
            thread.start()
            if print_waiting(thread):
                if len(get_completed_courses()) == 0:
                    continue
                (s, v) = wait_download()
                if s is not None:
                    path, nums = split_download_command(s)
                    for i in nums:
                        track = list(
                            filter(lambda x: x.id == int(i),
                                   get_completed_courses()))[0]
                        download_course(track.link, path, v)
        elif s == 'copy':
            thread = threading.Thread(target=print_all_courses)
            thread.start()
            if print_waiting(thread):
                if len(get_all_courses()) == 0:
                    continue
                (s, v) = wait_download()
                if s is not None:
                    path, nums = split_download_command(s)
                    for i in nums:
                        track = list(
                            filter(lambda x: x.id == int(i),
                                   get_all_courses()))[0]
                        download_course(track.link, path, v)
        elif s == 'exit':
            sys.exit()
def handle_tracks(args):
    thread = start_thread(print_tracks)
    if wait(thread):
        if len(get_completed_tracks()) == 0:
            exit()
        required_tracks = get_to_download()

        for track_id in required_tracks:
            track = list(
                filter(lambda x: x.id == track_id, get_completed_tracks()))[0]
            if args.all:
                download_track(track.link, args.path, args.all, args.all,
                               args.all)
            else:
                download_track(track.link, args.path, args.video,
                               args.exercise, args.dataset)
예제 #3
0
def push_track_to_s3(track_id):
	track = track_collection.find_one({'track_id': track_id})
	track_content = download_track(track['track_url'], None)
	s3_key = Key(bucket)
	s3_key.key = track['s3_path']
	s3_key.set_contents_from_string(track_content)
	return 'Did it son'
예제 #4
0
def handle_tracks(args):
    thread = start_thread(print_tracks)
    if wait(thread):
        if len(get_completed_tracks()) == 0:
            exit()
    required_tracks_by_id = get_to_download()[1]
    required_tracks_by_link = get_to_download()[0]
    if(len(required_tracks_by_id) > 0):
        for track_id in required_tracks_by_id:
            track = list(filter(lambda x: x.id == track_id,
                                get_completed_tracks()))[0]
            if args.all:
                download_track(track.link, args.path, args.all, args.all, args.all)
            else:
                download_track(track.link, args.path, args.video, args.exercise, args.dataset)
    if(len(required_tracks_by_link) > 0):
        for course_link in required_tracks_by_link:
            if(args.all):
                download_track(course_link, args.path, args.all, args.all, args.all)
            else:
                download_track(course_link, args.path, args.video, args.exercise, args.dataset)