Giter Site home page Giter Site logo

Comments (8)

norkunas avatar norkunas commented on May 30, 2024

Hello @projektile, i've just tested and everything works fine for me.

test.php:

<?php

$yt = new \YoutubeDl\YoutubeDl();
$yt->setBinPath('C:/bin/youtube-dl');
$yt->setDownloadPath('D:/');

$video = $yt->download('https://www.youtube.com/watch?v=C1Tcfn2ZEgg');
var_dump($video->getFile());

Output:

php -f test.php

object(SplFileInfo)#6 (2) {
  ["pathName":"SplFileInfo":private]=>
  string(65) "D:/Eric Saade - Masquerade [Official Music Video]-C1Tcfn2ZEgg.mp4"
  ["fileName":"SplFileInfo":private]=>
  string(62) "Eric Saade - Masquerade [Official Music Video]-C1Tcfn2ZEgg.mp4"
}

Could you provide your code how you use it?

from youtube-dl-php.

norkunas avatar norkunas commented on May 30, 2024

Maybe your process working dir somehow changes when downloading ❓ and if that's the case I can introduce another option and transfer the file manually with php.

from youtube-dl-php.

projektile avatar projektile commented on May 30, 2024

hey norkunas,

this is a cut from my index.php which invokes your api:

if(isset($_POST['name'])) {
$object = $_POST['name'];

    $dl = new YoutubeDl([
        'continue' => true, // force resume of partially downloaded files. By default, youtube-dl will resume downloads if possible.
        'format' => 'bestaudio',
        'extract-audio' => true,
    ]);

    $dl->setDownloadPath('/home/projektile/Music');

    try {
        $video = $dl->download('https://www.youtube.com/watch?v='.$object);
        echo $video->getTitle(); // Will return Phonebloks
    // $dl->getFile(); // \SplFileInfo instance of downloaded file
    } catch (NotFoundException $e) {
    // Video not found
    } catch (PrivateVideoException $e) {
    // Video is private
    } catch (CopyrightException $e) {
    // The YouTube account associated with this video has been terminated due to multiple third-party notifications of copyright infringement
    } catch (\Exception $e) {
    // Failed to download
    }

}

from youtube-dl-php.

norkunas avatar norkunas commented on May 30, 2024

@projektile thanks, can you print the output of $dl->getFile() ?

from youtube-dl-php.

projektile avatar projektile commented on May 30, 2024

Sorry for my late response, It's been a busy last few days.
the only way ive been able to print the output of $dl->getFile() gives me:

SplFileInfo Object
(
[pathName:SplFileInfo:private] => /home/projektile/Music
[fileName:SplFileInfo:private] => Music
)

i can redirect it to /tmp/ instead of my music directory and it will work, which seems odd because this doesn't seem to be a permission issue either.

from youtube-dl-php.

norkunas avatar norkunas commented on May 30, 2024

@projektile so when you got this output SplFileInfo Object ( [pathName:SplFileInfo:private] => /home/projektile/Music [fileName:SplFileInfo:private] => Music ) the file was downloaded to the primary directory where the script was executed?
Also in what environment are you running?

from youtube-dl-php.

projektile avatar projektile commented on May 30, 2024

Yes, the file was saved to /usr/share/nginx/html/ with that spl info. the only two directories I've managed to save the file into is either /usr/share/nginx/html/, or /tmp/. for my purposes /tmp/ will work but I'm still curious why I'm having this problem.
my environment is:
Linux 4.1.15
nginx 1.8.0
PHP 7.0.2

from youtube-dl-php.

norkunas avatar norkunas commented on May 30, 2024

@projektile i made a temporary ugly update, could you try now to pull dev-master version and set $dl->setMoveWithPhp(true); and check if it works?

from youtube-dl-php.

Related Issues (20)

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.