Code Monkey home page Code Monkey logo

php-yt_downloader's Introduction

yt_downloader - PHP class to download videos from YouTube and/or convert them to mp3 audio files.

Introduction

This PHP class takes a YouTube URL (or YouTube Video-ID) and downloads the video to your computer. Optionally, you can convert any YouTube video to an MP3 Audio file (requires ffmpeg to be installed!).

UI Demo

For an example integration, try the demo:
http://eyecatchup.github.com/php-yt_downloader/index.html?vid=http://www.youtube.com/watch?v=cMMpLEGlFWE

Download

The latest stable version can be downloaded from the downloads tab, or using the following link:
https://github.com/downloads/eyecatchup/php-yt_downloader/eyecatchup-php-yt_downloader-403c053.zip

The UI demo code is available here: https://github.com/eyecatchup/php-yt_downloader/tree/gh-pages

Basic Usage

Usage is pretty straight forward:

<?php
    require('youtube-dl.class.php');
    try {
        // Instantly download a YouTube video (using the default settings).
        new yt_downloader('http://www.youtube.com/watch?v=aahOEZKTCzU', TRUE);

        // Instantly download a YouTube video as MP3 (using the default settings).
        new yt_downloader('http://www.youtube.com/watch?v=aahOEZKTCzU', TRUE, 'audio');
    }
    catch (Exception $e) {
        die($e->getMessage());
    }

You can provide either a YouTube URL (as used in the example), or a Youtube Video-ID. The class will check whether the given input value is a YouTube URL, or a YouTube Video-ID . If it's a URL, the ID will be extracted automatically. So,

new yt_downloader("http://www.youtube.com/watch?v=aahOEZKTCzU"); is identical to new yt_downloader("https://www.youtube.com/watch?feature=related&v=aahOEZKTCzU"); is identical to new yt_downloader("aahOEZKTCzU");.

For more (advanced) examples see the example-*.php files.

Configuration

Use the youtube-dl.config.php file to set your download preferences.

URL: https://github.com/eyecatchup/php-yt_downloader/
License: http://eyecatchup.mit-license.org/
(c) 2012, Stephan Schmitz [email protected]

php-yt_downloader's People

Contributors

eyecatchup avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

php-yt_downloader's Issues

Grabbing original file location(s) failed.

Seems that this issue is back.

"Grabbing original file location(s) failed."

I just installed this for the first time on my vps (Centos 5.9) and that is all i get. I also see that 10 months ago this issue was fixed once so it must have came back again recently. If you need any more info on this issue let me know

VEVO problem, right ?

I have this error :
"This video contains content from VEVO. It is restricted from playback on certain sites".

Anyone ?

Does not download files

I have installed ffmpeg, php5, php5-curl from repo on Debian 6 but still it does not work. It downloads the image-thumbnail just fine but the video is always size 0. Please fix

hi anyway to use this with clipbucket script ?

hi I am using clipbucket for q video website, it has option to sujjest a embed video by adding the youtube link ( url) if video and it embeds the video into database, users can also upload videos and ffmpeg will convert the video and add it to database.

my question is how can I utilize this script - so when a user adds a youtube video - instead of embedding it into my database it will use this script to upload a .mp4 to the database

is anyone able to make this ? or familiar with clipbucket.com script

hope this is not to much to ask

Spiro

gh-pages branch missing

Note: You can find the source code of this demo in the gh-pages branch ??

Where is the gh-pages branch files ?

Thanks

source fixx?

hi,

i see on the download source the message ->
Since we cannot run PHP code here, the download functionality is disabled for this demo version.

Note: You can find the source code of this demo in the gh-pages branch.

