在線視頻爬蟲與百度云盤同步服務(wù)及其服務(wù)器架設(shè)(一)

在線視頻爬蟲下載工具youtube_dl安裝及其使用

利用python管理工具pip安裝

pip install --upgrade youtube-dl

youtube_dl常用命令行介紹

-f, --format FORMAT              Video format code, see the "FORMAT
                                 SELECTION" for all the info

--merge-output-format FORMAT     If a merge is required (e.g.
                                 bestvideo+bestaudio), output to given
                                 container format. One of mkv, mp4, ogg,
                                 webm, flv. Ignored if no merge is required

-F, --list-formats               List all available formats of requested
                                 videos

-a, --batch-file FILE            File containing URLs to download ('-' for
                                 stdin)

-o, --output TEMPLATE            Output filename template, see the "OUTPUT
                                 TEMPLATE" for all the info    

--list-extractors                List all supported extractors

輸出文件名模板

Note: on Windows you may need to use double quotes instead of single.

# Download YouTube playlist videos in separate directory indexed by video order in a playlist
$ youtube-dl -o '%(playlist)s/%(playlist_index)s - %(title)s.%(ext)s' https://www.youtube.com/playlist?list=PLwiyx1dc3P2JR9N8gQaQN_BCvlSlap7re

# Download all playlists of YouTube channel/user keeping each playlist in separate directory:
$ youtube-dl -o '%(uploader)s/%(playlist)s/%(playlist_index)s - %(title)s.%(ext)s' https://www.youtube.com/user/TheLinuxFoundation/playlists

# Download Udemy course keeping each chapter in separate directory under MyVideos directory in your home
$ youtube-dl -u user -p password -o '~/MyVideos/%(playlist)s/%(chapter_number)s - %(chapter)s/%(title)s.%(ext)s' https://www.udemy.com/java-tutorial/

# Download entire series season keeping each series and each season in separate directory under C:/MyVideos
$ youtube-dl -o "C:/MyVideos/%(series)s/%(season_number)s - %(season)s/%(episode_number)s - %(episode)s.%(ext)s" http://videomore.ru/kino_v_detalayah/5_sezon/367617

輸出文件格式模板

網(wǎng)站上視頻具有的下載格式可以通過youtube-dl -F查看可下載視頻格式列表

youtube-dl可以根據(jù)參數(shù)配置來確定視頻下載格式

Note: on Windows you may need to use double quotes instead of single.

# Download best mp4 format available or any other best if no mp4 available
$ youtube-dl -f 'bestvideo[ext=mp4]+bestaudio[ext=m4a]/best[ext=mp4]/best'

# Download best format available but not better that 480p
$ youtube-dl -f 'bestvideo[height<=480]+bestaudio/best[height<=480]'

# Download best video only format but no bigger than 50 MB
$ youtube-dl -f 'best[filesize<50M]'

# Download best format available via direct link over HTTP/HTTPS protocol
$ youtube-dl -f '(bestvideo+bestaudio/best)[protocol^=http]'

# Download the best video format and the best audio format without merging them
$ youtube-dl -f 'bestvideo,bestaudio' -o '%(title)s.f%(format_id)s.%(ext)s'

開發(fā)者模式使用

youtube_dl在python代碼中使用方式

from __future__ import unicode_literals ## for python2
import youtube_dl

ydl_opts = {}
with youtube_dl.YoutubeDL(ydl_opts) as ydl:
    ydl.download(['http://www.youtube.com/watch?v=BaW_jenozKc'])

ydl_opts 配置可以在YoutubeDL.py中找到,for example

            ydl_opts = {
                ##Download best format available but not better that 720p
                'format': 'bestvideo[height<=720]+worstaudio[ext=m4a]/best[height<=720][ext=mp4]',
                'merge_output_format': 'mp4',
                'outtmpl': './download/%(title)s.%(ext)s',
                #     # 'postprocessors': [{
                #     #    'key': 'FFmpegExtractAudio',
                #     #    'preferredcodec': 'mp3',
                #     #    'preferredquality': '192',
                #     # }],
                #     # 'logger': MyLogger(),
                #     #'progress_hooks': [my_hook],
            }

百度云盤同步工具bypy安裝及其使用

  • github地址 : bypy

利用pip安裝bypy

  • 通過pip安裝pip install bypy

bypy對百度云盤授權(quán)

第一次使用需要對百度云進行授權(quán),運行任意命令即可進入百度云盤授權(quán)過程,通過給出url得到百度云盤的授權(quán)碼.

如果需要重置授權(quán),運行bypy -c即可進入重置授權(quán)

bypy命令行使用

顯示在云盤(程序的)根目錄下文件列表:bypy list

把當(dāng)前目錄同步到云盤:bypy syncup or bypy upload

把云盤內(nèi)容同步到本地來:bypy syncdown or bypy downdir /

比較本地當(dāng)前目錄和云盤(程序的)根目錄:bypy compare

bypy代碼運行
在python代碼中運行bypy

import bypy
        by = bypy.ByPy()
            by.syncup(fromdir,todir)
