標籤

bat (52) 作品 (38) python (21) shell (17) windows (11) 虛擬機 (11) php (10) CPP (6) KMS (6) 程式設計 (6) docker (5) 使用教學 (5) xoops (4) 公文 (4) Apache2 (3) Excel (3) juniper (3) 資料庫 (3) mysql (2) 免動手 (2) 資料結構 (2) 軟體廣播 (2) 電腦維修 (2) Android Studio (1) Apple IPAD管理 (1) Arduino (1) CSS (1) LAMP (1) NAS (1) Ubuntu (1) VHD (1) Windows Server (1) 原因 (1) 程式應用 (1) 程式積木 (1) 編輯器 (1) 雲端硬碟 (1)

2022年11月26日 星期六

只要點兩下,就能離開位子。讓電腦依照規劃自動下載臉書的影片

下載檔案解壓密碼:demo1234
使用步驟教學:

        最近同事問我,可不可以下載FaceBook的影片作為教學影片?於是就開始嘗試去寫程式來完成這件事。 
        更由於先前的程式可以依照規劃與公開的PlayList來下載YouTube多媒體,網友提供了Youtube-dl 這個套件可以下載FB的影片。後來找Google大神,發現Youtube-dl功能很強大。原始網站https://github.com/ytdl-org/youtube-dl 提供了命令列功能與支援的網站https://github.com/ytdl-org/youtube-dl/blob/master/docs/supportedsites.md。但是我卻想要用Python程式來試試。可是問題來了,我該怎麼在Python用Youtube-dl這個套件?於是找大神,關鍵字是python youtube-dl example,沒想到找到資料來源1.Python youtube_dl.YoutubeDL() Examples。那我就開始測試,第一個測試程式如下:
程式目的:測試Youtube-dl是否能下載FB多媒體
程式名稱:test.py
程式內容:
import youtube_dl

ydl_opts = {}
with youtube_dl.YoutubeDL(ydl_opts) as ydl:
    ydl.download(['https://fb.watch/h21zao5IVE/'])
結果:
        很開心,發現可以下載FB多媒體。
        那要如何取得FB多媒體的網址呢?
        以FireFox為例,如下所示:


程式目的:下載FB多媒體
程式名稱:FbMp4Download.py
程式內容:
import youtube_dl
import os
from ClassFunc import OpenFiles

fcl = OpenFiles('下載名單.txt','').FileContentList()
ydl_opts = {
    'noplaylist': True
}
for i in fcl:
    with youtube_dl.YoutubeDL(ydl_opts) as ydl:
        ydl.download([i])

程式目的:常用程式類別
程式名稱:ClassFunc.py
程式內容:
import os

class OpenFiles():
    #開啟檔案

    def __init__(self,FileName,FolderName):
        self.FileName = FileName
        self.FolderName = FolderName
   
    def FileContentList(self):
        #設定信件內容檔名並取得檔案內容並回傳List
        ContentFileName = str(os.path.abspath(os.getcwd()))+"\\"+self.FileName
        ContentFile = open(ContentFileName,'r')
        FileContentList = ContentFile.readlines()
        ContentFile.close()
        return FileContentList
   
    def GetFolderPath(self):
        #取得資料夾路徑
        if os.path.exists(self.FolderName):
            FolderPath = str(os.path.abspath(os.getcwd()))+"\\"+self.FolderName
        else:
            os.mkdir(self.FolderName)
            FolderPath = str(os.path.abspath(os.getcwd()))+"\\"+self.FolderName
        return FolderPath



資料來源:




沒有留言:

張貼留言

只要點兩下,傳統右鍵選單改回Win11右鍵選單

系列文章: 1. 只要點兩下,就能將Win11 右鍵選單 回復 傳統右鍵選單 2. 只要點兩下,傳統右鍵選單改回Win11右鍵選單 上一篇提到只要點兩下,就能將Win11選單回到傳統選單。但是有沒有方法能夠回到Win11選單呢?                    ...