[心得] 批次下載並取代檔名, plays.tv 結束營業

by Mesak

今天早上收到很震撼的消息 12/15 以後 plays.tv 要停止桌面應用軟體的運作,這消息令人惋惜,一個好服務要消失了,不過目前最重要的還是把已上傳的檔案給下載下來備份

首先需要知道網址才有辦法下載,討論區有個網頁可以連線到官方的網頁中:https://plays.tv/i/uploaded 不過麻煩的是沒有下載網址,每次下載都是同樣的檔名,這樣很難判別每個檔案的內容

想要批次下載的話,必須要取得網址,還好官方沒有搞一些串流播放,這樣下載稍微順暢了一點。

首先利用 Chrome  瀏覽器,連線到自己帳號的首頁,例如我的:https://plays.tv/u/Zalaka,一直捲動到最下方,讀取完畢按下 F12 快速鍵,在 Console 貼上下面這一段:

let rt = [];
$('.video-list-container .thumb-link').each(function(i,n){
    let $p = $(n).parents('.video-item:first');
    let item = $p.find('source').attr('src').replace('//','https://' ).replace('preview_144.mp4','720.mp4');
    let filename = $p.find('.hashtag').text() + ',' +$p.find('.info .title').text();
    	filename = filename.replace('\'','_').replace('#','');
	    item += '|' + filename + '.mp4';
	    rt.push(item);
});
console.log( rt.join('\n') )

接著會取得一串下載字串,全部 COPY 之後,存成 url.txt

下載首先要取得 wget ,在這個網站(https://eternallybored.org/misc/wget/) 下載了 wget 的 zip 檔案,解壓縮到一個資料夾內

接著把 url.txt 放進去

建立一個 bat 檔案

FOR /F "tokens=1,2 delims=|" %%i IN (url.txt) DO wget -c %%i -O "%%j"

儲存 get.bat ,接著執行 就可以開始備份檔案了。

English Version:

1. Open your plays.tv page, scroll to bottom, use chrome “F12” key, paste this code to get download list

let rt = [];
$('.video-list-container .thumb-link').each(function(i,n){
    let $p = $(n).parents('.video-item:first');
    let item = $p.find('source').attr('src').replace('//','https://' ).replace('preview_144.mp4','720.mp4');
    let filename = $p.find('.hashtag').text() + ',' +$p.find('.info .title').text();
    	filename = filename.replace('\'','_').replace('#','');
	    item += '|' + filename + '.mp4';
	    rt.push(item);
});
console.log( rt.join('\n') )

2. save list to url.txt

3. go to the following link to download “wget”, then extract the file to the folder you want to download the video (https://eternallybored.org/misc/wget)

4. create one batch file , save to get.bat

FOR /F "tokens=1,2 delims=|" %%i IN (url.txt) DO wget -c %%i -O "%%j"

5. run get.bat 

6. done

You may also like