├── LICENSE.md ├── README.md ├── bin └── mpvhandler.exe ├── install.bat ├── src └── mpvhandler.c └── uninstall.bat /LICENSE.md: -------------------------------------------------------------------------------- 1 | 2 | The MIT License (MIT) 3 | 4 | Copyright (c) 2019 XENK 5 | 6 | Permission is hereby granted, free of charge, to any person obtaining a copy 7 | of this software and associated documentation files (the "Software"), to deal 8 | in the Software without restriction, including without limitation the rights 9 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | copies of the Software, and to permit persons to whom the Software is 11 | furnished to do so, subject to the following conditions: 12 | 13 | The above copyright notice and this permission notice shall be included in all 14 | copies or substantial portions of the Software. 15 | 16 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 22 | SOFTWARE. 23 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # MPV Button 2 | 3 | **MPV Button is a handler between mpv [URI scheme](https://en.wikipedia.org/wiki/Uniform_Resource_Identifier) and [mpv player](https://mpv.io)** 4 | 5 | ## Usage and Examples 6 | You can doing things like: 7 | - Autostart watch movie from link 8 | `mpv://https://somewebsite.com/uploads/movie.mp4` 9 | 10 | ![example1](https://puu.sh/DZPGE/ee53244ea6.gif) 11 | 12 | - Watch YouTube videos 13 | `mpv://https://www.youtube.com/watch?v=q7cf3QXwdoA` 14 | 15 | ![example2](https://puu.sh/DZPGS/aff8efc245.gif) 16 | 17 | **Note: for youtube videos you will be need download [youtube_dl](https://ytdl-org.github.io/youtube-dl/download.html) and put it in the same directory where your MPV is installed** 18 | 19 | ## Installation 20 | 1. Install [MPV](https://sourceforge.net/projects/mpv-player-windows/files/latest/download) 21 | 2. Add directory with mpv to [%PATH%](https://www.java.com/en/download/help/path.xml) 22 | 3. Run in console 23 | ``` 24 | $ git clone https://github.com/XENKing/mpvbutton 25 | $ cd mpvbutton 26 | $ start install.bat 27 | ``` 28 | -------------------------------------------------------------------------------- /bin/mpvhandler.exe: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/xenking/mpvbutton/479c366d6b7ccf215e1f84dd0512c722d8df6551/bin/mpvhandler.exe -------------------------------------------------------------------------------- /install.bat: -------------------------------------------------------------------------------- 1 | @echo off 2 | reg add "HKCR\mpv" /v "URL Protocol" /f 3 | reg add "HKCR\mpv\shell\open\command" /d "%~dp0bin\mpvhandler %%1" /f 4 | set pathkey="HKEY_LOCAL_MACHINE\System\CurrentControlSet\Control\Session Manager\Environment" 5 | for /F "usebackq skip=2 tokens=2*" %%A IN (`reg query %pathkey% /v Path`) do (reg add %pathkey% /f /v Path /t REG_SZ /d "%%B;%~dp0bin") -------------------------------------------------------------------------------- /src/mpvhandler.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | 5 | char *str_replace(char *orig, char *rep, char *with) { 6 | char *result; 7 | char *ins; 8 | char *tmp; 9 | int len_rep; 10 | int len_with; 11 | int len_front; 12 | int count; 13 | 14 | if (!orig || !rep) 15 | return NULL; 16 | len_rep = strlen(rep); 17 | if (len_rep == 0) 18 | return NULL; 19 | if (!with) 20 | with = ""; 21 | len_with = strlen(with); 22 | 23 | ins = orig; 24 | for (count = 0; tmp = strstr(ins, rep); ++count) { 25 | ins = tmp + len_rep; 26 | } 27 | 28 | tmp = result = malloc(strlen(orig) + (len_with - len_rep) * count + 1); 29 | 30 | if (!result) 31 | return NULL; 32 | 33 | ins = strstr(orig, rep); 34 | len_front = ins - orig; 35 | tmp = strncpy(tmp, orig, len_front) + len_front; 36 | tmp = strcpy(tmp, with) + len_with; 37 | orig += len_front + len_rep; 38 | strcpy(tmp, orig); 39 | return result; 40 | } 41 | 42 | int WinMain(_In_ HINSTANCE hInstance, _In_opt_ HINSTANCE hPrevInstance, _In_ LPSTR lpCmdLine, _In_ int nShowCmd) 43 | { 44 | if (lpCmdLine == NULL) 45 | return -1; 46 | char *str = str_replace(lpCmdLine, "://", " "); 47 | if (str == NULL){ 48 | return -1; 49 | } 50 | if(strstr(str,"--")){ 51 | char *str1 = str_replace(str,"--", " --"); 52 | if(str1 != NULL) 53 | str = str1; 54 | } 55 | 56 | printf("%s", str); 57 | STARTUPINFO si = {0}; 58 | PROCESS_INFORMATION pi = {0}; 59 | si.cb = sizeof(si); 60 | CreateProcessA(NULL, str, NULL, NULL, TRUE, 0, NULL, NULL, &si, &pi); 61 | return 0; 62 | } 63 | -------------------------------------------------------------------------------- /uninstall.bat: -------------------------------------------------------------------------------- 1 | @echo off 2 | reg delete "HKCR\mpv" /f 3 | 4 | --------------------------------------------------------------------------------