예제 #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()
예제 #2
0
def print_courses():
    courses = get_completed_courses()
    if len(courses) == 0:
        sys.stdout.write(
            f'{bcolors.FAIL} No completed courses found!  {bcolors.BKENDC}\n')
    for course in courses:
        sys.stdout.write(
            f'{bcolors.BKGREEN} {course.id}. {course.name}  {bcolors.BKENDC}\n')
예제 #3
0
def handle_courses(args):
    thread = start_thread(print_courses)
    if wait(thread):
        if len(get_completed_courses()) == 0:
            exit()

        required_courses = get_to_download()

        for course_id in required_courses:
            course = list(filter(lambda x: x.id == course_id,
                                 get_completed_courses()))[0]

            if(args.all):
                download_course(course.link, args.path,
                                args.all, args.all, args.all)
            else:
                download_course(course.link, args.path,
                                args.video, args.exercise, args.dataset)