Skip to content
This repository has been archived by the owner on May 7, 2020. It is now read-only.

Youtube-dl integration #196

Open
wants to merge 27 commits into
base: develop
Choose a base branch
from
Open

Conversation

nparkanyi
Copy link

This enables streaming Youtube videos with youtube-dl by giving a Youtube URL in the Open File dialogue or on the command line. Supports individual videos and playlists. Requires youtube-dl to be present in PATH variable.

@vBm
Copy link
Contributor

vBm commented Oct 2, 2017

I've noticed that you didn't include checker for 'short' links provided by youtube.
eg. https://youtu.be/L3dtIyt6U1E

On the other hand, i can't properly test it being that i'm always getting "Calling youtube-dl" -> "Opening..." -> "Failed to render the file".

2017-10-02_12-23-56

Note that i'm not a coder so i can't comment on code quality and reviewing it.

@kasper93
Copy link
Contributor

kasper93 commented Oct 2, 2017

This needs proper integration of youtube-dl. Usage of API they provide instead of parsing stdout. Support for all sites they support, youtube is very small subset of what they capable of. Quality selection dialog, this can be done later, but often "best"stream is not the best. Generally we need to have integration that can be extended in the future, current design would be hard to maintain.

@nparkanyi
Copy link
Author

@vBm That video works for me. Try running "youtube-dl -g -f best https://youtu.be/L3dtIyt6U1E" on command line and open the https stream it gives you in mpc-hc. If that works, I'm guessing it's a string encoding issue.

@kasper93 Is it worth dragging python as a runtime dependency to use the API? It might make most sense to do what mpv does, which is use the -J option and parse the JSON output, that would still be pretty flexible.

@vBm
Copy link
Contributor

vBm commented Oct 4, 2017

@nparkanyi yes, using decoded, direct url does work.

@nparkanyi
Copy link
Author

@vBm Do all youtube videos fail? In any case, the current approach will never work since when printing Unicode to stdout, it seems Windows garbles it in a locale-dependent way before piping it.

@nparkanyi
Copy link
Author

Here's an implementation which reads the JSON output from youtube-dl with rapidjson (very similar to how mpv does it). This also now works with non-youtube sites. It passes any http url through youtube-dl, and if youtube-dl is unavailable or fails, it falls back on the built-in behaviour to open the url directly.
@vBm Can you see if you can still reproduce the issue on the new commit?

@vBm
Copy link
Contributor

vBm commented Nov 5, 2017

@nparkanyi I can't even compile it.

MainFrm.obj : error LNK2001: unresolved external symbol "public: __cdecl CYoutubeDLInstance::CYoutubeDLInstance(void)" (??0CYoutubeDLInstance@@QEAA@XZ) [C:\projects\mpc-hc\src\mpc-hc\mpc-hc.vcxproj]
MainFrm.obj : error LNK2001: unresolved external symbol "public: __cdecl CYoutubeDLInstance::~CYoutubeDLInstance(void)" (??1CYoutubeDLInstance@@QEAA@XZ) [C:\projects\mpc-hc\src\mpc-hc\mpc-hc.vcxproj]
MainFrm.obj : error LNK2001: unresolved external symbol "public: bool __cdecl CYoutubeDLInstance::Run(class ATL::CStringT<wchar_t,class StrTraitMFC<wchar_t,class ATL::ChTraitsCRT<wchar_t> > >)" (?Run@CYoutubeDLInstance@@QEAA_NV?$CStringT@_WV?$StrTraitMFC@_WV?$ChTraitsCRT@_W@ATL@@@@@ATL@@@Z) [C:\projects\mpc-hc\src\mpc-hc\mpc-hc.vcxproj]
MainFrm.obj : error LNK2001: unresolved external symbol "public: bool __cdecl CYoutubeDLInstance::GetHttpStreams(class ATL::CAtlList<class ATL::CStringT<wchar_t,class StrTraitMFC<wchar_t,class ATL::ChTraitsCRT<wchar_t> > >,class ATL::CElementTraits<class ATL::CStringT<wchar_t,class StrTraitMFC<wchar_t,class ATL::ChTraitsCRT<wchar_t> > > > > &,class ATL::CAtlList<class ATL::CStringT<wchar_t,class StrTraitMFC<wchar_t,class ATL::ChTraitsCRT<wchar_t> > >,class ATL::CElementTraits<class ATL::CStringT<wchar_t,class StrTraitMFC<wchar_t,class ATL::ChTraitsCRT<wchar_t> > > > > &,class ATL::CAtlList<class ATL::CStringT<wchar_t,class StrTraitMFC<wchar_t,class ATL::ChTraitsCRT<wchar_t> > >,class ATL::CElementTraits<class ATL::CStringT<wchar_t,class StrTraitMFC<wchar_t,class ATL::ChTraitsCRT<wchar_t> > > > > &)" (?GetHttpStreams@CYoutubeDLInstance@@QEAA_NAEAV?$CAtlList@V?$CStringT@_WV?$StrTraitMFC@_WV?$ChTraitsCRT@_W@ATL@@@@@ATL@@V?$CElementTraits@V?$CStringT@_WV?$StrTraitMFC@_WV?$ChTraitsCRT@_W@ATL@@@@@ATL@@@2@@ATL@@00@Z) [C:\projects\mpc-hc\src\mpc-hc\mpc-hc.vcxproj]
C:\projects\mpc-hc\bin\mpc-hc_x64\mpc-hc64.exe : fatal error LNK1120: 4 unresolved externals [C:\projects\mpc-hc\src\mpc-hc\mpc-hc.vcxproj]

Please provide test builds, both x86 and x64.

@nparkanyi
Copy link
Author

@vBm oops, that's not surprising, I forgot to commit the updated project file.

@vBm
Copy link
Contributor

vBm commented Nov 6, 2017

@nparkanyi Yes, it works lovely now.
Tested with various quality links and several providers among other even twitch live stream.

@Skibicki
Copy link

Skibicki commented Nov 7, 2017

Can it play drag & dropped links? If it can, that would make better than the other DirectShow based options.

@nparkanyi
Copy link
Author

@Skibicki It does now.

@chros73
Copy link

chros73 commented Jan 21, 2018

Hi @nparkanyi ! First of all, thank you for your hard work!

Maybe you also know that - unfortunately - this project development became dead.
The good news is that @clsid2 cloned this project, also released a new unofficial version , and he's also willing to accept pull requests.
I understand that this can be a bit pain in the xxx, but can you create a pull request there? By knowing him, I'm pretty sure that it won't take long to deal with it.
Thanks!

@clsid2
Copy link
Contributor

clsid2 commented Jan 25, 2018

Does this also support high resolution (4k) videos? YouTube uses separate audio and video files for such streams.

@nparkanyi
Copy link
Author

I haven't tested an 4K videos, but YouTube also uses separate audio and video streams for 1080p content, which are handled here.

@clsid2
Copy link
Contributor

clsid2 commented Jan 27, 2018

Good. I think it would be useful to have some options to control which streams are selected. For example to restrict resolution to max 1080p. And an option to only load the audio stream, for people who only want to use it for music. These could be added as boolean values in Options > Advanced.

Can you also test if Add to Favorites works? It might be needed to store the original URL there?

@nparkanyi
Copy link
Author

Yes I plan to implement setting maximum quality. Audio stream should work too, though afaik only Youtube actually separates audio and video streams (vidme did too, RIP). I'll look into Add to Favorites.

@iG8R
Copy link

iG8R commented Aug 13, 2018

I'm sorry for my not quite smart question but where could it be possible to download already compiled mpc-hc64.exe with integrated youtube-dl support?

@Adyel
Copy link

Adyel commented Aug 14, 2018

@iG8R You need to compile it from the source. Link

@iG8R
Copy link

iG8R commented Aug 14, 2018

@Adyel Thank you for the answer. It would be more convenient for ordinary users to download already compiled files. Author and other pro users somehow check their commits by compiling MPC_HC with youtube-dl integration into and running executable files - maybe they wouldn't reject to release this files?

@b7398564
Copy link

Can anyone build it following the https://trac.mpc-hc.org/wiki/How_to_compile_the_MPC

Part D: Building the installer

Download ​Inno Setup Unicode v5.5.9 or newer.
Install everything and then go to C:\mpc-hc\distrib, open mpc-hc_setup.iss with Inno Setup, read the first comments in the script and compile it.

Notes:

    build.bat can build the installer by using the installer or the packages switch.
    Use Inno Setup's built-in IDE if you want to edit the iss file. 

@nparkanyi
Copy link
Author

https://drive.google.com/open?id=1HQl6vmaA5T7FQJnZ7Xd52yzE78xf79vE

@Pentaphon
Copy link

So what happened to this? Seems it was passed over for another solution.

@Jellykuf
Copy link

@Pentaphon The youtube-dl integration and further MPC-HC maintenance can be found at https://github.com/clsid2/mpc-hc

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet