for line in f:
        l = line.split()
        if len(l) > 0 and l[0][0] != "#":
            ytids.append(l[0])


TEMP_FOLDER = 'subs'
if not os.path.isdir(TEMP_FOLDER):
    try:
        os.mkdir(TEMP_FOLDER)
    except:
        print("Could not create temp directory %s" % (TEMP_FOLDER))
        raise

AMARA_USERNAME = '******'
amara = Amara(AMARA_USERNAME)
youtube = ytapi.get_authenticated_service(opts)

uploaded = 0
# Main loop
for i in range(len(ytids)):
    video_present = False
    lang_present  = False
    lang_visible  = False
    amara_id = ''
    ytid = ytids[i]

    video_url = 'https://www.youtube.com/watch?v=%s' % ytid

    print("Syncing YTID %s" % ytid)
Exemple #2
0
if opts.yt == False and opts.files == False and opts.amara == False:
    print('Please, set either "-f", "-y" or "-a".')
    print('Type "-h" for help')
    sys.exit(1)

# List ytids may also contain filenames
ytids = []
# Reading file with YT id's
with open(infile, "r") as f:
    for line in f:
        l = line.split()
        if len(l) > 0 and l[0][0] != "#":
            ytids.append(line.split())

amara = Amara()

try:
    os.remove('youtubedl.out')
    os.remove('youtubedl.err')
except:
    pass

if len(ytids) < 20:  # Do not print for large inputs
    print("This is what I got from the input file:")
    print(ytids)

# Main loop
for i in range(len(ytids)):
    ytid_from = ytids[i][0]
opts = read_cmd()
lang = opts.lang
amara_team = "khan-academy"
if opts.amara_public:
    amara_team = None

# List ytids may also contain filenames
ytids = []
# Reading file with YT id's
with open(opts.input_file, "r") as f:
    for line in f:
        ytids.append(line.split())

AMARA_USERNAME = '******'
amara = Amara(AMARA_USERNAME)

if opts.header:
    print_header()

# Main loop
for i in range(len(ytids)):
    if len(ytids[i]) == 0:
        print("")
        continue
    ytid = ytids[i][0]

    sys.stdout.flush()
    sys.stderr.flush()

    video_url = 'https://www.youtube.com/watch?v=%s' % ytid
                    subs_incomplete = True
            break
    return subs_published, subs_incomplete

opts = read_cmd()
AMARA_TEAM = 'khan-academy'

# List ytids may also contain filenames
ytids = []
# Reading file with YT id's
with open(opts.input_file, "r") as f:
    for line in f:
        ytids.append(line.split())

AMARA_USERNAME = '******'
amara = Amara(AMARA_USERNAME)

# Main loop
for i in range(len(ytids)):
    if len(ytids[i]) == 0:
        print("")
        continue
    ytid = ytids[i][0]

    # Trying to reduce E 429
    if opts.sleep_int > 0:
        sleep(opts.sleep_int)

    sys.stdout.flush()
    sys.stderr.flush()
Exemple #5
0
    for line in f:
        l = line.split(' ')
        if l[0][0] != "#":
            ytids.append(line.split())

if not os.path.isdir(opts.dirname):
    os.mkdir(opts.dirname)

try:
    os.remove("youtubedl.out")
    os.remove("youtubedl.err")
except:
    pass

if opts.amara:
    amara = Amara()

# Main loop
for i in range(len(ytids)):

    ytid = ytids[i][0]
    video_url = 'https://www.youtube.com/watch?v=%s' % ytid
    amara_id = ''

    if opts.video:
        video_download_cmd = "youtube-dl %s" % video_url
        p = Popen(video_download_cmd, shell=True, stdout=PIPE, stderr=PIPE)
        out, err = p.communicate()
        with open("youtubedl.out", 'a') as f:
            f.write(out.decode('UTF-8'))
        if err:
# Skip certain videos
ytid_skip = set()
fname_skip = "sync_yt2amara_skip.%s.dat" % opts.lang
try:
    with open(fname_skip, "r") as f:
        for l in f:
            ytid_skip.add(l.split()[0])
    print("Current number of skipped videos on Amara:", len(ytid_skip))
except FileNotFoundError as e:
    pass

uploaded = 0
missing = 0

amara = Amara()

# Main loop
for i in range(len(ytids)):
    video_present = False
    lang_present = False
    lang_visible = False
    if len(ytids[i]) == 0 or ytids[i][0][0] == "#":
        print("")
        continue
    ytid = ytids[i][0]
    video_url = "https://www.youtube.com/watch?v=%s" % ytid

    #   PART 1: Checking the existence of subtitles on Amara
    if ytid in ytid_skip:
        continue
PUBLISH_SUBTITLES = opts.publish
# When downloading from YT, do a publish automatically,
# since they are already published there.
# Though, maybe if people want to keep editing them, it would be better to
# leave them unpublished? Maybe.
if opts.yt_download:
    PUBLISH_SUBTITLES = True

# List ytids may also contain filenames
ytids = []
# Reading file with YT id's
with open(opts.input_file, "r") as f:
    for line in f:
        ytids.append(line.split())

amara = Amara(AMARA_SUBTITLER)
amara_review = Amara(AMARA_REVIEWER)


def check_upload_success(response, sub_version_old):
    sub_version_new = response['version_number']
    if sub_version_new != sub_version_old + 1:
        eprint("ERROR: Something went wrong during subtitle upload")
        eprint(r)
        sys.exit(1)


def compare_work_status(work_status, expected_work_status):
    if work_status != expected_work_status:
        eprint("ERROR: Unexpected work status!")
        eprint("Expected: %s Got: %s" % (expected_work_status, work_status))
Exemple #8
0
   return parser.parse_args()


opts = read_cmd()
lang = opts.lang
AMARA_USERNAME = '******'
AMARA_TEAM = "khan-academy"

# List ytids may also contain filenames
ytids = []
# Reading file with YT id's
with open(opts.input_file, "r") as f:
    for line in f:
        ytids.append(line.split())

amara = Amara(AMARA_USERNAME)

# Main loop
for i in range(len(ytids)):
    if len(ytids[i]) == 0:
        print("")
        continue
    ytid = ytids[i][0]

    sys.stdout.flush()
    sys.stderr.flush()

    video_url = 'https://www.youtube.com/watch?v=%s' % ytid

    # Check whether the video is already on Amara
    amara_response = amara.check_video(video_url, AMARA_TEAM)