Exemple #1
0
    def get_cc(self, lang="en"):
        # sets self.title
        #      self.srt_file
        #      self.vocap_file
        # and downloads self.srt_file

        if not isinstance(self.vid, unicode):
            self.vid = unicode(self.vid, 'utf-8')

        ######### Get subtitles and title
        cc = getyoutubecc.getyoutubecc(self.vid,lang)
        if not cc:
           return 0

        print cc.name
        self.title = cc.name

        self.srt_file = self.dir_name+u'/'+self.vid+u'.srt'
        if not isinstance(self.srt_file, unicode):
            self.srt_file = unicode(self.srt_file, 'utf-8')

        self.title_file = self.dir_name+u'/'+self.vid+u'.title'
        if not isinstance(self.title_file, unicode):
            self.title_file = unicode(self.title_file, 'utf-8')

        self.vocap_file = self.dir_name+u'/'+self.vid+u'.vocap'
        if not isinstance(self.vocap_file, unicode):
            self.vocap_file = unicode(self.vocap_file, 'utf-8')

        print "saving the file: "+self.srt_file
        cc.writeSrtFile(self.path+"/"+self.srt_file)

        fileobj=codecs.open(self.path+"/"+self.title_file, "w", "utf-8")
        fileobj.write(self.title)
        fileobj.close()
Exemple #2
0
def get_single_url(url, youtube_object=YouTube()):
    #    try:
    youtube_object.url = url
    video = youtube_object.get('mp4', '720p')
    filename = youtube_object.filename
    video.download()
    cc = getyoutubecc.getyoutubecc(youtube_object.video_id, 'en')
    cc_filename = filename + '.srt'
    cc.writeSrtFile(cc_filename)
    return {'filename': filename, 'cc_filename': cc_filename}
def get_single_url(url, youtube_object=YouTube()):
#    try:
    youtube_object.url = url
    video = youtube_object.get('mp4', '720p')
    filename = youtube_object.filename
    video.download()
    cc = getyoutubecc.getyoutubecc(youtube_object.video_id,'en')
    cc_filename = filename + '.srt'
    cc.writeSrtFile(cc_filename)
    return {'filename' : filename,
            'cc_filename': cc_filename}
Exemple #4
0
def search_all_files(search_url, youtube_object=YouTube()):
    search_url = search_url
    urls = get_urls(search_url)
    yt = youtube_object
    for url in urls:
        try:
            print "downloading " + url
            yt.url = url
            video = yt.get('mp4', '720p')
            filename = yt.filename
            video.download()
            time.sleep(.1)
            cc = getyoutubecc.getyoutubecc(yt.video_id, 'en')
            cc.writeSrtFile(filename + '.srt')
            time.sleep(.1)
        except:
            print "couldn't download " + url
def search_all_files(search_url, youtube_object=YouTube()):
    search_url = search_url 
    urls = get_urls(search_url)
    yt = youtube_object
    for url in urls:
        try:
            print "downloading " + url
            yt.url = url
            video = yt.get('mp4', '720p')
            filename = yt.filename
            video.download()
            time.sleep(.1)
            cc = getyoutubecc.getyoutubecc(yt.video_id,'en')
            cc.writeSrtFile(filename + '.srt')
            time.sleep(.1)
        except:
            print "couldn't download " + url
from pytube import YouTube
import getyoutubecc
from bs4 import BeautifulSoup

def get_urls(url):
    data = urllib.urlopen(url).read()
    soup = BeautifulSoup(data)
    soupy_links = soup.select('a.yt-uix-sessionlink')
    urls = ['http://youtube.com' + link.get('href') for link in soupy_links if 'watch' in link.get('href')]
    return set(urls)


search_url = sys.argv[1]
urls = get_urls(search_url)
yt = YouTube()
for url in urls:
    try:
        print "downloading " + url
        yt.url = url
        video = yt.get('mp4', '720p')
        filename = yt.filename
        video.download()
        time.sleep(.1)
        cc = getyoutubecc.getyoutubecc(yt.video_id,'en')
        cc.writeSrtFile(filename + '.srt')
        time.sleep(.1)
    except:
        print "couldn't download " + url

Exemple #7
0
from bs4 import BeautifulSoup


def get_urls(url):
    data = urllib.urlopen(url).read()
    soup = BeautifulSoup(data)
    soupy_links = soup.select('a.yt-uix-sessionlink')
    urls = [
        'http://youtube.com' + link.get('href') for link in soupy_links
        if 'watch' in link.get('href')
    ]
    return set(urls)


search_url = sys.argv[1]
urls = get_urls(search_url)
yt = YouTube()
for url in urls:
    try:
        print "downloading " + url
        yt.url = url
        video = yt.get('mp4', '720p')
        filename = yt.filename
        video.download()
        time.sleep(.1)
        cc = getyoutubecc.getyoutubecc(yt.video_id, 'en')
        cc.writeSrtFile(filename + '.srt')
        time.sleep(.1)
    except:
        print "couldn't download " + url
Exemple #8
0
def home(request):
    cc = getyoutubecc.getyoutubecc(u"T8X15QkS-N8")
    return render_to_response("home/home.html", {"name": cc.name})