# File 'apifile' should contain only one line with your Amara API key and Amara username. # Amara API can be found in Settins->Account-> API Access (bottom-right corner) file = open(apifile, "r") API_KEY, USERNAME = file.read().split()[0:] print("Using Amara username: "******"rm -f youtubedl.err youtubedl.out failed_yt.dat", shell=True) amara_headers = {"Content-Type": "application/json", "X-api-username": USERNAME, "X-api-key": API_KEY, "format": "json"} if len(ytids) < 20: # Do not print for large inputs print("This is what I got from the input file:") print(ytids) answer = answer_me("Should I proceed?") if not answer: sys.exit(1) # Main loop for i in range(len(ytids)): ytid_from = ytids[i][0] if opts.amara == True: ytid_to = ytids[i][1] else: ytid_to = ytids[i][0] video_url_from = "https://www.youtube.com/watch?v=" + ytid_from video_url_to = "https://www.youtube.com/watch?v=" + ytid_to
video_url_from = 'https://www.youtube.com/watch?v=%s' % ytid_from video_url_to = 'https://www.youtube.com/watch?v=%s' % ytid_to # PART 1: GETTING THE SUBTITLES # set this to false if you want to download only # when language is missing on Amara download_first = False subs = False if opts.yt and download_first == True: subs = download_yt_subtitles(lang, sub_format, ytid_from) if not subs: if opts.skip: answer = True else: answer = answer_me("Should I continue with the rest anyway?") if answer: continue else: sys.exit(1) elif opts.files == True: f = open(ytids[i][1], "r") subs = f.read() elif opts.amara == True: # First, get first Amara ID amara_response = amara.check_video(video_url_from) if amara_response['meta']['total_count'] == 0: print("ERROR: Source video is not on Amara! YTID=%s" % ytid_from) sys.exit(1)
print('Using Amara username: '******'Using Amara API key: '+API_KEY) call("rm -f youtubedl.out", shell=True) amara_headers = { 'Content-Type': 'application/json', 'X-api-username': USERNAME, 'X-api-key': API_KEY, 'format': 'json' } print("This is what I got from the input file:") print(ytids) answer = answer_me("Should I proceed?") if not answer: sys.exit(1) # Main loop for i in range(len(ytids)): ytid_from = ytids[i][0] video_url_from = 'https://www.youtube.com/watch?v='+ytid_from # GETTING THE SUBTITLES if opts.yt == True: ytdownload = 'youtube-dl --youtube-skip-dash-manifest --sub-lang '+lang+ \ ' --sub-format '+sub_format+' --write-sub '+ video_url_from if not opts.video: