Giter Club home page Giter Club logo

youtube-dl's Introduction

YouTube-dl

系統:Centos 6.8
必要軟體:YouTube-dl . ffmpeg . Apache . php . python

Step1: 安裝 Python

YouTube-dl需要Python2.6,2.7,3.2+
yum install python -y

Step2: 安裝必要軟體

2-1 Youtube-dl

到這邊YouTube-dl 下載YouTube-dl
sudo wget https://yt-dl.org/downloads/latest/youtube-dl -O /usr/bin/youtube-dl
sudo chmod a+rx /usr/bin/youtube-dl
測試YouTube-dl是否正常運作
youtube-dl
正常會回傳
Usage: youtube-dl [OPTIONS] URL [URL...]

youtube-dl: error: You must provide at least one URL.
Type youtube-dl --help to see a list of all options.

2-2 ffmpeg

從本專案中下載ffmpeg安裝腳本ffmpeg
sudo wget https://raw.githubusercontent.com/Kutinging/YouTube-dl/master/ffmpeg/latest-ffmpeg-centos6.sh
sudo chmod +x latest-ffmpeg-centos6.sh sudo ./latest-ffmpeg-centos6.sh   安裝完後到安裝的目錄底下查看bin資料夾
裡面包含ffmpeg,ffprobe等等檔案
將所有檔案複製到/bin/
cp ffmpeg ffprobe ffserver lame vsyasm x264 yasm ytasm /bin/

2-3 Apache,php

yum install httpd php -y
建議在安裝一個 Apache mod : ITK Multi-Processing Module
詳細安裝步驟不在此說明,需要安裝請到此查看如何安裝
Apache 透過 ITK Multi-Processing Module 讓虛擬主機以不同使用者執行

Step3: 網頁執行

網頁執行須要使用到php中的 shell_exec
主要語法有:
1.檢查網址:
判斷網址是否為youtube.com 或 youtu.be 並取得影片的ID
$kbps = $_GET['kbps'];   $url = $_GET['url']; if(strrpos($url,"youtube")){ $id = explode("=",$url); } else if(strrpos($url,"youtu.be")){ $id = explode("youtu.be/",$url); } else{

}

2.執行下載轉檔,詳細參數請參考Youtube-dl官方說明
if($url!=null && (strrpos($url,"youtube")||strrpos($url,"youtu.be"))){
shell_exec("youtube-dl --max-filesize 20M --extract-audio --audio-format mp3 --audio-quality $kbps -o'mp3/%(id)s.%(ext)s' $url");
}
else{
echo "Error url";
}

3.使用者下載(Javascript)

seconds = 6;

function check(a,b){
if(seconds <= 0 ){
document.getElementById(b).innerHTML="開始下載 <meta http-equiv="refresh" content="10;url=./" />";
location.href="./mp3/downloadfiles.php?file=";
}
else{
seconds--;
document.getElementById(b).innerHTML="正在取得連結
"+ seconds+"秒";
setTimeout(function(){check(a,b)}, 1000);
}
}

window.onload=function(){
check(seconds, 'countbox1');
};

youtube-dl's People

Contributors

thanatosdi avatar

Watchers

James Cloos avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.