最后編輯于
?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請聯(lián)系作者
  • 序言:七十年代末赌莺,一起剝皮案震驚了整個濱河市,隨后出現(xiàn)的幾起案子唆樊,更是在濱河造成了極大的恐慌提揍,老刑警劉巖芽卿,帶你破解...
    沈念sama閱讀 218,607評論 6 507
  • 序言:濱河連續(xù)發(fā)生了三起死亡事件,死亡現(xiàn)場離奇詭異,居然都是意外死亡什往,警方通過查閱死者的電腦和手機软能,發(fā)現(xiàn)死者居然都...
    沈念sama閱讀 93,239評論 3 395
  • 文/潘曉璐 我一進店門迎捺,熙熙樓的掌柜王于貴愁眉苦臉地迎上來,“玉大人查排,你說我怎么就攤上這事凳枝。” “怎么了?”我有些...
    開封第一講書人閱讀 164,960評論 0 355
  • 文/不壞的土叔 我叫張陵岖瑰,是天一觀的道長叛买。 經(jīng)常有香客問我,道長蹋订,這世上最難降的妖魔是什么率挣? 我笑而不...
    開封第一講書人閱讀 58,750評論 1 294
  • 正文 為了忘掉前任,我火速辦了婚禮露戒,結(jié)果婚禮上椒功,老公的妹妹穿的比我還像新娘。我一直安慰自己智什,他們只是感情好动漾,可當(dāng)我...
    茶點故事閱讀 67,764評論 6 392
  • 文/花漫 我一把揭開白布。 她就那樣靜靜地躺著荠锭,像睡著了一般旱眯。 火紅的嫁衣襯著肌膚如雪。 梳的紋絲不亂的頭發(fā)上证九,一...
    開封第一講書人閱讀 51,604評論 1 305
  • 那天删豺,我揣著相機與錄音,去河邊找鬼甫贯。 笑死吼鳞,一個胖子當(dāng)著我的面吹牛,可吹牛的內(nèi)容都是我干的叫搁。 我是一名探鬼主播赔桌,決...
    沈念sama閱讀 40,347評論 3 418
  • 文/蒼蘭香墨 我猛地睜開眼,長吁一口氣:“原來是場噩夢啊……” “哼渴逻!你這毒婦竟也來了疾党?” 一聲冷哼從身側(cè)響起,我...
    開封第一講書人閱讀 39,253評論 0 276
  • 序言:老撾萬榮一對情侶失蹤惨奕,失蹤者是張志新(化名)和其女友劉穎雪位,沒想到半個月后,有當(dāng)?shù)厝嗽跇淞掷锇l(fā)現(xiàn)了一具尸體梨撞,經(jīng)...
    沈念sama閱讀 45,702評論 1 315
  • 正文 獨居荒郊野嶺守林人離奇死亡雹洗,尸身上長有42處帶血的膿包…… 初始之章·張勛 以下內(nèi)容為張勛視角 年9月15日...
    茶點故事閱讀 37,893評論 3 336
  • 正文 我和宋清朗相戀三年,在試婚紗的時候發(fā)現(xiàn)自己被綠了卧波。 大學(xué)時的朋友給我發(fā)了我未婚夫和他白月光在一起吃飯的照片时肿。...
    茶點故事閱讀 40,015評論 1 348
  • 序言:一個原本活蹦亂跳的男人離奇死亡,死狀恐怖港粱,靈堂內(nèi)的尸體忽然破棺而出螃成,到底是詐尸還是另有隱情旦签,我是刑警寧澤,帶...
    沈念sama閱讀 35,734評論 5 346
  • 正文 年R本政府宣布寸宏,位于F島的核電站宁炫,受9級特大地震影響,放射性物質(zhì)發(fā)生泄漏氮凝。R本人自食惡果不足惜羔巢,卻給世界環(huán)境...
    茶點故事閱讀 41,352評論 3 330
  • 文/蒙蒙 一、第九天 我趴在偏房一處隱蔽的房頂上張望罩阵。 院中可真熱鬧朵纷,春花似錦、人聲如沸永脓。這莊子的主人今日做“春日...
    開封第一講書人閱讀 31,934評論 0 22
  • 文/蒼蘭香墨 我抬頭看了看天上的太陽常摧。三九已至,卻和暖如春威创,著一層夾襖步出監(jiān)牢的瞬間落午,已是汗流浹背。 一陣腳步聲響...
    開封第一講書人閱讀 33,052評論 1 270
  • 我被黑心中介騙來泰國打工肚豺, 沒想到剛下飛機就差點兒被人妖公主榨干…… 1. 我叫王不留溃斋,地道東北人。 一個月前我還...
    沈念sama閱讀 48,216評論 3 371
  • 正文 我出身青樓吸申,卻偏偏與公主長得像梗劫,于是被迫代替她去往敵國和親。 傳聞我的和親對象是個殘疾皇子截碴,可洞房花燭夜當(dāng)晚...
    茶點故事閱讀 44,969評論 2 355

推薦閱讀更多精彩內(nèi)容