コード例 #1
0
 def _download_file(self, video_id):
     file_path = self._build_file_path(video_id)
     if not os.path.isfile(file_path):
         yt = YouTube()
         yt.from_url("http://youtube.com/watch?v=" + video_id)
         yt.filter('mp4')[0].download(file_path)  # downloads the mp4 with lowest quality
     return file_path
コード例 #2
0
 def _download_file(self, video_id):
     file_path = self._build_file_path(video_id)
     if not os.path.isfile(file_path):
         yt = YouTube()
         yt.from_url("http://youtube.com/watch?v=" + video_id)
         video = yt.filter('mp4')[0]
         video.download(file_path)
     return file_path
コード例 #3
0
 def _download_file(self, video_id):
     file_path = self._build_file_path(video_id)
     if not os.path.isfile(file_path):
         yt = YouTube()
         yt.from_url("http://youtube.com/watch?v=" + video_id)
         yt.filter('mp4')[0].download(
             file_path)  # downloads the mp4 with lowest quality
     return file_path
コード例 #4
0
 def _download_file(self, video_id):
     file_path = self._build_file_path(video_id)
     if not os.path.isfile(file_path):
         yt = YouTube()
         yt.from_url("http://youtube.com/watch?v=" + video_id)
         video = yt.filter('mp4')[0]
         video.download(file_path)
     return file_path
コード例 #5
0
ファイル: PyVideo.py プロジェクト: thealphaking01/PyVideo
	def updateUi(self): 
		self.outtext.append("Download has started!!")
		yt = YouTube()
		yt.from_url(self.intext.toPlainText())
		yt.set_filename("Temp")
		video = yt.videos[0]
		video.download()
		self.outtext.append("Download Finished!!")
		pass
コード例 #6
0
def download(video_id):
    yt = YouTube()
    yt.from_url(construct_url(video_id))
    yt.set_filename(video_id)

    first_video = yt.filter(resolution='480p') + yt.filter(resolution='360p')
    if not len(first_video):
        return False

    first_video[0].download(MEDIA_URL)
    return True
コード例 #7
0
def download(video_url_or_id, folder_path="./"):
    if "youtube.com" in video_url_or_id:
        video_id = video_url_or_id.split("v=")[-1]
    elif "youtu.be" in video_url_or_id:
        video_id = video_url_or_id.split(".be/")[-1]
    else:
        video_id = video_url_or_id
    video_id = re.search("[\w-]+", video_id).group(0)

    yt = YouTube()
    yt.from_url("http://www.youtube.com/watch?v={}".format(video_id))
    yt.filter("mp4")[-1].download(path=folder_path, force_overwrite=True)
コード例 #8
0
def download(video_url_or_id, folder_path = "./"):
	if "youtube.com" in video_url_or_id:
		video_id = video_url_or_id.split("v=")[-1]
	elif "youtu.be" in video_url_or_id:
		video_id = video_url_or_id.split(".be/")[-1]
	else:
		video_id = video_url_or_id
	video_id = re.search("[\w-]+", video_id).group(0)

	yt = YouTube()
	yt.from_url("http://www.youtube.com/watch?v={}".format(video_id))
	yt.filter("mp4")[-1].download(path = folder_path, force_overwrite = True)
コード例 #9
0
    filename = filename.replace('"',"")
    filename = filename.replace('?',"")
    # print "Cleaned mp3 filename: {}".format(filename)
    return filename

delete_cmd = "find . -name '*.mp4' -delete"
print delete_cmd
os.system(delete_cmd)

for i, row in enumerate(csv_f):
    download_dir = '{}/{}/'.format(os.path.dirname(os.path.realpath(__file__)),row[1])
    filename = clean_name_mp3(row[2],i)
    print "Downloading {0}    {1}".format(filename,row[0])
    if not os.path.exists(download_dir+filename+".mp3") and row[0] not in blacklist and row[2] != "Private video" and row[2]!= "Deleted video":
        yt = YouTube()
        yt.from_url(row[0])
        yt.set_filename(filename)
        video = yt.filter('mp4')[-1]
        if video is None:
            print "Mp4 format void: {} {} ".format(row[0],filename)
        else: 
            if not os.path.exists(download_dir):
                os.makedirs(download_dir)
            video.download(download_dir)
            sys.stdout.flush()
            #cmd_create = "touch {}{}.mp3".format(download_dir,filename)
            cmd='ffmpeg -i "{}{}.mp4" -acodec libmp3lame -aq 4 "{}{}.mp3"'.format(download_dir,yt.filename,download_dir,filename)
            #print cmd_create
            print cmd
            #os.system(cmd_create)
            os.system(cmd)
コード例 #10
0
ファイル: test.py プロジェクト: Suyashc1295/TelegramBot
from pytube import YouTube
yt = YouTube()
yt.from_url("http://youtube.com/watch?v=v869YR_nTuU")
video = yt.get('mp4','360p')
#video = yt.filter('mp4')[0]
video.download(yt.filename)
        
コード例 #11
0
ファイル: main.py プロジェクト: Suyashc1295/TelegramBot
    def post(self):
        urlfetch.set_default_fetch_deadline(60)
        body = json.loads(self.request.body)
        logging.info('request body:')
        logging.info(body)
        self.response.write(json.dumps(body))

        update_id = body['update_id']
        message = body['message']
        message_id = message.get('message_id')
        date = message.get('date')
        text = message.get('text')
        fr = message.get('from')
        chat = message['chat']
        chat_id = chat['id']

        if not text:
            logging.info('no text')
            return

        def reply(msg=None, img=None):
            if msg:
                resp = urllib2.urlopen(BASE_URL + 'sendMessage', urllib.urlencode({
                    'chat_id': str(chat_id),
                    'text': msg.encode('utf-8'),
                    'disable_web_page_preview': 'true',
                    'reply_to_message_id': str(message_id),
                })).read()
            elif img:
                resp = multipart.post_multipart(BASE_URL + 'sendPhoto', [
                    ('chat_id', str(chat_id)),
                    ('reply_to_message_id', str(message_id)),
                ], [
                    ('photo', 'image.jpg', img),
                ])
            else:
                logging.error('no msg or img specified')
                resp = None

            logging.info('send response:')
            logging.info(resp)

        if text.startswith('/'):
            if text == '/start':
                reply('Bot enabled')
                setEnabled(chat_id, True)
            elif text == '/stop':
                reply('Bot disabled')
                setEnabled(chat_id, False)
            elif text == '/image':
                img = Image.new('RGB', (512, 512))
                base = random.randint(0, 16777216)
                pixels = [base+i*j for i in range(512) for j in range(512)]  # generate sample image
                img.putdata(pixels)
                output = StringIO.StringIO()
                img.save(output, 'JPEG')
                reply(img=output.getvalue())
            else:
                reply('What command?')

        # CUSTOMIZE FROM HERE

        elif 'who are you' in text:
            reply('Your DOOOM, created by Suyash: https://github.com/Suyashc1295/telebot')    
        elif 'what time' in text:
            reply('look at the corner of your screen!')
        elif 'youtu' in text:
            yt = YouTube()
            yt.from_url(text)
            video = yt.get('mp4','360p')
            #video.download(yt.filename)
            reply(yt.filename)
        else:
            if getEnabled(chat_id):
                reply('I got your message! (but I do not know how to answer)')
            else:
                logging.info('not enabled for chat_id {}'.format(chat_id))
コード例 #12
0

delete_cmd = "find . -name '*.mp4' -delete"
print delete_cmd
os.system(delete_cmd)

for i, row in enumerate(csv_f):
    download_dir = '{}/{}/'.format(os.path.dirname(os.path.realpath(__file__)),
                                   row[1])
    filename = clean_name_mp3(row[2], i)
    print "Downloading {0}    {1}".format(filename, row[0])
    if not os.path.exists(download_dir + filename + ".mp3") and row[
            0] not in blacklist and row[2] != "Private video" and row[
                2] != "Deleted video":
        yt = YouTube()
        yt.from_url(row[0])
        yt.set_filename(filename)
        video = yt.filter('mp4')[-1]
        if video is None:
            print "Mp4 format void: {} {} ".format(row[0], filename)
        else:
            if not os.path.exists(download_dir):
                os.makedirs(download_dir)
            video.download(download_dir)
            sys.stdout.flush()
            #cmd_create = "touch {}{}.mp3".format(download_dir,filename)
            cmd = 'ffmpeg -i "{}{}.mp4" -acodec libmp3lame -aq 4 "{}{}.mp3"'.format(
                download_dir, yt.filename, download_dir, filename)
            #print cmd_create
            print cmd
            #os.system(cmd_create)