Skip to content

plugins.okru: canonicalize mobile URLs #6444

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

Merged

Conversation

bastimeyer
Copy link
Member

Fixes #6443

@leomani51214
https://github.com/streamlink/streamlink/blob/master/CONTRIBUTING.md#pull-request-feedback

Their mobile site sometimes returns a different HTML response which the plugin can't handle. This varying response seems to be similar to the data which is covered by the plugin's logic for their main site, but I don't think it's worth handling this case and refactoring the plugin because of that. Requesting the same video ID on their main site seems to be working, so I instead removed all logic for the mobile site and made the plugin translate mobile input URLs to URLs for their main site.

I however don't know if this solution works reliably, not just for the input URL of #6443. So @leomani51214, since I'm not familar with okru, please go ahead and test the changes of this PR and see if any other live streams are not working because of these changes. Thank you.


$ ./script/test-plugin-urls.py okru -r ID 9544902123178
:: https://m.ok.ru/video/9544902123178
::  240p, 360p, 480p, 720p, 1080p, worst, best
:: https://mobile.ok.ru/video/9544902123178
::  240p, 360p, 480p, 720p, 1080p, worst, best
:: https://ok.ru/live/9544902123178
::  240p, 360p, 480p, 720p, 1080p, worst, best
:: https://ok.ru/video/9544902123178
::  240p, 360p, 480p, 720p, 1080p, worst, best
:: https://ok.ru/videoembed/9544902123178
::  240p, 360p, 480p, 720p, 1080p, worst, best
:: https://www.ok.ru/video/9544902123178
::  240p, 360p, 480p, 720p, 1080p, worst, best

@bastimeyer bastimeyer added the plugin issue A Plugin does not work correctly label Feb 20, 2025
@bastimeyer bastimeyer force-pushed the plugins/okru/translate-mobile-urls branch from c58a069 to ead7952 Compare February 20, 2025 17:03
@bastimeyer bastimeyer changed the title plugins.okru: translate mobile URLs plugins.okru: canonicalize mobile URLs Feb 20, 2025
@bastimeyer bastimeyer force-pushed the plugins/okru/translate-mobile-urls branch from ead7952 to 508bbe6 Compare February 20, 2025 17:04
@bastimeyer
Copy link
Member Author

Different approch: use the canonical video URL from .//head/link[@rel='canonical'][@href][1] on their mobile site instead of translating mobile URLs in the plugin constructor. The reason for this is that video search results from mobile can't be translated, so it'll always return 4xx.

$ streamlink https://m.ok.ru/dk?st.cmd=movieLayer&st.groupId=57297539104788&st.retLoc=search&st.mvId=1765604597268&st.rtu=%2Fdk%3Fst.cmd%3DuserMovies%26st.vdsrch%3Dlive%26_prevCmd%3DuserMovies%26tkn%3D6061&_prevCmd=userMovies&tkn=9239&_cl.id=1740069479238&_clickLog=%5B%7B%22qId%22%3A%22484eb2ce7adbd123372ea76c0b6bd481%22%2C%22query%22%3A%22live%22%2C%22position%22%3A10%2C%22entityId%22%3A%221765604597268%22%2C%22searchActionEntity%22%3A%22VIDEO%22%2C%22searchActionCard%22%3A%22MOVIE_CARD%22%2C%22searchActionLocation%22%3A%22ANON_GLOBAL_SEARCH_VIDEO%22%2C%22searchActionTarget%22%3A%22CLICKABLE_AREA%22%2C%22target%22%3A%22videoSearch%22%7D%5D&_cl.sID=userMovies#lst best
[cli][info] Found matching plugin okru for URL https://m.ok.ru/dk?st.cmd=movieLayer&st.groupId=57297539104788&st.retLoc=search&st.mvId=1765604597268&st.rtu=%2Fdk%3Fst.cmd%3DuserMovies%26st.vdsrch%3Dlive%26_prevCmd%3DuserMovies%26tkn%3D6061&_prevCmd=userMovies&tkn=9239&_cl.id=1740069479238&_clickLog=%5B%7B%22qId%22%3A%22484eb2ce7adbd123372ea76c0b6bd481%22%2C%22query%22%3A%22live%22%2C%22position%22%3A10%2C%22entityId%22%3A%221765604597268%22%2C%22searchActionEntity%22%3A%22VIDEO%22%2C%22searchActionCard%22%3A%22MOVIE_CARD%22%2C%22searchActionLocation%22%3A%22ANON_GLOBAL_SEARCH_VIDEO%22%2C%22searchActionTarget%22%3A%22CLICKABLE_AREA%22%2C%22target%22%3A%22videoSearch%22%7D%5D&_cl.sID=userMovies#lst
[cli][info] Available streams: 240p (worst), 360p, 480p, 720p, 1080p (best)
[cli][info] Opening stream: 1080p (hls)
[cli][info] Starting player: /usr/bin/mpv
[cli][info] Player closed
[cli][info] Stream ended
[cli][info] Closing currently open stream...

@bastimeyer bastimeyer merged commit dd77463 into streamlink:master Feb 20, 2025
23 checks passed
@bastimeyer bastimeyer deleted the plugins/okru/translate-mobile-urls branch February 20, 2025 17:09
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
plugin issue A Plugin does not work correctly
Projects
None yet
Development

Successfully merging this pull request may close these issues.

plugins.okru: ElementPath query './/a[@data-video]' did not return an element
1 participant