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

Input/Write URL (a option in Menu & in Subtitles/Audio Button) #497

Closed
alexpandain opened this issue Apr 5, 2023 · 30 comments
Closed

Input/Write URL (a option in Menu & in Subtitles/Audio Button) #497

alexpandain opened this issue Apr 5, 2023 · 30 comments

Comments

@alexpandain
Copy link

image
image

@tomasklaen
Copy link
Owner

Sure. No objections, but no ETA either :)

@aicynide
Copy link

aicynide commented Nov 3, 2023

Waiting

@po5
Copy link
Contributor

po5 commented Nov 4, 2023

Here's a script that does what you want, but note that pasting in search menus is not currently supported.

-- open-url.lua

mp.utils = require "mp.utils"

mp.register_script_message("open-url:", function(path)
    mp.commandv("script-message-to", "uosc", "close-menu", "open-url")
    mp.commandv("loadfile", path)
end)

mp.add_forced_key_binding("F10", "open-url", function()
    local script_name = mp.get_script_name()
    local json = mp.utils.format_json({
        type = "open-url",
        title = "http://www.example.com/stream.avi",
        items = {
            {
            title = "Enter a network URL and press Ctrl+Enter",
            value = "ignore",
            muted = true,
            selectable = false
            }
        },
        on_search = {"script-message-to", script_name, "open-url:"},
        palette = true,
        search_style = "palette",
        search_debounce = "submit"
    }) or "{}"
    mp.commandv("script-message-to", "uosc", "open-menu", json)
end)

Doesn't handle loading links as extra tracks but that's a trivial change if you want that.
Replace loadfile with sub-add, audio-add or video-add.

@tomasklaen
Copy link
Owner

Just an update: I don't want to add more loading items to subtitle/audio menus, especially not for something like this that won't be used by almost anyone, so it'll have to be as an alt action on the "Load {type}" item, which depends on menu item buttons, which is not implemented yet.

tomasklaen added a commit that referenced this issue Nov 4, 2023
This adds several paste related features:

- You can paste into search input box.
- You can paste a url or a path into track select menus (subtitles/audio/video) to load it.
- Menu API now accepts `on_paste` option, which works the same as `on_search`.

closes #765, ref #497
@tomasklaen
Copy link
Owner

There's still no button or UI so I'll keep this open, but thanks to the commit above, in 5.1 you'll be able to paste in subtitle/audio/video track select menus to automatically load whatever path/url is in the clipboard as current menu track type.

@aicynide
Copy link

I hope one day you support typing URL also like vlc

@aicynide
Copy link

funny thing is mpv-android let you load subtitle/audio by typing URL.
Check mpv-android app, it even support typing video URL

@cipricus
Copy link

Just in case, as a tip to the OP, showing that the need for this is rather limited. Dragging and dropping an url on mpv window does it.

image

I guess this question is asked in Windows but in Linux you can do it by copying the link and in a terminal writing mpv and pasting.

And more specifically in Plasma if we associate html files to mpv, copying the link will open the list of applications associated with html.

@aicynide
Copy link

typing URL like vlc should be added

@aicynide
Copy link

I'm clueless why does typing URL like any guide video player software like VLC,Potplayer,Mpc-hc not possible

@aicynide
Copy link

Patiently waiting @tomasklaen

@aicynide
Copy link

Waiting

@christoph-heinrich
Copy link
Contributor

@aicynide Stop being annoying, just use the script from po5's comment.

@tomasklaen
Copy link
Owner

People can now paste paths or URLs into:

  • File menu to open them immediately.
  • Track menus (audio, video, subtitles) to add as new track and activate it.
  • Playlist menu to add to playlist.

I think this covers most of the pasting/input needs.

@hooke007
Copy link
Contributor

image
I think you forget to handle the special characters.

@tomasklaen
Copy link
Owner

Could you give me name of the file with those special characters so I can test?

I'm retrieving the clipboard data from ziggy binary. I guess somewhere in the clipboard read->serialize->output->deserialize chain they're getting escaped or dropped.

@hooke007
Copy link
Contributor

Any filename which contains space.

@tomasklaen
Copy link
Owner

tomasklaen commented Aug 31, 2024

I don't have issue with spaces in file names. Also, you can see the whole filename including spaces in the screenshot you posted, so that seems to not be an issue.

And dunno what the Invalid argument could mean. Pasting in a path/url results in the standard:

mp.commandv('loadfile', value)

In other words: can't reproduce. Are you sure the file exists and is valid?

@hooke007
Copy link
Contributor

hooke007 commented Aug 31, 2024

C:\Users\hooke007\Videos\[VCB-Studio] Fate stay night Unlimited Blade Works [24][Ma10p_1080p][x265_flac].mkv

If I delete all space in the original filename, it will work.
image

@tomasklaen
Copy link
Owner

tomasklaen commented Aug 31, 2024

I used your name with spaced, and again, no issues for me. No idea what might be going on here.

What menu are you pasting it into?

@hooke007
Copy link
Contributor

I got some clues.
I build the same dirs in Disk D and copy the file. Now it could read this file.

D:\Users\hooke007\Videos\[VCB-Studio] Fate stay night Unlimited Blade Works [24][Ma10p_1080p][x265_flac].mkv

What menu are you pasting it into?

Filebrowser

@hooke007
Copy link
Contributor

hooke007 commented Aug 31, 2024

I got some clues.

Now I confirmed that any file in my disk C which use space in the filename can not be read correctly.

I also confirmed manually input command loadfile ``path2file`` work in the console. So it might not be the bug from mpv.

@tomasklaen
Copy link
Owner

You can try debugging it yourself. The code that is opening the file is in file lib/menus.lua at line 738:

mp.commandv(command, event.value)

Try adding this before it and checking if there's something unusual:

print(utils.to_string(command), utils.to_string(event.value))

@hooke007
Copy link
Contributor

Try adding this before it and checking if there's something unusual

Cannot found any difference with the actual filename.

@hooke007
Copy link
Contributor

Hmm, Sorry for wasting a little time for both of us. I think that was a 'ghost' bug for windows.
I reboot my PC and then everything works fine...😂

@aicynide
Copy link

aicynide commented Sep 8, 2024

People can now paste paths or URLs into:

  • File menu to open them immediately.
  • Track menus (audio, video, subtitles) to add as new track and activate it.
  • Playlist menu to add to playlist.

I think this covers most of the pasting/input needs.

writing URL?

@aicynide
Copy link

aicynide commented Sep 8, 2024

Like this

image

@hooke007
Copy link
Contributor

hooke007 commented Sep 9, 2024

Like this

You prefer to waste time type in each word one by one instead of pasting in one second?

@aicynide
Copy link

aicynide commented Sep 9, 2024

Like this

You prefer to waste time type in each word one by one instead of pasting in one second?

well VLC has this feature, I'll write shortener i.e. shortened URL or add password in pasted URL

@hooke007
Copy link
Contributor

hooke007 commented Sep 9, 2024

add password in pasted URL.

Not sure if mpv natively support it.
mpv-player/mpv#1512 (comment)
So far it seems only smb's password is supported in mpv.

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

8 participants
@cipricus @christoph-heinrich @hooke007 @po5 @tomasklaen @alexpandain @aicynide and others