Giter Site home page Giter Site logo

thann / play-with-mpv Goto Github PK

View Code? Open in Web Editor NEW
338.0 44.0 75.0 627 KB

Chrome extension that allows you to play videos in webpages like youtube with MPV instead

Home Page: https://chrome.google.com/webstore/detail/play-with-mpv/hahklcmnfgffdlchjigehabfbiigleji

License: The Unlicense

JavaScript 48.64% Python 38.60% HTML 12.77%
mpv chrome-extension video-player freedom

play-with-mpv's Introduction

Play with MPV

Chrome extension and python server that allows you to play videos in webpages with MPV instead.
Works on hundreds of sites thanks to youtube-dl, and even torrents if you install peerflix.

Installation

  1. Install MPV
  2. Install python 2 or 3 and pip
  3. Install chrome extension
  4. Run pip install git+git://github.com/thann/play-with-mpv --user
  5. Start server by running play-with-mpv (or use the Linux free desktop shortcut)

(optional) Install fair-use extension.
(optional) Install peerflix to stream torrents.
(optional) Install mkchromecast pip install git+git://github.com/muammar/mkchromecast --user and extension.
(recommended) Install youtube-dl through your package manager for frequent updates.
(Arch Linux) aur package available.

Usage

Right-click this link and select "Play with MPV". MPV should popup and start playing the video. (Ctrl+Space also works)

screenshot

Autostart

  • Linux: cp {/usr,~/.local}/share/applications/thann.play-with-mpv.desktop ~/.config/autostart
  • MacOS: instructions
  • Windows instructions

Protips

MPV is highly configurable, this is just how I like to use it.

To start in the corner, have no border, and stay on top: edit ~/.config/mpv/mpv.conf

ontop=yes
border=no
window-scale=0.4
geometry=100%:100%

In order to resize the window without borders, add keybinds: edit ~/.config/mpv/input.conf

