Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
sebma opened this issue Apr 27, 2021 · 3 comments

Comments

@sebma
Copy link

sebma commented Apr 27, 2021

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 ?

@beew
Copy link

beew commented Jul 8, 2021

Seems like you should file a bug to youtube-dl

youtube-dl -F https://m.facebook.com/story.php?story_fbid=1039169016616268&id=100015695375092
[1] 169281
bee@local:~$ [facebook] 1039169016616268: Downloading webpage
ERROR: Unable to download webpage: HTTP Error 404: Not Found (caused by <HTTPError 404: 'Not Found'>); please report this issue on https://yt-dl.org/bug . Make sure you are using the latest version; see  https://yt-dl.org/update  on how to update. Be sure to call youtube-dl with the --verbose flag and include its complete output.

@sebma
Copy link
Author

sebma commented Jul 9, 2021

@beew Nope. You need to quote this url because it contains the & character, youtube-dl works fine here :

$ youtube-dl -F "https://m.facebook.com/story.php?story_fbid=1039169016616268&id=100015695375092"
[facebook] 1039169016616268: Downloading webpage
[info] Available formats for 1039169016616268:
format code               extension  resolution note
916730542510987a          m4a        audio only DASH audio   49k , m4a_dash container, mp4a.40.5 (48000Hz)
464433831320708v          mp4        426x240    DASH video  110k , mp4_dash container, avc1.42C01E, video only
dash_sd_src               mp4        unknown    
dash_sd_src_no_ratelimit  mp4        unknown    (best)

@beew
Copy link

beew commented Jul 17, 2021

@sebma

Yeh you are right. The link works with ff2mpv on Firefox but not with play-with-mpv on Chrome

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants