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

#60 generalize video url #62

Open
wants to merge 10 commits into
base: master
Choose a base branch
from

Conversation

marcopus
Copy link
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
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
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
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 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
Owner

Choose a reason for hiding this comment

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

Nice refactor!

@marcopus
Copy link
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
Contributor Author

UP 😃

@mcastorina
Copy link
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