zaps166 / QMPlay2

QMPlay2 is a video and audio player which can play most formats and codecs.
GNU Lesser General Public License v3.0
866 stars 179 forks source link

Add support of cookies arguments commands of yt-dlp "--cookies-from-browser firefox" to play restircted videos of twitter #756

Open trimechee opened 3 months ago

trimechee commented 3 months ago

Hello, yesterday i tried to play twitter videos because videos on twitter are very heavy and lag freeze even lowest quality in my old laptop, i tried with Qmplay2, smplayer, potplayer with 3DYD Youtube Source plugin, mpc hc, mpc be, qmplay2...all these players fails to pay twitter videos and have message that i should add cookies commands like --cookies-from-browser firefox....

i am not expert, i tired to add --cookies-from-browser firefox to the yt-dlp engines of these media players but no video playback :(

my idea please is that media player allows to support or add cookies yt-dlp commands arguments --cookies-from-browser firefox --cookies-from-browser chrome --cookies-from-browser r3dfox ........to video stream detected so we can avoid possible bugs and we could playback restirctid videos of twitter in vlc or potplayer or smplayer...thank you very much!

zaps166 commented 3 months ago

Hello, could you try this:

diff --git a/src/qmplay2/YouTubeDL.cpp b/src/qmplay2/YouTubeDL.cpp
index fd4a5d24..c64eb6d1 100644
--- a/src/qmplay2/YouTubeDL.cpp
+++ b/src/qmplay2/YouTubeDL.cpp
@@ -63,6 +63,7 @@ QStringList YouTubeDL::getCommonArgs()
     QStringList commonArgs {
         "--no-check-certificate", // Ignore SSL errors
         "--user-agent", Functions::getUserAgent(),
+        "--cookies-from-browser", "firefox",
     };

     const char *httpProxy = getenv("http_proxy");

?

trimechee commented 3 months ago

Sorry I didn't understand well, i.e. I click on ctrl+u and I put all that?

before doing that, I try with a link of a normal youtube video because I suceeded to watch bein sport live channel during the olympics games with QMPlay2 but I didn't try with a normal youtube video and it works !!!

Our so bloved QMPlay2 can playback youtube video in my windows 7 SP1 32 bits without the need of comand cookies-from-browser firefox chrome !!!! I don't know what changed, maybe new version of yt-dlp, also recently I uninstalled python (installed by elephant extension of FDM).....

I just proposed this idea of ​​being able to add this command cookies-from-browser firefox in case there would be a future playback problem in the future, in addition I recently read a thread that advises against adding this command cookies-from-browser firefox chrome because youtube will block the video so cookies-from-browser firefox seems to have the opposite effect !!

a user said this command cookies-from-browser firefox can work provided that we are not connected and if we are logged out of our youtube account......

but we still hope, in case youtube complicates things in the future, to be able to easily add custom command please, maybe that will solve some possible problems, for the moment I close my issue of the problem of youtube playback in windows 7 32 bits, and it's up to you to decide Mr Zaps166 if this issue of adding custom command argument should be closed or left open.....

from what I've read, youtube seems to censor only ip addresses that download or use youtube too much.....a trick I found is it seems when we use aria2c and yt-dlp together, and I even added the argument cookies-from-browser firefox, we can download youtube videos and bypass possible blocking, I have used this beautiful downloader which allows us to add custom argument command and allows to add aria2c extension and combine it with yt-dlp to prove this theory :

https://github.com/mhogomchungu/media-downloader

Thanks a lot !

RJVB commented 3 weeks ago

Hello, could you try this:

     "--user-agent", Functions::getUserAgent(),
  • "--cookies-from-browser", "firefox",

Hah, I was just going to suggest this because it actually works (provided you're logged in to YT in firefox I presume):

> yt-dlp  "https://www.youtube.com/watch?v=thx-HKhb-X8"
[youtube] Extracting URL: https://www.youtube.com/watch?v=thx-HKhb-X8
[youtube] thx-HKhb-X8: Downloading webpage
[youtube] thx-HKhb-X8: Downloading ios player API JSON
[youtube] thx-HKhb-X8: This video is age-restricted; some formats may be missing without authentication. Use --cookies-from-browser or --cookies for the authentication. See  https://github.com/yt-dlp/yt-dlp/wiki/FAQ#how-do-i-pass-cookies-to-yt-dlp  for how to manually pass cookies
[youtube] thx-HKhb-X8: Downloading tv embedded player API JSON
[youtube] thx-HKhb-X8: Downloading mweb player API JSON
ERROR: [youtube] thx-HKhb-X8: Sign in to confirm your age. This video may be inappropriate for some users.
Exit 1
> yt-dlp --cookies-from-browser firefox "https://www.youtube.com/watch?v=thx-HKhb-X8"
Extracting cookies from firefox
Extracted 1537 cookies from firefox
[youtube] Extracting URL: https://www.youtube.com/watch?v=thx-HKhb-X8
[youtube] thx-HKhb-X8: Downloading webpage
[youtube] thx-HKhb-X8: Downloading ios player API JSON
[youtube] thx-HKhb-X8: Downloading mweb player API JSON
[youtube] thx-HKhb-X8: Downloading player 76c7a082
[youtube] thx-HKhb-X8: Downloading m3u8 information
[info] thx-HKhb-X8: Downloading 1 format(s): 135+140
[download] Destination: Differences of Alternate, Scalpel and Sarod Picking [thx-HKhb-X8].f135.mp4
[download] 100% of   75.46MiB in 00:00:10 at 7.20MiB/s
[download] Destination: Differences of Alternate, Scalpel and Sarod Picking [thx-HKhb-X8].f140.m4a
[download] 100% of   13.31MiB in 00:00:04 at 3.14MiB/s
[Merger] Merging formats into "Differences of Alternate, Scalpel and Sarod Picking [thx-HKhb-X8].mp4"
Deleting original file Differences of Alternate, Scalpel and Sarod Picking [thx-HKhb-X8].f140.m4a (pass -k to keep)
Deleting original file Differences of Alternate, Scalpel and Sarod Picking [thx-HKhb-X8].f135.mp4 (pass -k to keep)

(very curious to have an age-limit on a video about guitar picking...)

trimechee commented 3 weeks ago

Try with these tools :

https://github.com/seproDev/yt-dlp-ChromeCookieUnlock

https://github.com/coletdjnz/yt-dlp-youtube-oauth2

https://github.com/coletdjnz/yt-dlp-get-pot

RJVB commented 3 weeks ago

On Tuesday October 29 2024 12:04:21 trimechee wrote:

Try with these tools :

Is the --cookies-from-browser option not enough?

QMPlay2 uses its own yt-dlp copy so installing a plugin is probably going to be (much) more work than just adding an argument to its invocation!

RJVB commented 3 weeks ago

FWIW, if the --cookies-from-browser option suffices there could be an additional simple choice in the Extensions/YouTube settings, e.g. a drop-down list with the known-supported browsers plus "none".

trimechee commented 3 weeks ago

Yes it seems good idea 👍 💯