trizen / pipe-viewer

A lightweight YouTube client for Linux, without requiring an API key.
Artistic License 2.0
381 stars 18 forks source link

Bind pipe-viewer to the initial desktop? #154

Open TheChymera opened 1 year ago

TheChymera commented 1 year ago

So if I start playing a series of videos, once a video finishes and a new one starts, I get am mpv window popping up in whatever desctop is focused. Can I make it just use whatever desktop it was started on, i.e. start subsequent mpv windows in place of the original one?

sun95n commented 1 year ago

To get mpv to start in a workspace check the geometry option. And to use the same window and not create another check the umpv script.

TheChymera commented 1 year ago

@sun95n thanks for the suggestion, I tried setting the following in my pipe-viewer config file:

...
  video_player_selected         => "umpv",
  video_players                 => {
                                     umpv => {
                                              arg => "--really-quiet --force-media-title=*TITLE* --no-ytdl *VIDEO*",
                                              audio => "--audio-file=*AUDIO*",
                                              cmd => "/usr/bin/umpv",
                                              fs => "--fullscreen",
                                              novideo => "--no-video",
                                              srt => "--sub-file=*SUB*",
                                            },
...

But now the mpv window does not play any sound. This is weird since both umpv and mpv play fine when pointed to a downloaded video on my local storage.

I also checked and the player is unmuted and the volume is set to a decent level, so it didn't just inherit parameters from some past instance (not that I think it should).

sun95n commented 1 year ago

Yes that's because umpv is a python script (not a player). So you don't need to modify video_player_selected and video_players section just cmd.

TheChymera commented 1 year ago

@sun95n still no sound:

  video_player_selected         => "mpv",
  video_players                 => {
                                     mpv => {
                                              arg => "--really-quiet --force-media-title=*TITLE* --no-ytdl *VIDEO*",
                                              audio => "--audio-file=*AUDIO*",
                                              cmd => "umpv",
                                              fs => "--fullscreen",
                                              novideo => "--no-video",
                                              srt => "--sub-file=*SUB*",
                                            },

The umpv description within the script seems to indicate that it does not take command line arguments, maybe that's confusing it somehow? also tried to delete all the arguments from the video_players section, and no improvement. How did you get it to work?

sun95n commented 1 year ago

Hi. Maybe you are forgetting something. These are my settings:

video_player_selected       => "mpv",
video_players               => {
                                   mpv => {
                                            arg   => "--really-quiet --force-media-title=*TITLE* --no-terminal *URL*",
                                            audio => "--audio-file=*AUDIO*",
                                            cmd   => "/usr/local/bin/umpv",
                                            fs    => "--fullscreen",
                                            srt   => "--sub-file=*SUB*",
                                          },
sun95n commented 1 year ago

UPDATE: You need to pass the URL to mpv if you don't want to have problems with the *TITLE* string (I opened a new thread to deal with this problem). Please check my options again I modified arg to achieve what you want.

TheChymera commented 1 year ago

@sun95n with your settings it just won't play past the first video. (=mpv-0.35.0 and =pipe-viewer-0.4.4)

Output from pipe-viewer:

-> Command: /usr/bin/umpv --audio-file=https\:\/\/rr1\-\-\-sn\-bvvbax\-cvne\.googlevideo\.com\/videoplayback\?expire\=1672738696\&ei\=KKOzY_DBGIHHhwaR76WIDg\&ip\=2601\%3A18c\%3A4300\%3A6e21\%3A3de5\%3A1826\%3Aef82\%3A67f1\&id\=o\-AHS_xZT25wR4SN415hFz3Y01R4TVSUfPFQ7\-o7DRtbvS\&itag\=251\&source\=youtube\&requiressl\=yes\&mh\=du\&mm\=31\%2C29\&mn\=sn\-bvvbax\-cvne\%2Csn\-ab5l6nrr\&ms\=au\%2Crdu\&mv\=m\&mvi\=1\&pl\=34\&initcwndbps\=1833750\&vprv\=1\&mime\=audio\%2Fwebm\&gir\=yes\&clen\=5492980\&dur\=356\.021\&lmt\=1647354005213211\&mt\=1672716824\&fvip\=5\&keepalive\=yes\&fexp\=24001373\%2C24007246\&c\=ANDROID\&txp\=4532434\&sparams\=expire\%2Cei\%2Cip\%2Cid\%2Citag\%2Csource\%2Crequiressl\%2Cvprv\%2Cmime\%2Cgir\%2Cclen\%2Cdur\%2Clmt\&sig\=AOq0QJ8wRQIhANX6hbUTtgUHVMLtrzsHvOW3ERYQEJ\-sAcU4D83I4GFDAiBfsAmPHaqeFh_dFOA23cceY35dmJkB8sT\-Z_pPxpjJDQ\%3D\%3D\&lsparams\=mh\%2Cmm\%2Cmn\%2Cms\%2Cmv\%2Cmvi\%2Cpl\%2Cinitcwndbps\&lsig\=AG3C_xAwRgIhAOCPzSUe8QkpmUuNU3fVt_0OkpDRnbcFxEqaK3Nk7jNlAiEA54fORiOYYLk4d4DfX_wwdEDSj_GLJ\-ZimvcI59rHTQY\%3D --sub-file=\/home\/chymera\/\.cache\/pipe\-viewer\/uHKfrz65KSU_en\.srt --really-quiet --force-media-title=Baby\ Cats\ \-\ Cute\ and\ Funny\ Cat\ Videos\ Compilation\ \#8\ \|\ Aww\ Animals --no-terminal https\:\/\/www\.youtube\.com\/watch\?v\=uHKfrz65KSU
Traceback (most recent call last):
  File "/usr/bin/umpv", line 86, in <module>
    subprocess.check_call(opts)
  File "/usr/lib/python3.10/subprocess.py", line 369, in check_call
    raise CalledProcessError(retcode, cmd)
subprocess.CalledProcessError: Command '['mpv', '--no-terminal', '--force-window', '--input-ipc-server=/home/chymera/.umpv_socket', '--', '/home/chymera/--audio-file=https:/rr1---sn-bvvbax-cvne.googlevideo.com/videoplayback?expire=1672738696&ei=KKOzY_DBGIHHhwaR76WIDg&ip=2601%3A18c%3A4300%3A6e21%3A3de5%3A1826%3Aef82%3A67f1&id=o-AHS_xZT25wR4SN415hFz3Y01R4TVSUfPFQ7-o7DRtbvS&itag=251&source=youtube&requiressl=yes&mh=du&mm=31%2C29&mn=sn-bvvbax-cvne%2Csn-ab5l6nrr&ms=au%2Crdu&mv=m&mvi=1&pl=34&initcwndbps=1833750&vprv=1&mime=audio%2Fwebm&gir=yes&clen=5492980&dur=356.021&lmt=1647354005213211&mt=1672716824&fvip=5&keepalive=yes&fexp=24001373%2C24007246&c=ANDROID&txp=4532434&sparams=expire%2Cei%2Cip%2Cid%2Citag%2Csource%2Crequiressl%2Cvprv%2Cmime%2Cgir%2Cclen%2Cdur%2Clmt&sig=AOq0QJ8wRQIhANX6hbUTtgUHVMLtrzsHvOW3ERYQEJ-sAcU4D83I4GFDAiBfsAmPHaqeFh_dFOA23cceY35dmJkB8sT-Z_pPxpjJDQ%3D%3D&lsparams=mh%2Cmm%2Cmn%2Cms%2Cmv%2Cmvi%2Cpl%2Cinitcwndbps&lsig=AG3C_xAwRgIhAOCPzSUe8QkpmUuNU3fVt_0OkpDRnbcFxEqaK3Nk7jNlAiEA54fORiOYYLk4d4DfX_wwdEDSj_GLJ-ZimvcI59rHTQY%3D', '/home/chymera/--sub-file=/home/chymera/.cache/pipe-viewer/uHKfrz65KSU_en.srt', '/home/chymera/--really-quiet', '/home/chymera/--force-media-title=Baby Cats - Cute and Funny Cat Videos Compilation #8 | Aww Animals', '/home/chymera/--no-terminal', 'https://www.youtube.com/watch?v=uHKfrz65KSU']' returned non-zero exit status 3.

diff between my old config and the changes you proposed:

100,101c100,101
<   video_player_selected         => "mpv",
<   video_players                 => {
---
>   video_player_selected       => "mpv",
>   video_players               => {
103c103
<                                               arg => "--force-media-title=*TITLE* --no-ytdl *VIDEO*",
---
>                                               arg   => "--really-quiet --force-media-title=*TITLE* --no-terminal *URL*",
105,109c105,108
<                                               cmd => "mpv",
<                                               fs => "--fullscreen",
<                                               novideo => "--no-video",
<                                               srt => "--sub-file=*SUB*",
<                                             },
---
>                                               cmd   => "/usr/bin/umpv",
>                                               fs    => "--fullscreen",
>                                               srt   => "--sub-file=*SUB*",
>                                           },
sun95n commented 1 year ago

Your output points to umpv failing to recognize the arg and audio keys. Try the following:

video_player_selected       => "mpv",
video_players               => {
                                   mpv => {
                                            arg   => "*URL*",
                                            audio => "",
                                            cmd   => "/usr/bin/umpv",
                                            fs    => "--fullscreen",
                                            srt   => "--sub-file=*SUB*",
                                          },

If it fails again check that it is not a problem with umpv script or mpv otherwise this will not work in your case although for me the previous configuration and this one did.

TheChymera commented 1 year ago

It plays, but the window does not remain in place, and after the video is over re-spawns in the focused desktop and not in place of the original window, here's the output from pipe-viewer --debug:

--------------------------------------------------------------------------------------------------------------------------------------------
                                              =>> Happy Doggos To Make Your Day Better 🐶🥰 <<=

-> Channel   : Fluppy
-> ChannelID : UCIDvgzmxcpil52HZifHHGZQ
-> VideoID   : xYABBedOkwk
-> Category  : Pets & Animals
-> Duration  : 10:37
-> Likes     : 9,357
-> Rating    : 69%
-> Views     : 550,455
-> Published : 1 year ago
--------------------------------------------------------------------------------------------------------------------------------------------
-> Resolution: 480
-> Video itag: 244
-> Audio itag: 251
-> Video type: video/webm
-> Audio type: audio/webm
-> Command: /usr/bin/umpv  https\:\/\/www\.youtube\.com\/watch\?v\=xYABBedOkwk
** POST https://youtubei.googleapis.com/youtubei/v1/player?key=AIzaSyAO_FJ2SlqU8Q4STEHLGCilw_Y9_11qcW8 ==> 200 OK (1s)
:: Using `player_response` to extract the streaming URLs...
:: Found 19 streaming URLs...
:: Extracting video info using the fallback method...
** GET https://m.youtube.com/watch?hl=en&v=40RVG_ij-cY ==> 200 OK

=> Description
--------------------------------------------------------------------------------------------------------------------------------------------
...
--------------------------------------------------------------------------------------------------------------------------------------------
=> URL: https://www.youtube.com/watch?v=40RVG_ij-cY
--------------------------------------------------------------------------------------------------------------------------------------------
                                                =>> Cute Funny Doggos | Funny Pet Videos <<=

-> Channel   : Funny Pet Videos
-> ChannelID : UCYK1TyKyMxyDQU8c6zF8ltg
-> VideoID   : 40RVG_ij-cY
-> Duration  : 10:39
-> Likes     : 974
-> Rating    : 61%
-> Views     : 79,857
-> Published : Mar 27, 2020
--------------------------------------------------------------------------------------------------------------------------------------------
-> Resolution: 480
-> Video itag: 244
-> Audio itag: 251
-> Video type: video/webm; codecs="vp9"
-> Audio type: audio/webm; codecs="opus"
-> Command: /usr/bin/umpv  https\:\/\/www\.youtube\.com\/watch\?v\=40RVG_ij\-cY
** POST https://youtubei.googleapis.com/youtubei/v1/player?key=AIzaSyAO_FJ2SlqU8Q4STEHLGCilw_Y9_11qcW8 ==> 200 OK
:: Using `player_response` to extract the streaming URLs...
:: Found 25 streaming URLs...
:: Extracting video info using the fallback method...
** GET https://m.youtube.com/watch?hl=en&v=0DPZ9b9ZZr4 ==> 200 OK (1s)

=> Description
--------------------------------------------------------------------------------------------------------------------------------------------
...
sun95n commented 1 year ago

I assume you mean mpv (video window) right?

Then review the options that deal with this behavior: screen geometry autofit

Although if you mean the window generated by the GTK version of pipe-viewer then you should consider it a bug and report it. I can't deal with it because I don't work as a developer of this project. Sorry.

ehula commented 1 day ago

mpv has the ability to play a playlist. It would be great if pipe-viewer would use this functionality. This way, I could select a number of videos to play and mpv would open with all of the videos in a playlist. Once mpv is running, I could switch to another workspace without worrying about where the next video will appear. mpv will continue to play all the videos in the first window it opens on the same workspace.

There are other benefits to using this feature of mpv. All of the videos I selected to be played are temporarily in the mpv playlist. If I want to go back/forward to a previous/next video in the playlist, I just hit "<" or ">". I think this should be the default behaviour.

Lastly, I think it would be desirable to have an option where pipe-viewer launches mpv with my videos, and returns to the prompt, ready for me to browse youtube some more, and perhaps select another bunch of videos and launch another instance of mpv.

trizen commented 1 day ago

@ehula Take a look at task-spooler.

ehula commented 19 hours ago

@trizen Thanks for the quick reply.

Task spooler (ts) does solve one of the above problems. I have implemented using ts with my player.

But it doesn't solve the main problem, and the problem identified by the OP in this issue, mainly, when selecting more than one video to play, once one video completes, the next video will start up in the current workspace. This is because the first mpv instance quits and a new instance is opened.

The OP and I would like them to play one after the other on the original workspace.

I think the best solution is to do what ytfzf does, which is to use the playlist feature of mpv. In other words, I would like to select multiple videos, and then I would like all those videos fed into mpv as a playlist. What happens then is that one instance of mpv is started with all of my selected video in a playlist that I can view and jump around in if I want. But the best feature is that once the first video starts to play, I can switch to another workspace, and when the first video is completed, the next one plays in the same mpv window on the original workspace.

I don't know how you are currently queuing up videos, but is there some way to define a "video_player", or is there some change you can make to the code to allow multiple selected videos to be loaded into mpv as a playlist?

Edit:

I think if you were to create a new token called *URLS*, a space-separated list of the YouTube URLs of the videos a user has selected, then all the user would have to do is replace *URL* with *URLS* in their video_player config to have all their selected videos appear as a playlist in mpv. This would solve the problem without breaking any existing functionality.