Can you help me to remove the message and convert with your script - i have downloadet the version but i see only this shit :(

No documentation

Ive got no clue how to use this crapware...
Reading code is not helpful either.

public function download_video($c=NULL)
{
    $c = ($c !== NULL) ? $c : 0;

FUCK YOU!!!!

Installed ffmpeg but, "You must have Ffmpeg installed in order to use this function."

Hi,

I'm having an issue using "example-audio-2.php" from the examples. I have installed 'ffmpeg' on my Linux/CentOS server.

When I type 'ffmpeg -version' in SSH it returns with the version

Also when I type 'which ffmpeg' it returns with the path "/usr/local/bin/ffmpeg/"

But for some reason I'm getting the error shown in the title when trying to use the example files.

Is there something else I must do? Is this in the correct path?

Thanks

" ↵Grabbing original file location(s) failed. "

Object {readyState: 4, responseText: "
↵Grabbing original file location(s) failed. ", status: 200, statusText: "OK"}

I keep getting this error, not sure why sometimes and other times just doing the request repeatedly solves it.

Don't save file on server

Any way to just offer a download link to the user instead of saving the video on my server first? Seems like an unnecessary step, plus can get pretty bandwidth-heavy.
This is a great script! just think this suggestion will make it better :)

help me plz

hi,

i see on the download source the message ->
Since we cannot run PHP code here, the download functionality is disabled for this demo version.

Note: You can find the source code of this demo in the gh-pages branch.

Can you help me to remove the message and convert with your script - i have downloadet the version but i see only this shit :(

Also Exception due to variable "videos"

Hey, I also get an error: "Notice: Undefined variable: videos in var/www/youtube_graph/youtube-dl.class.php on line 534
Grabbing original file location(s) failed."

Can you tell whats wrong there?

How to get this working?

I downloaded this after crawling the web for hours and it seems all other solutions you need to pay for so maybe its too good to be true. 9 times out of 10 i get the same error as Adzster where videos is undefined. And the one time it does seem to work i get... "Something went wrong while converting the video into mp3 format, sorry!" and it manages to download the thumbnail but no video file. I would really love to get this working do you have any tips how to make it work?

Upgrading the library, need help.

Hello, i'm updating the script but i encountered some problems.

First of all, I got some code from a more updated repository (I watched in the "network" section of github).

This is the final class: https://gist.github.com/LuigiElleBalotta/d5f30cbed74e808d67ad44d3f9506d31

The problem is that the video is without the audio. Example: LINK

This is a problem for ffmpeg that outputs "Output file #0 does not contain any stream".

This is the json response from youtube: LINK

Any help?

exit your life

<?php

        $id = self::get_video_id();
        if($id === FALSE) {
            throw new Exception("Missing video id. Use set_youtube() and try again.");
            exit();
        }

no_idea_what_im_doing

Empty video file

Hi,

I'm trying the script, but the generated video file is empty (instead the thumb is right).
SSD_vs_HDD_Performance_Comparison_-240p-youtubeid-j84eEjP-RL4.jpg -> 16751 bytes
SSD_vs_HDD_Performance_Comparison
-240p-_youtubeid-j84eEjP-RL4.3gp -> 0 bytes

I also tried the HQ parameter, also getting an empty mp4 file.

I'm echoing the URL, is this:

http://r11---sn-a5m7ln7s.c.youtube.com/videoplayback?sparams=algorithm%2Cburst%2Ccp%2Cfactor%2Cid%2Cip%2Cipbits%2Citag%2Csource%2Cupn%2Cexpire&newshard=yes&id=8fce1e1233fe44be&key=yt1&algorithm=throttle-factor&burst=40&source=youtube&sver=3&itag=17&ipbits=8&expire=1357850795&cp=U0hUTFhQTl9OT0NONF9QSlJIOjltV0RZNEdqY0pw&upn=co9o_SBi5sw&ip=67.220.200.154&ms=au&fexp=907720%2C901809%2C930100%2C916626%2C901459%2C920704%2C912806%2C922403%2C922405%2C929901%2C913605%2C929104%2C929110%2C908493%2C920201%2C913302%2C930101%2C919009%2C911116%2C926403%2C910221%2C901451&mt=1357828754&mv=m&factor=1.25

Can you please confirm if the youtube URL has changed, or just my installation is failing?

Thanks & Regards!

Cannot Install

Hello There,

On installing, I am getting the following error:

Warning: require(/home/mp3globe/public_html/../bootstrap/autoload.php): failed to open stream: No such file or directory in /home/mp3globe/public_html/index.php on line 21

Fatal error: require(): Failed opening required '/home/mp3globe/public_html/../bootstrap/autoload.php' (include_path='.:/usr/lib/php:/usr/local/lib/php') in /home/mp3globe/public_html/index.php on line 21

UI Help

I need some help with the UI. Whenever I enter the URL and click "Audio" or "Video", I get this message:

"Since we cannot run PHP code here, the download functionality is disabled for this demo version.

Note: You can find the source code of this demo in the gh-pages branch”

I downloaded both of the files (UI and the PHP thing) and put them in the same folder on my website file manager.

Grabbing original file location(s) failed

I'm facing the Problem that I always getting the Error
Grabbing original file location(s) failed .

It seems that the youtube-dl.class.php file cant finde the videos direction to store the Video and Images.

I also found out some strange behavior:

It seems that this error get caused by this line in the php file:
self::set_downloads_dir(cnfg::Download_Folder);

I think that "Download_Folder" isnt set in the cnfg.
So I added this line of code in the first line of the PHP File:
const Download_Folder = APPATH.'./videos/';

So after that, the PHP File always works 1 TIME. ONLY 1.
After the first time it downloads the Video, but then after that it throws the error again and again.

It could be that this dont have to do anything with the error, but I wanted to mention that.
So does someone know how to fix this Error on Apache Server in 2017?

Cheers

EDIT:

It seems that this fixes the issue at least:
Change this lines of Code in the class.php file:

          if(preg_match('/itag=([0-9]+)&url=(.*?)&.*?/si',$url,$um))
                {
                    $u = urldecode($um[2]);

                    $tmp[$um[1]] = $u;
                }

with this lines of code:

            if(preg_match('/url=(.*?)&.*?itag=([0-9]+)/si',$url,$um))
                {
                  $u = urldecode($um[1]);
                  $tmp[$um[2]] = $u;
                }
                else if (preg_match('/itag=([0-9]+)&.*url=(.*)/si',$url, $um))
                {
                  $u = urldecode($um[2]);
                  $tmp[$um[1]] = $u;
                }

Undefined Variable: 'videos'

I've got ffmpeg, curl, etc, installed however when I go to use the example scripts I get the issue of:

'Notice: Undefined variable: videos in /var/www/yt/examples/youtube-dl.class.php on line 534 Grabbing original file location(s) failed.'

Any help would be appreciated

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.