Skip to content

#60 generalize video url#62

Open
marcopus wants to merge 10 commits intomcastorina:masterfrom
marcopus:#60_generalize_video_url
Open

#60 generalize video url#62
marcopus wants to merge 10 commits intomcastorina:masterfrom
marcopus:#60_generalize_video_url

Conversation

@marcopus
Copy link
Copy Markdown
Contributor

@marcopus marcopus commented Oct 3, 2022

Closes #60

earlier, if cmd["path"] was an url it assumed it was a yt video and prepend the ytdl:// prefix to the path for the controller. Now we skip this check and we rely on the client sending a valid (url) path for playing.
now if shared data is a valid URL it get sent straight away to the server for playing, else ytdl://ytsearch: is prefixed to the search string to performa a guess-search on yt
@marcopus marcopus marked this pull request as ready for review October 3, 2022 17:10
Copy link
Copy Markdown
Owner

@mcastorina mcastorina left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for improving this feature! 🎉

Comment on lines +171 to +177
// send valid url straight to server, or prepend ytdl://ytsearch for guess-searching
if (!URLUtil.isValidUrl(sharedText)) {
EditText et = (EditText) findViewById(R.id.ytsearch);
et.setText(sharedText);
sharedText = "ytdl://ytsearch:" + sharedText;
}
sendCommand(null, "play", "path", sharedText);
Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I wonder if this logic should happen on the server side. What do you think?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hmm.. Good point. In that case we could unify this logic with the existing logic that checks whether it's a valid file path, which is already server-side.. I think it also makes more sense, since ytdl is very much tight to the server (mpv) rather than the client. I'll make the changes

Comment thread server/mpv_remote_app/media_server.py Outdated
Comment on lines +150 to +155
path = join(self.root, cmd["path"])
if not isfile(path):
# not a file, perhaps a URI
if cmd["path"].startswith("ytdl://"):
ret = self.controller.play(cmd["path"])
else:
ret, msg = False, "%s is neither a file nor a valid URI" % cmd["path"]
else:
# play the file
ret = self.controller.play(abspath(realpath(path)))
if not isfile(
path := abspath(realpath(join(self.root, cmd["path"])))
):
path = cmd["path"]
# play the path
ret = self.controller.play(path)
Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice refactor!

@marcopus marcopus force-pushed the #60_generalize_video_url branch from f8e10da to 027884f Compare October 9, 2022 17:45
@marcopus
Copy link
Copy Markdown
Contributor Author

marcopus commented Oct 9, 2022

@mcastorina I adapted the code to do all checks server-side, can you pls review? :)

@marcopus
Copy link
Copy Markdown
Contributor Author

UP 😃

@mcastorina
Copy link
Copy Markdown
Owner

@marcopus sorry for such a long delay on this one 🙁

I will test the changes this week and if all looks good merge it.

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

Successfully merging this pull request may close these issues.

Wrong video played via shared data

2 participants