当前位置: 首页>>代码示例>>Python>>正文


Python YouTube.from_url方法代码示例

本文整理汇总了Python中pytube.YouTube.from_url方法的典型用法代码示例。如果您正苦于以下问题:Python YouTube.from_url方法的具体用法?Python YouTube.from_url怎么用?Python YouTube.from_url使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在pytube.YouTube的用法示例。


在下文中一共展示了YouTube.from_url方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: _download_file

# 需要导入模块: from pytube import YouTube [as 别名]
# 或者: from pytube.YouTube import from_url [as 别名]
 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
开发者ID:bolshoibooze,项目名称:whatsappcli,代码行数:9,代码来源:media_downloader.py

示例2: _download_file

# 需要导入模块: from pytube import YouTube [as 别名]
# 或者: from pytube.YouTube import from_url [as 别名]
 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
开发者ID:relima,项目名称:whatsapp-bot-seed,代码行数:10,代码来源:media_sender.py

示例3: updateUi

# 需要导入模块: from pytube import YouTube [as 别名]
# 或者: from pytube.YouTube import from_url [as 别名]
	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
开发者ID:thealphaking01,项目名称:PyVideo,代码行数:11,代码来源:PyVideo.py

示例4: download

# 需要导入模块: from pytube import YouTube [as 别名]
# 或者: from pytube.YouTube import from_url [as 别名]
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
开发者ID:CasaBuddies,项目名称:AntiReplay,代码行数:13,代码来源:video_service.py

示例5: download

# 需要导入模块: from pytube import YouTube [as 别名]
# 或者: from pytube.YouTube import from_url [as 别名]
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)
开发者ID:joeylmaalouf,项目名称:media-api-packages,代码行数:14,代码来源:youtube.py

示例6: enumerate

# 需要导入模块: from pytube import YouTube [as 别名]
# 或者: from pytube.YouTube import from_url [as 别名]
    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)
开发者ID:Artperkitny,项目名称:Youtube-Video-Mp3-Converter,代码行数:33,代码来源:download.py

示例7: YouTube

# 需要导入模块: from pytube import YouTube [as 别名]
# 或者: from pytube.YouTube import from_url [as 别名]
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)
        
开发者ID:Suyashc1295,项目名称:TelegramBot,代码行数:8,代码来源:test.py

示例8: post

# 需要导入模块: from pytube import YouTube [as 别名]
# 或者: from pytube.YouTube import from_url [as 别名]
    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))
开发者ID:Suyashc1295,项目名称:TelegramBot,代码行数:79,代码来源:main.py


注:本文中的pytube.YouTube.from_url方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。