-
Notifications
You must be signed in to change notification settings - Fork 14
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
#60 generalize video url #62
base: master
Are you sure you want to change the base?
Conversation
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
There was a problem hiding this 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! 🎉
// 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); |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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
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) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice refactor!
f8e10da
to
027884f
Compare
@mcastorina I adapted the code to do all checks server-side, can you pls review? :) |
…s/mpv-remote-app into #60_generalize_video_url
UP 😃 |
@marcopus sorry for such a long delay on this one 🙁 I will test the changes this week and if all looks good merge it. |
Closes #60