示例#1
0
import logging
from list_videos import walk_videos
import periscope
import sys

#Avoid logging of info in periscope

subtitle_downloader = periscope.Periscope("CACHE")

for to_periscope in walk_videos(sys.argv[1], exclude_having_subtitles = True):
	try:
		result = subtitle_downloader.downloadSubtitle(to_periscope, langs = ['es'])
		if result is not None:
			print "downloaded for " + to_periscope
	except Exception as e:
		print "Error " + str(e)
示例#2
0
import periscope
import sys

# Avoid logging of info in periscope
logging.basicConfig(level="error")

subtitle_downloader = periscope.Periscope("CACHE")

pending_torrents_dir_file = open(sys.argv[1], "r+")


def walk_nonempty_dirs(f):
    for l in f.read().splitlines():
        yield l.strip()


missing_subtitles_dirs = set()

for dir_to_walk in walk_nonempty_dirs(pending_torrents_dir_file):
    for to_periscope in walk_videos(dir_to_walk, exclude_having_subtitles=True):
        subtitle = subtitle_downloader.downloadSubtitle(to_periscope, langs=["es"])
        if subtitle is None:
            missing_subtitles_dirs.add(dir_to_walk)
        else:
            print "Downloaded for " + to_periscope + ": " + str(subtitle)

pending_torrents_dir_file.seek(0)
pending_torrents_dir_file.write("\n".join(missing_subtitles_dirs))
pending_torrents_dir_file.truncate()
pending_torrents_dir_file.close()