` cycle border
ALT+UP add window-scale 0.05
ALT+DOWN add window-scale -0.05

play-with-mpv's People

Contributors

adithya-r-prabhu avatar thann 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  avatar  avatar  avatar  avatar  avatar

play-with-mpv's Issues

How to pass youtube-dl preferences?

Hi Jon

I have installed play-with-mpv and youtube-dl

sudo pip install git+git://github.com/thann/play-with-mpv
sudo pip install youtube-dl

and installed plugin for chrome.
Also I created config file for youtube-dl:

cat ~/.config/youtube-dl/config
-f bestvideo[height<=?1080]+bestaudio/best

as I don't want to get highest video quality, FullHD is enough.

But when I play some High Quality videos, youtube-dl chooses highest resolution, so my config file was ignored:

$ play-with-mpv
serving at port 7531
['play_url', 'https://www.youtube.com/watch?v=Bey4XXJAqS8']
127.0.0.1 - - [10/Jun/2019 19:22:38] "GET /?play_url=https://www.youtube.com/watch?v=Bey4XXJAqS8 HTTP/1.1" 200 -
Playing: https://www.youtube.com/watch?v=Bey4XXJAqS8
(+) Video --vid=1 () (vp9 3840x2160 29.970fps)
(+) Audio --aid=1 --alang=eng (
) 'DASH audio' (opus 2ch 48000Hz) (external)
Subs --sid=1 --slang=en 'vtt' (webvtt) (external)
AO: [pulse] 48000Hz stereo 2ch float
VO: [gpu] 3840x2160 yuv420p
AV: 00:00:03 / 00:29:36 (0%) A-V: 0.000 Cache: 33s+51MB

Do you know how to fix this?

Integrate server.py to the extension?

mpv is able to work with any site that youtube-dl supports. Vimeo, Dailymotion, etc should work as well.

edit:
Better tested, does not work on youtube either :/
mpv and youtuble-dl are working on my setup.
This similar extenstion for firefox works great : https://github.com/antoniy/mpv-youtube-dl-binding

edit2:
works after reading the doc... :p
had to run server.py ; but couldn't that be ran automatically when extention is active and server stoped when disabling the extention or shutting down chrome?

OSX launchd won't run the play-with-mpv script

Has anyone able to launch the play-with-mpv script with OSX successfully?
It seems that PythonHttpServer acting weird if it's launched with launchd.
Did I miss something here?Any help would be appreciated ๐Ÿ™

auto-start isn't working

I'm having trouble with auto-start, it isn't working. Could I get some help?

I followed the instructions here in this github. This log might have some relevant information:

my_user@pc:~$ lsb_release -a
No LSB modules are available.
Distributor ID:	Linuxmint
Description:	Linux Mint 20.1
Release:	20.1
Codename:	ulyssa
my_user@pc:~$ uname -a
Linux pc 5.8.0-53-generic #60~20.04.1-Ubuntu SMP Thu May 6 09:52:46 UTC 2021 x86_64 x86_64 x86_64 GNU/Linux
my_user@pc:~$ whereis play-with-mpv
play-with-mpv: /home/my_user/.local/bin/play-with-mpv
my_user@pc:~$ ls /usr/share/applications/ | grep ^th
thunar-bulk-rename.desktop
thunar.desktop
thunar-settings.desktop
thunar-volman-settings.desktop
thunderbird.desktop
my_user@pc:~$ ls -l ~/.local/share/applications/thann.play-with-mpv.desktop
-rwxrwxr-x 1 my_user my_user 310 mai 13 21:46 /home/my_user/.local/share/applications/thann.play-with-mpv.desktop
my_user@pc:~$ ls -l ~/.local/bin/play-with-mpv 
-rwxrwxr-x 1 my_user my_user 214 mai 13 21:46 /home/my_user/.local/bin/play-with-mpv
my_user@pc:~$ ls -l ~/.config/autostart/thann.play-with-mpv.desktop 
-rwxrwxr-x 1 my_user my_user 310 mai 13 21:51 /home/my_user/.config/autostart/thann.play-with-mpv.desktop
my_user@pc:~$ diff ~/.local/share/applications/thann.play-with-mpv.desktop ~/.config/autostart/thann.play-with-mpv.desktop 
my_user@pc:~$ cat ~/.config/autostart/thann.play-with-mpv.desktop 
#!/usr/bin/env xdg-open
[Desktop Entry]
Categories=AudioVideo;Audio;Video;Player;TV
Comment=Chrome extension and python server that allows you to play videos in webpages with MPV instead.
Exec=/play_with_mpv-0.1.0.post9+g07a9c1d.data/scripts/play-with-mpv
Icon=mpv
Name=Play With MPV (server)
Type=Application

Error on installing the server

Been running pip3 install git+https://github.com/thann/play-with-mpv but got the following output:

ERROR: Command errored out with exit status 1:
     command: /usr/bin/python -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'/tmp/pip-req-build-_gn3hp6x/setup.py'"'"'; __file__='"'"'/tmp/pip-req-build-_gn3hp6x/setup.py'"'"';f=getattr(tokenize, '"'"'open'"'"', open)(__file__);code=f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' egg_info --egg-base /tmp/pip-pip-egg-info-8646fqve
         cwd: /tmp/pip-req-build-_gn3hp6x/
    Complete output (46 lines):
    WARNING: The wheel package is not available.
    WARNING: Skipping page https://github.com/thann/install_freedesktop/tarball/master#egg=install_freedesktop-0.2.0 because the GET request got Content-Type: application/x-gzip.The only supported Content-Type is text/html
      WARNING: Cache entry deserialization failed, entry ignored
      ERROR: Command errored out with exit status 1:
       command: /usr/bin/python -u -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'/tmp/pip-wheel-r1x9agur/install-freedesktop_55051b358b2843a8832f8ed15439cfd7/setup.py'"'"'; __file__='"'"'/tmp/pip-wheel-r1x9agur/install-freedesktop_55051b358b2843a8832f8ed15439cfd7/setup.py'"'"';f=getattr(tokenize, '"'"'open'"'"', open)(__file__);code=f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' bdist_wheel -d /tmp/pip-wheel-rorsue2t
           cwd: /tmp/pip-wheel-r1x9agur/install-freedesktop_55051b358b2843a8832f8ed15439cfd7/
      Complete output (6 lines):
      usage: setup.py [global_opts] cmd1 [cmd1_opts] [cmd2 [cmd2_opts] ...]
         or: setup.py --help [cmd1 cmd2 ...]
         or: setup.py --help-commands
         or: setup.py cmd --help
    
      error: invalid command 'bdist_wheel'
      ----------------------------------------
      ERROR: Failed building wheel for install-freedesktop
    ERROR: Failed to build one or more wheels
    Traceback (most recent call last):
      File "/usr/lib/python3.9/site-packages/setuptools/installer.py", line 75, in fetch_build_egg
        subprocess.check_call(cmd)
      File "/usr/lib/python3.9/subprocess.py", line 373, in check_call
        raise CalledProcessError(retcode, cmd)
    subprocess.CalledProcessError: Command '['/usr/bin/python', '-m', 'pip', '--disable-pip-version-check', 'wheel', '--no-deps', '-w', '/tmp/tmp75ck894n', '--quiet', '--find-links', 'https://github.com/thann/install_freedesktop/tarball/master#egg=install_freedesktop-0.2.0', 'install_freedesktop>=0.2.0']' returned non-zero exit status 1.
    
    The above exception was the direct cause of the following exception:
    
    Traceback (most recent call last):
      File "<string>", line 1, in <module>
      File "/tmp/pip-req-build-_gn3hp6x/setup.py", line 27, in <module>
        setup(
      File "/usr/lib/python3.9/site-packages/setuptools/__init__.py", line 152, in setup
        _install_setup_requires(attrs)
      File "/usr/lib/python3.9/site-packages/setuptools/__init__.py", line 147, in _install_setup_requires
        dist.fetch_build_eggs(dist.setup_requires)
      File "/usr/lib/python3.9/site-packages/setuptools/dist.py", line 721, in fetch_build_eggs
        resolved_dists = pkg_resources.working_set.resolve(
      File "/usr/lib/python3.9/site-packages/pkg_resources/__init__.py", line 766, in resolve
        dist = best[req.key] = env.best_match(
      File "/usr/lib/python3.9/site-packages/pkg_resources/__init__.py", line 1051, in best_match
        return self.obtain(req, installer)
      File "/usr/lib/python3.9/site-packages/pkg_resources/__init__.py", line 1063, in obtain
        return installer(requirement)
      File "/usr/lib/python3.9/site-packages/setuptools/dist.py", line 780, in fetch_build_egg
        return fetch_build_egg(self, req)
      File "/usr/lib/python3.9/site-packages/setuptools/installer.py", line 77, in fetch_build_egg
        raise DistutilsError(str(e)) from e
    distutils.errors.DistutilsError: Command '['/usr/bin/python', '-m', 'pip', '--disable-pip-version-check', 'wheel', '--no-deps', '-w', '/tmp/tmp75ck894n', '--quiet', '--find-links', 'https://github.com/thann/install_freedesktop/tarball/master#egg=install_freedesktop-0.2.0', 'install_freedesktop>=0.2.0']' returned non-zero exit status 1.
    ----------------------------------------
ERROR: Command errored out with exit status 1: python setup.py egg_info Check the logs for full command output.

Add a option to change the ip

Would be great to be able to change the ip for the server in the options menu so you can run the server on a different computer hooked to a tv.

Best way to launch play-with-mpv?

Hey @Thann,

I have a question about:

Start server by running play-with-mpv (or use the Linux free desktop shortcut)

The way I do it at the moment is opening a terminal and then running this command.

However, it would be great if this command could launch automatically in the background when wanting to play a video with mpv by using this extension.

Is this somehow possible?

Thanks! :)

Allow mpv options with play-with-mpv

I use Send to mpv with firefox and mpv has default media player.

I'm trying to use you addon on vivaldi
With the previous app, i can set arguments mpv --title=Player --geometry=45%x45% --load-unsafe-playlists to run firefox's mpv with options and keep mpv config clear for other uses.

Make some thing like play-with-mpv --title=Player --geometry=45%x45% --load-unsafe-playlists should be perfect or maybe ith a config file

Firefox support

It would be great if there was a firefox version of this addon.

Since fx 57 supports webextensions, I tried installing it with chrome store foxified but it fails AMO validation due to the extension toolbar icon not being square

play-with-mpv doesn't work

I literally know nothing about programming. I followed all the steps, IDK what I'm doing wrong.

serving on localhost:7531
MPV ARGS: ['--ytdl-format=bestvideo[height<=?1080]+bestaudio/best']

Exception occurred during processing of request from ('127.0.0.1', 51547)
Traceback (most recent call last):
File "C:\Program Files\WindowsApps\PythonSoftwareFoundation.Python.3.9_3.9.496.0_x64__qbz5n2kfra8p0\lib\socketserver.py", line 316, in _handle_request_noblock
self.process_request(request, client_address)
File "C:\Program Files\WindowsApps\PythonSoftwareFoundation.Python.3.9_3.9.496.0_x64__qbz5n2kfra8p0\lib\socketserver.py", line 347, in process_request
self.finish_request(request, client_address)
File "C:\Program Files\WindowsApps\PythonSoftwareFoundation.Python.3.9_3.9.496.0_x64__qbz5n2kfra8p0\lib\socketserver.py", line 360, in finish_request
self.RequestHandlerClass(request, client_address, self)
File "C:\Program Files\WindowsApps\PythonSoftwareFoundation.Python.3.9_3.9.496.0_x64__qbz5n2kfra8p0\lib\socketserver.py", line 720, in init
self.handle()
File "C:\Program Files\WindowsApps\PythonSoftwareFoundation.Python.3.9_3.9.496.0_x64__qbz5n2kfra8p0\lib\http\server.py", line 427, in handle
self.handle_one_request()
File "C:\Program Files\WindowsApps\PythonSoftwareFoundation.Python.3.9_3.9.496.0_x64__qbz5n2kfra8p0\lib\http\server.py", line 415, in handle_one_request
method()
File "C:\Users\daban\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.9_qbz5n2kfra8p0\LocalCache\local-packages\Python39\site-packages\play_with_mpv.py", line 46, in do_GET
pipe = Popen(['mpv', urls, '--force-window'] +
File "C:\Program Files\WindowsApps\PythonSoftwareFoundation.Python.3.9_3.9.496.0_x64__qbz5n2kfra8p0\lib\subprocess.py", line 947, in init
self._execute_child(args, executable, preexec_fn, close_fds,
File "C:\Program Files\WindowsApps\PythonSoftwareFoundation.Python.3.9_3.9.496.0_x64__qbz5n2kfra8p0\lib\subprocess.py", line 1416, in _execute_child
hp, ht, pid, tid = _winapi.CreateProcess(executable, args,
FileNotFoundError: [WinError 2] The system cannot find the file specified

Play HTTP link with authentication

If I try to play a link which requires http authentication nothing happens
Would it be possible to pass the cookie or http authentication header to the player ?

Bug: The url arguments are not passed to the urls variable in play_with_mpv.py

Hi,
I tried to load this video : https://m.facebook.com/story.php?story_fbid=1039169016616268&id=100015695375092
but it does not work because only a part of the previous url (https://m.facebook.com/story.php?story_fbid=1039169016616268) is passed to mpv.

After some digging in your play_with_mpv.py script and with the help of the ipdb debugger python module, I noticed that your url.query is transformed into a dictionary hence losing the HTTP GET arguements in the play_url :

ipdb> l 45
     40             query = urlparse.parse_qs(url.query)
     41         except:
     42             query = {}
     43         if query.get('mpv_args'):
     44             print("MPV ARGS:", query.get('mpv_args'))
     45         set_trace()
---> 46         if "play_url" in query:
     47             urls = str(query["play_url"][0])
     48             if urls.startswith('magnet:') or urls.endswith('.torrent'):
     49                 pipe = Popen(['peerflix', '-k',  urls, '--', '--force-window'] +
     50                              query.get("mpv_args", []))

ipdb> url.query
'play_url=https://m.facebook.com/story.php?story_fbid=1039169016616268&id=100015695375092&mpv_args=--ytdl-format%3Dbestvideo%5Bheight%3C%3D%3F480%5D%2Bbestaudio%2Fbest'
ipdb> urlparse.parse_qs(url.query)
{'play_url': ['https://m.facebook.com/story.php?story_fbid=1039169016616268'], 'id': ['100015695375092'], 'mpv_args': ['--ytdl-format=bestvideo[height<=?480]+bestaudio/best']}
ipdb> urlparse.parse_qs(url.query)['play_url']
['https://m.facebook.com/story.php?story_fbid=1039169016616268']

I used this little trick to fetch the complete url :

ipdb> url.query.split('play_url=')[1].split('&mpv_args')[0]
'https://m.facebook.com/story.php?story_fbid=1039169016616268&id=100015695375092'

I'm not sure if that's the right way to do it, but It works :

ipdb> n
> /usr/local/lib/python3.8/dist-packages/play_with_mpv.py(47)do_GET()
     46         if "play_url" in query:
---> 47             urls = str(query["play_url"][0])
     48             if urls.startswith('magnet:') or urls.endswith('.torrent'):

ipdb> 
> /usr/local/lib/python3.8/dist-packages/play_with_mpv.py(48)do_GET()
     47             urls = str(query["play_url"][0])
---> 48             if urls.startswith('magnet:') or urls.endswith('.torrent'):
     49                 pipe = Popen(['peerflix', '-k',  urls, '--', '--force-window'] +

ipdb> urls=url.query.split('play_url=')[1].split('&mpv_args')[0]
ipdb> urls
'https://m.facebook.com/story.php?story_fbid=1039169016616268&id=100015695375092'
ipdb> r
127.0.0.1 - - [27/Apr/2021 22:18:12] "GET /?play_url=https://m.facebook.com/story.php?story_fbid=1039169016616268&id=100015695375092&mpv_args=--ytdl-format%3Dbestvideo%5Bheight%3C%3D%3F480%5D%2Bbestaudio%2Fbest HTTP/1.1" 200 -
--Return--
None
> /usr/local/lib/python3.8/dist-packages/play_with_mpv.py(54)do_GET()
     53                              query.get("mpv_args", []))
---> 54             self.respond(200, "playing...")
     55         elif "cast_url" in query:

ipdb> Can't load unknown script: /home/sebastien/.config/mpv/scripts/luadoc.css
[auto_profiles] Applying profile seb-C70D-B-311 
Resuming playback. This behavior can be disabled with --no-resume-playback.
 (+) Video --vid=1 (*) (h264 426x240 29.970fps)
 (+) Audio --aid=1 (*) (aac 2ch 48000Hz)
File tags:
 Title: 1039169003282936
mesa: for the --simplifycfg-sink-common option: may only occur zero or one times!
mesa: for the --global-isel-abort option: may only occur zero or one times!
mesa: for the --amdgpu-atomic-optimizations option: may only occur zero or one times!
mesa: for the --structurizecfg-skip-uniform-regions option: may only occur zero or one times!
AO: [pulse] 48000Hz stereo 2ch float
Using hardware decoding (vaapi).
VO: [gpu] 426x240 vaapi[nv12]
AV: 00:02:43 / 00:09:23 (28%) A-V:  0.000 Cache: 399s/18MB
Saving state.


Exiting... (Quit)
ipdb>

Can you please fix this ?

facebook videos don't work lately

I only use play-with-mpv to watch fb & youtube videos, but fb videos don't work today.
I'm using Arch on a slow laptop, right-clicking here:
ksnip_20201016-224800

I'm suspecting fb put a lot of junk on their links and this is a youtube-dl issue.

Debian stores the executable on .local/bin/play-with-mpv

On GNU/Linux Debian, the launcher was not set correctly, I had to execute this way ./.local/bin/play-with-mpv
So I needed to modify the executable to this path.
Changed the Play With MPV (server) on /home/floor/.local/share/applications/ to Exec=./.local/bin/play-with-mpv as it is a better consistent solution.
play-with-mpv works on ungoogled-chromium (to appear on search results).

Something wrong with GNOME autostart?

The installed desktop file thann.play-with-mpv.desktop looks like this:

#!/usr/bin/env xdg-open
[Desktop Entry]
Categories=AudioVideo;Audio;Video;Player;TV
Comment=Chrome extension and python server that allows you to play videos in webpages with MPV instead.
Exec=/play_with_mpv-0.0.9.data/scripts/play-with-mpv
Icon=mpv
Name=Play With MPV (server)
Type=Application

I copied this to the autostart directory, yet autostart doesn't work. When I launch gnome-tweaks, I get the error message:

WARNING : Error loading desktopfile: /home/xuanrui/.config/autostart/thann.play-with-mpv.desktop

which seems to suggest that there is a problem with this file. I tried to fix this file by removing the shebang line and fixing the Exec path and it seemed to work again. But it might be better if we don't ship broken .desktop files :(

Start videos at the correct time

It is just annoying to have to manually skip to the position if you forgot to play it with mpv from the start.

Mpv supports the youtube "?t=123" syntax so this should be an easy fix. I would even fix it myself if there are no reasons for not doing that.

This feature could be turned on / off in the settings.

I would appreciate any feedback!

Shortcut Keybind for playing in mpv

Hello, I am a big fan of your extension, but I would much rather prefer to use a keyboard shortcut than to press the extension button. Your readme suggests ctrl+spacebar is the hotkey, but this didn't seem to work for me when I pressed it on a youtube video url.

Windows 10, installed, but nothing is happening.

I installed with pip included in my python like below. (might be not good to do that way?)

py -m pip install git+git://github.com/thann/play-with-mpv --user

it went ahead and did all good, warned by about wheel and ytdl but still continued and "finished"

At abit of a loss of where it was placed, running play-with-mpv in console does nothing. Maybe I messed it up. Really want to get it working though. Can't manage to get any errors to share. I am on windows 10

Retry with pip installed stand alone?

play-with-mpv command not found

Successfully installed play-with-mpv-0.0.9

pip install git+git://github.com/thann/play-with-mpv --user

play-with-mpv: command not found

I've tried running this without the --user flag as well

Kubuntu, i3

=========SOLVED==========

Essentially I have to navigate to ~/.local/bin to execute the play-with-mpv command
Just wrote a bash script so I can call command from anywhere

Provided pip install command fails

If I run the install command from the readme it's failing:

brandon@xps13 ~ $ pip install git+git://github.com/thann/play-with-mpv --user
Collecting git+git://github.com/thann/play-with-mpv
Cloning git://github.com/thann/play-with-mpv to /tmp/pip-uC2Hk3-build
Complete output from command python setup.py egg_info:
[email protected]: Permission denied (publickey).
fatal: Could not read from remote repository.

Please make sure you have the correct access rights
and the repository exists.

Tried it on two different machines and got the same result

I tried manually cloning the repo (git clone git://github.com/thann/play-with-mpv) and that works without error. I then tried pip install /path/to/play-with-mpv --user and that failed with the same user as above

Opening videos with right click (youtube)

Steps to reproduce:

  • Starting the server for play-with-mpv
  • Open a video on YouTube (e.g. A Cat Video)
  • Right-Click on the running video twice (since YouTube has its own context menu)
  • Click play-with-mpv

Expected Behavior:

Video would be opened.

Observed Behavior:

Video is successfully sent to internal play-with-mpv server but doesn't play due to error (see below):

[...]
[file] Cannot open file 'blob:https://www.youtube.com/80d576ea-46a7-4123-8fd1-79200e4ff32f': No such file or directory
Failed to open blob:https://www.youtube.com/80d576ea-46a7-4123-8fd1-79200e4ff32f.

Fix:

The right click menu needs to remove the blob: prefix. At the moment only the menu in the top right corner works since it sends the URL directly.

Environment:

  • Browser: Brave Browser 89.1.22.71
  • Python: Python 3.7.3
  • Extension: 0.1.0
  • play-with-mpv: from git

Not startin gplay-with-mpv

Terminal output:

Traceback (most recent call last):
  File "/usr/bin/play-with-mpv", line 6, in <module>
    from pkg_resources import load_entry_point
  File "/usr/lib/python3.8/site-packages/pkg_resources/__init__.py", line 3252, in <module>
    def _initialize_master_working_set():
  File "/usr/lib/python3.8/site-packages/pkg_resources/__init__.py", line 3235, in _call_aside
    f(*args, **kwargs)
  File "/usr/lib/python3.8/site-packages/pkg_resources/__init__.py", line 3264, in _initialize_master_working_set
    working_set = WorkingSet._build_master()
  File "/usr/lib/python3.8/site-packages/pkg_resources/__init__.py", line 583, in _build_master
    ws.require(__requires__)
  File "/usr/lib/python3.8/site-packages/pkg_resources/__init__.py", line 900, in require
    needed = self.resolve(parse_requirements(requirements))
  File "/usr/lib/python3.8/site-packages/pkg_resources/__init__.py", line 786, in resolve
    raise DistributionNotFound(req, requirers)
pkg_resources.DistributionNotFound: The 'wheel' distribution was not found and is required by play-with-mpv

Autostart native server via native-messaging-hosts

Requiring the user to manually start the native python server is suboptimal. Instead, it could be worth it to register the native server in browser-specific native-messaging-hosts and rework it to communicate with the extension via stdio rather than via HTTP requests to localhost.

E. g. on Chromium on Arch, this is how it looks for the browserpass native host:

$ cat /etc/chromium/native-messaging-hosts/com.dannyvankooten.browserpass.json
{
  "name": "com.dannyvankooten.browserpass",
  "description": "Browserpass binary for the Chrome extension",
  "path": "/usr/bin/browserpass",
  "type": "stdio",
  "allowed_origins": [
    "chrome-extension://naepdomgkenhinolocfifgehidddafch/",
    "chrome-extension://klfoddkbhleoaabpmiigbmpbjfljimgb/"
  ]
}

This would require reworking the native server and the extension to communicate via pipes rather than via HTTP request. It should be doable โ€” very simple "protocol" would be to encode the message in a single-line JSON and terminate it with a newline.

Multiuser solution

This setup doesn't play well with multiple users.

If you set it to autostart on 2 users and:

  1. Login into user A
  2. Switch user
  3. Login into user B
  4. play-with-mpv can't start on user B because the port is open from user A
  5. Click on the extension icon
  6. The video will play on user A but we're on account B

Cannot play magnet link with peerflix installed

playing normally through cmd with peerflix "magnetlink" --mpv works wonderfully, but in chrome right-clicking a magnet link and choosing "Play with MPV" doesn't seem to do anything.
Is there any further configuration i need to do to make this work?

I can't play any videos if I add options including `--ytdl-options` on the extension options page

If I add --ytdl-format="((bestvideo[vcodec^=vp9]/bestvideo)+bestaudio)/best" to "MPV options" in the extension options page, MPV doesn't start properly anymore. MPV is launched, with the proper options, but then after a few seconds the status of MPV changes to mpv [defunct], and no window is displayed.

I have tested with starting mpv on the command line with the same command line options, and everything works alright, so there are no problems with my command line options. There seems to be something wrong with the play-with-mpv server.

force-window option in server.py causes high cpu load and desktop freeze after closing mpv

The --force-window option in server.py causes high(er) cpu load while playling videos and a desktop freeze after closing mpv (opened a youtube video with play-with-mpv). Tried with 2 different WMs: bspwm and i3-gaps

system: Arch Linux (up to date as of 05-21-2018)
i3-gaps version: 4.15.0.1-2
bspwm version: 0.9.5-1
chromium version: 66.0.3359.181 (Official Build) Arch Linux (64-bit)

mpv --version
mpv 0.28.2 (C) 2000-2017 mpv/MPlayer/mplayer2 projects
built on Mon May 14 09:49:30 CEST 2018
ffmpeg library versions:
libavutil 56.14.100
libavcodec 58.18.100
libavformat 58.12.100
libswscale 5.1.100
libavfilter 7.16.100
libswresample 3.1.100
ffmpeg version: 4.0

play-with-mpv-git is up to date from the AUR

I removed the --force-window option from /usr/lib/python3.6/site-packages/server.py and now it doesn't cause high cpu load and desktop freeze anymore.

I did not experience this issue when I opened a video from the terminal (with mpv & youtube-dl), so I think it's related to play-with-mpv's server.py.

serving on localhost:7531 ---------------------------------------- Exception happened during processing of request from ('127.0.0.1', 52654) Traceback (most recent call last): File "C:\Program Files\py\lib\socketserver.py", line 317, in _handle_request_noblock self.process_request(request, client_address) File "C:\Program Files\py\lib\socketserver.py", line 348, in process_request self.finish_request(request, client_address) File "C:\Program Files\py\lib\socketserver.py", line 361, in finish_request self.RequestHandlerClass(request, client_address, self) File "C:\Program Files\py\lib\socketserver.py", line 696, in __init__ self.handle() File "C:\Program Files\py\lib\http\server.py", line 418, in handle self.handle_one_request() File "C:\Program Files\py\lib\http\server.py", line 406, in handle_one_request method()

NxkVfxM5Wo

Does not work in Brave

When I press the button, nothing happens. There's no logs coming out of the server either. If I curl the server directly I do get a 400 error and a corresponding entry on the log for the server. It doesn't seem like the extension is even making the request.

I'm using all defaults - non-public, default port. I've checked the config for the browser extension and it matches.

There's no further logging on the brave console logs, if I start brave from a terminal.

Is there anything I can do to view logs for the extension itself somehow?

Ubuntu 20.04
Brave nightly 1.25.5 (Chromium 89)
youtube-dl 2021.02.22
Python 3.8
play-with-mpv server 0.1.0.post8+g69beabf

Incorrect versioning in Arch AUR package

The Arch AUR package play-with-mpv-git has incorrect versioning scheme. Basically, it extracts version from setup.py and appends short commit id of HEAD:

pkgver() {
  cd $pkgname
  echo "$(python setup.py --version | tail -n1)+$(git rev-parse --short HEAD)"
}

If a commit is added without bumping version string in setup.py, the new pkgver won't necessarily compare as "greater" with the previous one. This is contrary to the AUR packaging guidelines.

It is strongly recommended to tag releases in Git instead, then use the following pkgver() function:

pkgver() {
    cd $pkgname
    git describe --long --tags | sed 's/-/.r;s/-/./' # add 's/^v//' if your tag is prefixed with 'v'
}

Audio only?

Hey @Thann love your extension! Question. I want to preserve as much battery of my laptop as I can. Hence want to only stream the audio. Any way to achieve this? :-)

Thanks!

Vivaldi displays the extension button in the wrong place

I'm not really sure what would be causing this, but this is the only extension it's happening for. Even though everything works fine in Chromium, in Vivaldi, the extension's button appears inside the URL bar instead of with the rest of the extension buttons. Additionally the option to hide it does nothing. This actually appears to have been caused by a bug in Vivaldi with the Extensions Toggle option in the address bar settings. I believe a recent change to Chromium upstream broke this functionality. I really love being able to right click on links to mkv files and open them with mpv in one click but I really don't want that button cluttering up my interface even more than it already is.

Below is a screenshot of the odd phenomenon, along with a bunch of other extensions so you can see what I expect it to look like.
image

Select default quality?

If for example I want to only play up to 1080p and if a video is 4k I want it to not select that one but choose the lower one what would I need to configure?

Request: solution to play video in stream pages (like vidcloud9)

Hi, your application its amazing, i found some issues on stream video pages like vidcloud9, your code try to read the direct link but some pages (if not all of them), process the videos using embedded players like jwplayer, for that reason cli returns an error because they cant find the video, i like to know if you can implement a compatibility for that cases, if you can process the url with 9xbuddy.org this service comeback the real urls of video embed and with this urls you can play the video directly and avoid the error message:

[ytdl_hook] youtube-dl failed: unexpected error ocurred
Failed to recognize file format.

Thanks and i hope you can add this process option in the future, its only pass the links before on 9xbuddy, catch the return links and play it.

thanks for your time!

Bug : Wrong Exec= argument value in "thann.play-with-mpv.desktop" file

Hi,
Your thann.play-with-mpv.desktop file contains the temporary path used during the building of the python wheel.

Here's what I see when I install your module as a normal user :

$ pip install git+git://github.com/thann/play-with-mpv --user
Collecting git+git://github.com/thann/play-with-mpv
  Cloning git://github.com/thann/play-with-mpv to /tmp/pip-req-build-hncv1p_j
  Running command git clone -q git://github.com/thann/play-with-mpv /tmp/pip-req-build-hncv1p_j
Requirement already satisfied: wheel in /usr/local/lib/python3.6/dist-packages (from play-with-mpv==0.1.0.post5+g656448e) (0.33.1)
Requirement already satisfied: youtube-dl in /usr/local/lib/python3.6/dist-packages (from play-with-mpv==0.1.0.post5+g656448e) (2020.6.16.1)
Building wheels for collected packages: play-with-mpv
  Building wheel for play-with-mpv (setup.py) ... done
  Created wheel for play-with-mpv: filename=play_with_mpv-0.1.0.post5+g656448e-py3-none-any.whl size=5601 sha256=875390f5c927245de99703bf57c8322a44a944f6ab240bd0b3d2b6dec3945205
  Stored in directory: /tmp/pip-ephem-wheel-cache-ojgomgev/wheels/c5/f4/a3/7a8b76b863f05c0441c50152cd5c57f7db6546666ee156e7f8
Successfully built play-with-mpv
Installing collected packages: play-with-mpv
Successfully installed play-with-mpv-0.1.0.post5+g656448e
$ grep Exec= ~/.local/share/applications/thann.play-with-mpv.desktop
Exec=/play_with_mpv-0.1.0.post5+g656448e.data/scripts/play-with-mpv
$ ls /play_with_mpv-0.1.0.post5+g656448e.data/scripts/play-with-mpv
ls: cannot access /play_with_mpv-0.1.0.post5+g656448e.data/scripts/play-with-mpv: No such file or directory

But the Exec= line should be :
Exec=~/.local/bin/play-with-mpv

$ ls ~/.local/bin/play-with-mpv
/home/sebastien/.local/bin/play-with-mpv

And if I install it as a sudoer I get :

$ sudo -H $(which pip) install git+git://github.com/thann/play-with-mpv 
Collecting git+git://github.com/thann/play-with-mpv
  Cloning git://github.com/thann/play-with-mpv to /tmp/pip-req-build-xgtpwwl9
  Running command git clone -q git://github.com/thann/play-with-mpv /tmp/pip-req-build-xgtpwwl9
Requirement already satisfied: wheel in /usr/local/lib/python3.6/dist-packages (from play-with-mpv==0.1.0.post5+g656448e) (0.33.1)
Requirement already satisfied: youtube-dl in /usr/local/lib/python3.6/dist-packages (from play-with-mpv==0.1.0.post5+g656448e) (2020.6.16.1)
Building wheels for collected packages: play-with-mpv
  Building wheel for play-with-mpv (setup.py) ... done
  Created wheel for play-with-mpv: filename=play_with_mpv-0.1.0.post5+g656448e-py3-none-any.whl size=5601 sha256=37354253fb65c3bb782bb3fb4160862f134460200e8d344fc94bfa162722f343
  Stored in directory: /tmp/pip-ephem-wheel-cache-hvejy6is/wheels/c5/f4/a3/7a8b76b863f05c0441c50152cd5c57f7db6546666ee156e7f8
Successfully built play-with-mpv
Installing collected packages: play-with-mpv
Successfully installed play-with-mpv-0.1.0.post5+g656448e
$ grep Exec= /usr/local/share/applications/thann.play-with-mpv.desktop
Exec=/play_with_mpv-0.1.0.post5+g656448e.data/scripts/play-with-mpv
$ ls /play_with_mpv-0.1.0.post5+g656448e.data/scripts/play-with-mpv
ls: cannot access /play_with_mpv-0.1.0.post5+g656448e.data/scripts/play-with-mpv: No such file or directory

But then the Exec= line should be :
Exec=/usr/local/bin/play-with-mpv

$ ls /usr/local/bin/play-with-mpv
/usr/local/bin/play-with-mpv

Prefix the "ytdl-format" argument value by "best[height<=${opts.maxheight}]/"

Hi,
Can you please update the --ytdl-format argument value in your ../chrome-extension/background.js according to this git diff output so that format selection on https://ok.ru/video can work :

$ git br 
* master
$ git describe --tags --abbrev=0
0.1.0
$ git diff chrome-extension/background.js
diff --git a/chrome-extension/background.js b/chrome-extension/background.js
index 799d99d..4de29e8 100644
--- a/chrome-extension/background.js
+++ b/chrome-extension/background.js
@@ -25,7 +25,7 @@ function playUrl(url, pause) {
                }
                if (opts.maxheight) {
                        opts.mpv_args.splice(0, 0,
-                       `--ytdl-format=bestvideo[height<=?${opts.maxheight}]+bestaudio/best`);
+                       `--ytdl-format=best[height<=${opts.maxheight}]/bestvideo[height<=?${opts.maxheight}]+bestaudio/best`);
                }
                const query = (`?play_url=` + encodeURIComponent(url) + [''].concat(
                        opts.mpv_args.map(encodeURIComponent)).join('&mpv_args='));

I tried modifying this file myself within the browser extension directory, but chrome says This extension may have been corrupted. and thus disabled this extension.

play-with-mpv opens the video twice (in separate mpv windows).

Note: I am on windows. Using python 3.9.

The first time I open a video using the extension, it opens the video only once. But after I close that window and open any other video via the extension, it opens the video twice. I have double and triple checked that there is only one instance of play-with-mpv.exe running. If i force quit the process, it always works correctly for the first video, but opens two instances of mpv for every video after that.

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.