[
  {
    "path": ".gitattributes",
    "content": "/.gitattributes export-ignore\n*.bat           text eol=crlf\n*.ico           -text\n"
  },
  {
    "path": "COPYING",
    "content": "Copyright © 2015, James Ross-Gowan <rossymiles@gmail.com>\n\nPermission to use, copy, modify, and/or distribute this software for any\npurpose with or without fee is hereby granted, provided that the above\ncopyright notice and this permission notice appear in all copies.\n\nTHE SOFTWARE IS PROVIDED \"AS IS\" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH\nREGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND\nFITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,\nINDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM\nLOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR\nOTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR\nPERFORMANCE OF THIS SOFTWARE.\n"
  },
  {
    "path": "README.md",
    "content": "``mpv-install.bat`` <img src=\"https://rossy.github.io/mpv-install/mpv-document.png\" align=\"right\">\n===================\n\nThis script sets up file associations for [mpv][1] on Windows.\n\nHow to install\n--------------\n\n1. Make sure you have the latest build of mpv. Official builds are here:\n   https://mpv.srsfckn.biz/\n2. Download the zip: https://github.com/rossy/mpv-install/archive/master.zip\n   <br>\n   **Note:** Make sure you use the above link. Don't use GitHub's \"Raw\" links\n   on the files themselves, since these have incorrect line-endings, which\n   cause the script to crash. (See [#7][2].)\n3. Copy the .bat files and the .ico to the same directory as mpv.exe\n4. Run ``mpv-install.bat`` as administrator. **Note:** For an unattended\n   install, use the ``/u`` switch.\n5. Use the _Default Programs_ and _AutoPlay_ control panels to make mpv the\n   default player\n\nWhat it does\n------------\n\n- Creates file associations for several video and audio file types\n- Registers mpv with the _Default Programs_ control panel\n- Puts mpv in the \"Open with\" menu for all video and audio files\n- Registers mpv.exe so it can be used from the Run dialog and the Start Menu\n- Adds mpv as an AutoPlay handler for Blu-rays and DVDs\n- Works when reinstalled to a different folder than the one it was in\n  previously. (File associations created by the \"Open with\" menu have trouble\n  with this.)\n\nWhat it doesn't do\n------------------\n\n- Add mpv to the ``%PATH%``\n- Enable thumbnails for all media types (use [Icaros][3] for this)\n- Allow multiple files to be selected and opened as a playlist. This is harder\n  than it sounds and it can't be done with a simple script. As a workaround,\n  you can create a shortcut to mpv.exe in the \"Send to\" menu.\n\nHow to uninstall\n----------------\n\nTo remove all traces of this script from your computer, run\n``mpv-uninstall.bat`` as administrator.\n\n**Note:** This is not necessary if you want to reinstall mpv later (in a\ndifferent folder, for example,) only if you want to remove it completely. To\nreinstall, just run ``mpv-install.bat`` again.\n\nDisclaimer\n----------\n\nShould work on Windows Vista and up, tested with Windows Vista, 7, 8.1 and 10.\nThese scripts were written for personal use and released with the hope that\nthey would be useful, but without any warranty.\n\n[1]: https://mpv.io/\n[2]: https://github.com/rossy/mpv-install/issues/7\n[3]: http://www.majorgeeks.com/files/details/icaros.html\n"
  },
  {
    "path": "mpv-install.bat",
    "content": "@echo off\r\nsetlocal enableextensions enabledelayedexpansion\r\npath %SystemRoot%\\System32;%SystemRoot%;%SystemRoot%\\System32\\Wbem\r\n\r\n:: Unattended install flag. When set, the script will not require user input.\r\nset unattended=no\r\nif \"%1\"==\"/u\" set unattended=yes\r\n\r\n:: Make sure this is Windows Vista or later\r\ncall :ensure_vista\r\n\r\n:: Make sure the script is running as admin\r\ncall :ensure_admin\r\n\r\n:: Command line arguments to use when launching mpv from a file association\r\nset mpv_args=\r\n\r\n:: Get mpv.exe location\r\nset mpv_path=%~dp0mpv.exe\r\nif not exist \"%mpv_path%\" call :die \"mpv.exe not found\"\r\n\r\n:: Get mpv-document.ico location\r\nset icon_path=%~dp0mpv-document.ico\r\nif not exist \"%icon_path%\" call :die \"mpv-document.ico not found\"\r\n\r\n:: Register mpv.exe under the \"App Paths\" key, so it can be found by\r\n:: ShellExecute, the run command, the start menu, etc.\r\nset app_paths_key=HKLM\\SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\App Paths\\mpv.exe\r\ncall :reg add \"%app_paths_key%\" /d \"%mpv_path%\" /f\r\ncall :reg add \"%app_paths_key%\" /v \"UseUrl\" /t REG_DWORD /d 1 /f\r\n\r\n:: Register mpv.exe under the \"Applications\" key to add some default verbs for\r\n:: when mpv is used from the \"Open with\" menu\r\nset classes_root_key=HKLM\\SOFTWARE\\Classes\r\nset app_key=%classes_root_key%\\Applications\\mpv.exe\r\ncall :reg add \"%app_key%\" /v \"FriendlyAppName\" /d \"mpv\" /f\r\ncall :add_verbs \"%app_key%\"\r\n\r\n:: Add mpv to the \"Open with\" list for all video and audio file types\r\ncall :reg add \"%classes_root_key%\\SystemFileAssociations\\video\\OpenWithList\\mpv.exe\" /d \"\" /f\r\ncall :reg add \"%classes_root_key%\\SystemFileAssociations\\audio\\OpenWithList\\mpv.exe\" /d \"\" /f\r\n\r\n:: Add DVD AutoPlay handler\r\nset autoplay_key=HKLM\\SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Explorer\\AutoplayHandlers\r\ncall :reg add \"%classes_root_key%\\io.mpv.dvd\\shell\\play\" /d \"&Play\" /f\r\ncall :reg add \"%classes_root_key%\\io.mpv.dvd\\shell\\play\\command\" /d \"\\\"%mpv_path%\\\" %mpv_args% dvd:// --dvd-device=\\\"%%%%L\" /f\r\ncall :reg add \"%autoplay_key%\\Handlers\\MpvPlayDVDMovieOnArrival\" /v \"Action\" /d \"Play DVD movie\" /f\r\ncall :reg add \"%autoplay_key%\\Handlers\\MpvPlayDVDMovieOnArrival\" /v \"DefaultIcon\" /d \"%mpv_path%,0\" /f\r\ncall :reg add \"%autoplay_key%\\Handlers\\MpvPlayDVDMovieOnArrival\" /v \"InvokeProgID\" /d \"io.mpv.dvd\" /f\r\ncall :reg add \"%autoplay_key%\\Handlers\\MpvPlayDVDMovieOnArrival\" /v \"InvokeVerb\" /d \"play\" /f\r\ncall :reg add \"%autoplay_key%\\Handlers\\MpvPlayDVDMovieOnArrival\" /v \"Provider\" /d \"mpv\" /f\r\ncall :reg add \"%autoplay_key%\\EventHandlers\\PlayDVDMovieOnArrival\" /v \"MpvPlayDVDMovieOnArrival\" /f\r\n\r\n:: Add Blu-ray AutoPlay handler\r\ncall :reg add \"%classes_root_key%\\io.mpv.bluray\\shell\\play\" /d \"&Play\" /f\r\ncall :reg add \"%classes_root_key%\\io.mpv.bluray\\shell\\play\\command\" /d \"\\\"%mpv_path%\\\" %mpv_args% bd:// --bluray-device=\\\"%%%%L\" /f\r\ncall :reg add \"%autoplay_key%\\Handlers\\MpvPlayBluRayOnArrival\" /v \"Action\" /d \"Play Blu-ray movie\" /f\r\ncall :reg add \"%autoplay_key%\\Handlers\\MpvPlayBluRayOnArrival\" /v \"DefaultIcon\" /d \"%mpv_path%,0\" /f\r\ncall :reg add \"%autoplay_key%\\Handlers\\MpvPlayBluRayOnArrival\" /v \"InvokeProgID\" /d \"io.mpv.bluray\" /f\r\ncall :reg add \"%autoplay_key%\\Handlers\\MpvPlayBluRayOnArrival\" /v \"InvokeVerb\" /d \"play\" /f\r\ncall :reg add \"%autoplay_key%\\Handlers\\MpvPlayBluRayOnArrival\" /v \"Provider\" /d \"mpv\" /f\r\ncall :reg add \"%autoplay_key%\\EventHandlers\\PlayBluRayOnArrival\" /v \"MpvPlayBluRayOnArrival\" /f\r\n\r\n:: Add a capabilities key for mpv, which is registered later on for use in the\r\n:: \"Default Programs\" control panel\r\nset capabilities_key=HKLM\\SOFTWARE\\Clients\\Media\\mpv\\Capabilities\r\ncall :reg add \"%capabilities_key%\" /v \"ApplicationName\" /d \"mpv\" /f\r\ncall :reg add \"%capabilities_key%\" /v \"ApplicationDescription\" /d \"mpv media player\" /f\r\n\r\n:: Add file types\r\nset supported_types_key=%app_key%\\SupportedTypes\r\nset file_associations_key=%capabilities_key%\\FileAssociations\r\n:: DVD/Blu-ray audio formats\r\ncall :add_type \"audio/ac3\"                        \"audio\" \"AC-3 Audio\"                 \".ac3\" \".a52\"\r\ncall :add_type \"audio/eac3\"                       \"audio\" \"E-AC-3 Audio\"               \".eac3\"\r\ncall :add_type \"audio/vnd.dolby.mlp\"              \"audio\" \"MLP Audio\"                  \".mlp\"\r\ncall :add_type \"audio/vnd.dts\"                    \"audio\" \"DTS Audio\"                  \".dts\"\r\ncall :add_type \"audio/vnd.dts.hd\"                 \"audio\" \"DTS-HD Audio\"               \".dts-hd\" \".dtshd\"\r\ncall :add_type \"\"                                 \"audio\" \"TrueHD Audio\"               \".true-hd\" \".thd\" \".truehd\" \".thd+ac3\"\r\ncall :add_type \"\"                                 \"audio\" \"True Audio\"                 \".tta\"\r\n:: Uncompressed formats\r\ncall :add_type \"\"                                 \"audio\" \"PCM Audio\"                  \".pcm\"\r\ncall :add_type \"audio/wav\"                        \"audio\" \"Wave Audio\"                 \".wav\"\r\ncall :add_type \"audio/aiff\"                       \"audio\" \"AIFF Audio\"                 \".aiff\" \".aif\" \".aifc\"\r\ncall :add_type \"audio/amr\"                        \"audio\" \"AMR Audio\"                  \".amr\"\r\ncall :add_type \"audio/amr-wb\"                     \"audio\" \"AMR-WB Audio\"               \".awb\"\r\ncall :add_type \"audio/basic\"                      \"audio\" \"AU Audio\"                   \".au\" \".snd\"\r\ncall :add_type \"\"                                 \"audio\" \"Linear PCM Audio\"           \".lpcm\"\r\ncall :add_type \"\"                                 \"video\" \"Raw YUV Video\"              \".yuv\"\r\ncall :add_type \"\"                                 \"video\" \"YUV4MPEG2 Video\"            \".y4m\"\r\n:: Free lossless formats\r\ncall :add_type \"audio/x-ape\"                      \"audio\" \"Monkey's Audio\"             \".ape\"\r\ncall :add_type \"audio/x-wavpack\"                  \"audio\" \"WavPack Audio\"              \".wv\"\r\ncall :add_type \"audio/x-shorten\"                  \"audio\" \"Shorten Audio\"              \".shn\"\r\n:: MPEG formats\r\ncall :add_type \"video/vnd.dlna.mpeg-tts\"          \"video\" \"MPEG-2 Transport Stream\"    \".m2ts\" \".m2t\" \".mts\" \".mtv\" \".ts\" \".tsv\" \".tsa\" \".tts\" \".trp\"\r\ncall :add_type \"audio/vnd.dlna.adts\"              \"audio\" \"ADTS Audio\"                 \".adts\" \".adt\"\r\ncall :add_type \"audio/mpeg\"                       \"audio\" \"MPEG Audio\"                 \".mpa\" \".m1a\" \".m2a\" \".mp1\" \".mp2\"\r\ncall :add_type \"audio/mpeg\"                       \"audio\" \"MP3 Audio\"                  \".mp3\"\r\ncall :add_type \"video/mpeg\"                       \"video\" \"MPEG Video\"                 \".mpeg\" \".mpg\" \".mpe\" \".mpeg2\" \".m1v\" \".m2v\" \".mp2v\" \".mpv\" \".mpv2\" \".mod\" \".tod\"\r\ncall :add_type \"video/dvd\"                        \"video\" \"Video Object\"               \".vob\" \".vro\"\r\ncall :add_type \"\"                                 \"video\" \"Enhanced VOB\"               \".evob\" \".evo\"\r\ncall :add_type \"video/mp4\"                        \"video\" \"MPEG-4 Video\"               \".mpeg4\" \".m4v\" \".mp4\" \".mp4v\" \".mpg4\"\r\ncall :add_type \"audio/mp4\"                        \"audio\" \"MPEG-4 Audio\"               \".m4a\"\r\ncall :add_type \"audio/aac\"                        \"audio\" \"Raw AAC Audio\"              \".aac\"\r\ncall :add_type \"\"                                 \"video\" \"Raw H.264/AVC Video\"        \".h264\" \".avc\" \".x264\" \".264\"\r\ncall :add_type \"\"                                 \"video\" \"Raw H.265/HEVC Video\"       \".hevc\" \".h265\" \".x265\" \".265\"\r\n:: Xiph formats\r\ncall :add_type \"audio/flac\"                       \"audio\" \"FLAC Audio\"                 \".flac\"\r\ncall :add_type \"audio/ogg\"                        \"audio\" \"Ogg Audio\"                  \".oga\" \".ogg\"\r\ncall :add_type \"audio/ogg\"                        \"audio\" \"Opus Audio\"                 \".opus\"\r\ncall :add_type \"audio/ogg\"                        \"audio\" \"Speex Audio\"                \".spx\"\r\ncall :add_type \"video/ogg\"                        \"video\" \"Ogg Video\"                  \".ogv\" \".ogm\"\r\ncall :add_type \"application/ogg\"                  \"video\" \"Ogg Video\"                  \".ogx\"\r\n:: Matroska formats\r\ncall :add_type \"video/x-matroska\"                 \"video\" \"Matroska Video\"             \".mkv\"\r\ncall :add_type \"video/x-matroska\"                 \"video\" \"Matroska 3D Video\"          \".mk3d\"\r\ncall :add_type \"audio/x-matroska\"                 \"audio\" \"Matroska Audio\"             \".mka\"\r\ncall :add_type \"video/webm\"                       \"video\" \"WebM Video\"                 \".webm\"\r\ncall :add_type \"audio/webm\"                       \"audio\" \"WebM Audio\"                 \".weba\"\r\n:: Misc formats\r\ncall :add_type \"video/avi\"                        \"video\" \"Video Clip\"                 \".avi\" \".vfw\"\r\ncall :add_type \"\"                                 \"video\" \"DivX Video\"                 \".divx\"\r\ncall :add_type \"\"                                 \"video\" \"3ivx Video\"                 \".3iv\"\r\ncall :add_type \"\"                                 \"video\" \"XVID Video\"                 \".xvid\"\r\ncall :add_type \"\"                                 \"video\" \"NUT Video\"                  \".nut\"\r\ncall :add_type \"video/flc\"                        \"video\" \"FLIC Video\"                 \".flic\" \".fli\" \".flc\"\r\ncall :add_type \"\"                                 \"video\" \"Nullsoft Streaming Video\"   \".nsv\"\r\ncall :add_type \"application/gxf\"                  \"video\" \"General Exchange Format\"    \".gxf\"\r\ncall :add_type \"application/mxf\"                  \"video\" \"Material Exchange Format\"   \".mxf\"\r\n:: Windows Media formats\r\ncall :add_type \"audio/x-ms-wma\"                   \"audio\" \"Windows Media Audio\"        \".wma\"\r\ncall :add_type \"video/x-ms-wm\"                    \"video\" \"Windows Media Video\"        \".wm\"\r\ncall :add_type \"video/x-ms-wmv\"                   \"video\" \"Windows Media Video\"        \".wmv\"\r\ncall :add_type \"video/x-ms-asf\"                   \"video\" \"Windows Media Video\"        \".asf\"\r\ncall :add_type \"\"                                 \"video\" \"Microsoft Recorded TV Show\" \".dvr-ms\" \".dvr\"\r\ncall :add_type \"\"                                 \"video\" \"Windows Recorded TV Show\"   \".wtv\"\r\n:: DV formats\r\ncall :add_type \"\"                                 \"video\" \"DV Video\"                   \".dv\" \".hdv\"\r\n:: Flash Video formats\r\ncall :add_type \"video/x-flv\"                      \"video\" \"Flash Video\"                \".flv\"\r\ncall :add_type \"video/mp4\"                        \"video\" \"Flash Video\"                \".f4v\"\r\ncall :add_type \"audio/mp4\"                        \"audio\" \"Flash Audio\"                \".f4a\"\r\n:: QuickTime formats\r\ncall :add_type \"video/quicktime\"                  \"video\" \"QuickTime Video\"            \".qt\" \".mov\"\r\ncall :add_type \"video/quicktime\"                  \"video\" \"QuickTime HD Video\"         \".hdmov\"\r\n:: Real Media formats\r\ncall :add_type \"application/vnd.rn-realmedia\"     \"video\" \"Real Media Video\"           \".rm\"\r\ncall :add_type \"application/vnd.rn-realmedia-vbr\" \"video\" \"Real Media Video\"           \".rmvb\"\r\ncall :add_type \"audio/vnd.rn-realaudio\"           \"audio\" \"Real Media Audio\"           \".ra\" \".ram\"\r\n:: 3GPP formats\r\ncall :add_type \"audio/3gpp\"                       \"audio\" \"3GPP Audio\"                 \".3ga\"\r\ncall :add_type \"audio/3gpp2\"                      \"audio\" \"3GPP Audio\"                 \".3ga2\"\r\ncall :add_type \"video/3gpp\"                       \"video\" \"3GPP Video\"                 \".3gpp\" \".3gp\"\r\ncall :add_type \"video/3gpp2\"                      \"video\" \"3GPP Video\"                 \".3gp2\" \".3g2\"\r\n:: Video game formats\r\ncall :add_type \"\"                                 \"audio\" \"AY Audio\"                   \".ay\"\r\ncall :add_type \"\"                                 \"audio\" \"GBS Audio\"                  \".gbs\"\r\ncall :add_type \"\"                                 \"audio\" \"GYM Audio\"                  \".gym\"\r\ncall :add_type \"\"                                 \"audio\" \"HES Audio\"                  \".hes\"\r\ncall :add_type \"\"                                 \"audio\" \"KSS Audio\"                  \".kss\"\r\ncall :add_type \"\"                                 \"audio\" \"NSF Audio\"                  \".nsf\"\r\ncall :add_type \"\"                                 \"audio\" \"NSFE Audio\"                 \".nsfe\"\r\ncall :add_type \"\"                                 \"audio\" \"SAP Audio\"                  \".sap\"\r\ncall :add_type \"\"                                 \"audio\" \"SPC Audio\"                  \".spc\"\r\ncall :add_type \"\"                                 \"audio\" \"VGM Audio\"                  \".vgm\"\r\ncall :add_type \"\"                                 \"audio\" \"VGZ Audio\"                  \".vgz\"\r\n:: Playlist formats\r\ncall :add_type \"audio/x-mpegurl\"                  \"audio\" \"M3U Playlist\"               \".m3u\" \".m3u8\"\r\ncall :add_type \"audio/x-scpls\"                    \"audio\" \"PLS Playlist\"               \".pls\"\r\ncall :add_type \"\"                                 \"audio\" \"CUE Sheet\"                  \".cue\"\r\n\r\n:: Register \"Default Programs\" entry\r\ncall :reg add \"HKLM\\SOFTWARE\\RegisteredApplications\" /v \"mpv\" /d \"SOFTWARE\\Clients\\Media\\mpv\\Capabilities\" /f\r\n\r\necho.\r\necho Installed successfully^^! You can now configure mpv's file associations in the\r\necho Default Programs control panel.\r\necho.\r\nif [%unattended%] == [yes] exit 0\r\n<nul set /p =Press any key to open the Default Programs control panel . . .\r\npause >nul\r\ncontrol /name Microsoft.DefaultPrograms\r\nexit 0\r\n\r\n:die\r\n\tif not [%1] == [] echo %~1\r\n\tif [%unattended%] == [yes] exit 1\r\n\tpause\r\n\texit 1\r\n\r\n:ensure_admin\r\n\t:: 'openfiles' is just a commmand that is present on all supported Windows\r\n\t:: versions, requires admin privileges and has no side effects, see:\r\n\t:: https://stackoverflow.com/questions/4051883/batch-script-how-to-check-for-admin-rights\r\n\topenfiles >nul 2>&1\r\n\tif errorlevel 1 (\r\n\t\techo This batch script requires administrator privileges. Right-click on\r\n\t\techo mpv-install.bat and select \"Run as administrator\".\r\n\t\tcall :die\r\n\t)\r\n\tgoto :EOF\r\n\r\n:ensure_vista\r\n\tver | find \"XP\" >nul\r\n\tif not errorlevel 1 (\r\n\t\techo This batch script only works on Windows Vista and later. To create file\r\n\t\techo associations on Windows XP, right click on a video file and use \"Open with...\".\r\n\t\tcall :die\r\n\t)\r\n\tgoto :EOF\r\n\r\n:reg\r\n\t:: Wrap the reg command to check for errors\r\n\t>nul reg %*\r\n\tif errorlevel 1 set error=yes\r\n\tif [%error%] == [yes] echo Error in command: reg %*\r\n\tif [%error%] == [yes] call :die\r\n\tgoto :EOF\r\n\r\n:reg_set_opt\r\n\t:: Set a value in the registry if it doesn't already exist\r\n\tset key=%~1\r\n\tset value=%~2\r\n\tset data=%~3\r\n\r\n\treg query \"%key%\" /v \"%value%\" >nul 2>&1\r\n\tif errorlevel 1 call :reg add \"%key%\" /v \"%value%\" /d \"%data%\"\r\n\tgoto :EOF\r\n\r\n:add_verbs\r\n\tset key=%~1\r\n\r\n\t:: Set the default verb to \"play\"\r\n\tcall :reg add \"%key%\\shell\" /d \"play\" /f\r\n\r\n\t:: Hide the \"open\" verb from the context menu, since it's the same as \"play\"\r\n\tcall :reg add \"%key%\\shell\\open\" /v \"LegacyDisable\" /f\r\n\r\n\t:: Set open command\r\n\tcall :reg add \"%key%\\shell\\open\\command\" /d \"\\\"%mpv_path%\\\" %mpv_args% -- \\\"%%%%L\" /f\r\n\r\n\t:: Add \"play\" verb\r\n\tcall :reg add \"%key%\\shell\\play\" /d \"&Play\" /f\r\n\tcall :reg add \"%key%\\shell\\play\\command\" /d \"\\\"%mpv_path%\\\" %mpv_args% -- \\\"%%%%L\" /f\r\n\r\n\tgoto :EOF\r\n\r\n:add_progid\r\n\tset prog_id=%~1\r\n\tset friendly_name=%~2\r\n\r\n\t:: Add ProgId, edit flags are FTA_OpenIsSafe | FTA_AlwaysUseDirectInvoke\r\n\tset prog_id_key=%classes_root_key%\\%prog_id%\r\n\tcall :reg add \"%prog_id_key%\" /d \"%friendly_name%\" /f\r\n\tcall :reg add \"%prog_id_key%\" /v \"EditFlags\" /t REG_DWORD /d 4259840 /f\r\n\tcall :reg add \"%prog_id_key%\" /v \"FriendlyTypeName\" /d \"%friendly_name%\" /f\r\n\tcall :reg add \"%prog_id_key%\\DefaultIcon\" /d \"%icon_path%\" /f\r\n\tcall :add_verbs \"%prog_id_key%\"\r\n\r\n\tgoto :EOF\r\n\r\n:update_extension\r\n\tset extension=%~1\r\n\tset prog_id=%~2\r\n\tset mime_type=%~3\r\n\tset perceived_type=%~4\r\n\r\n\t:: Add information about the file extension, if not already present\r\n\tset extension_key=%classes_root_key%\\%extension%\r\n\tif not [%mime_type%] == [] call :reg_set_opt \"%extension_key%\" \"Content Type\" \"%mime_type%\"\r\n\tif not [%perceived_type%] == [] call :reg_set_opt \"%extension_key%\" \"PerceivedType\" \"%perceived_type%\"\r\n\tcall :reg add \"%extension_key%\\OpenWithProgIds\" /v \"%prog_id%\" /f\r\n\r\n\t:: Add type to SupportedTypes\r\n\tcall :reg add \"%supported_types_key%\" /v \"%extension%\" /f\r\n\r\n\t:: Add type to the Default Programs control panel\r\n\tcall :reg add \"%file_associations_key%\" /v \"%extension%\" /d \"%prog_id%\" /f\r\n\r\n\tgoto :EOF\r\n\r\n:add_type\r\n\tset mime_type=%~1\r\n\tset perceived_type=%~2\r\n\tset friendly_name=%~3\r\n\tset extension=%~4\r\n\r\n\techo Adding \"%extension%\" file type\r\n\r\n\t:: Add ProgId\r\n\tset prog_id=io.mpv%extension%\r\n\tcall :add_progid \"%prog_id%\" \"%friendly_name%\"\r\n\r\n\t:: Add extensions\r\n\t:extension_loop\r\n\t\tcall :update_extension \"%extension%\" \"%prog_id%\" \"%mime_type%\" \"%perceived_type%\"\r\n\r\n\t\t:: Trailing parameters are additional extensions\r\n\t\tshift /4\r\n\t\tset extension=%~4\r\n\t\tif not [%extension%] == [] goto extension_loop\r\n\r\n\tgoto :EOF\r\n"
  },
  {
    "path": "mpv-uninstall.bat",
    "content": "@echo off\r\nsetlocal enableextensions enabledelayedexpansion\r\npath %SystemRoot%\\System32;%SystemRoot%;%SystemRoot%\\System32\\Wbem\r\n\r\n:: Unattended install flag. When set, the script will not require user input.\r\nset unattended=no\r\nif \"%1\"==\"/u\" set unattended=yes\r\n\r\n:: Make sure the script is running as admin\r\ncall :ensure_admin\r\n\r\n:: Delete \"App Paths\" entry\r\nreg delete \"HKLM\\SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\App Paths\\mpv.exe\" /f >nul\r\n\r\n:: Delete HKCR subkeys\r\nset classes_root_key=HKLM\\SOFTWARE\\Classes\r\nreg delete \"%classes_root_key%\\Applications\\mpv.exe\" /f >nul\r\nreg delete \"%classes_root_key%\\SystemFileAssociations\\video\\OpenWithList\\mpv.exe\" /f >nul\r\nreg delete \"%classes_root_key%\\SystemFileAssociations\\audio\\OpenWithList\\mpv.exe\" /f >nul\r\n\r\n:: Delete AutoPlay handlers\r\nset autoplay_key=HKLM\\SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Explorer\\AutoplayHandlers\r\nreg delete \"%autoplay_key%\\Handlers\\MpvPlayDVDMovieOnArrival\" /f >nul\r\nreg delete \"%autoplay_key%\\EventHandlers\\PlayDVDMovieOnArrival\" /v \"MpvPlayDVDMovieOnArrival\" /f >nul\r\nreg delete \"%autoplay_key%\\Handlers\\MpvPlayBluRayOnArrival\" /f >nul\r\nreg delete \"%autoplay_key%\\EventHandlers\\PlayBluRayOnArrival\" /v \"MpvPlayBluRayOnArrival\" /f >nul\r\n\r\n:: Delete \"Default Programs\" entry\r\nreg delete \"HKLM\\SOFTWARE\\RegisteredApplications\" /v \"mpv\" /f >nul\r\nreg delete \"HKLM\\SOFTWARE\\Clients\\Media\\mpv\\Capabilities\" /f >nul\r\n\r\n:: Delete all OpenWithProgIds referencing ProgIds that start with io.mpv.\r\nfor /f \"usebackq eol= delims=\" %%k in (`reg query \"%classes_root_key%\" /f \"io.mpv.*\" /s /v /c`) do (\r\n\tset \"key=%%k\"\r\n\techo !key!| findstr /r /i \"^HKEY_LOCAL_MACHINE\\\\SOFTWARE\\\\Classes\\\\\\.[^\\\\][^\\\\]*\\\\OpenWithProgIds$\" >nul\r\n\tif not errorlevel 1 (\r\n\t\tfor /f \"usebackq eol= tokens=1\" %%v in (`reg query \"!key!\" /f \"io.mpv.*\" /v /c`) do (\r\n\t\t\tset \"value=%%v\"\r\n\t\t\techo !value!| findstr /r /i \"^io\\.mpv\\.[^\\\\][^\\\\]*$\" >nul\r\n\t\t\tif not errorlevel 1 (\r\n\t\t\t\techo Deleting !key!\\!value!\r\n\t\t\t\treg delete \"!key!\" /v \"!value!\" /f >nul\r\n\t\t\t)\r\n\t\t)\r\n\t)\r\n)\r\n\r\n:: Delete all ProgIds starting with io.mpv.\r\nfor /f \"usebackq eol= delims=\" %%k in (`reg query \"%classes_root_key%\" /f \"io.mpv.*\" /k /c`) do (\r\n\tset \"key=%%k\"\r\n\techo !key!| findstr /r /i \"^HKEY_LOCAL_MACHINE\\\\SOFTWARE\\\\Classes\\\\io\\.mpv\\.[^\\\\][^\\\\]*$\" >nul\r\n\tif not errorlevel 1 (\r\n\t\techo Deleting !key!\r\n\t\treg delete \"!key!\" /f >nul\r\n\t)\r\n)\r\n\r\necho Uninstalled successfully\r\nif [%unattended%] == [yes] exit 0\r\npause\r\nexit 0\r\n\r\n:die\r\n\tif not [%1] == [] echo %~1\r\n\tif [%unattended%] == [yes] exit 1\r\n\tpause\r\n\texit 1\r\n\r\n:ensure_admin\r\n\t:: 'openfiles' is just a commmand that is present on all supported Windows\r\n\t:: versions, requires admin privileges and has no side effects, see:\r\n\t:: https://stackoverflow.com/questions/4051883/batch-script-how-to-check-for-admin-rights\r\n\topenfiles >nul 2>&1\r\n\tif errorlevel 1 (\r\n\t\techo This batch script requires administrator privileges. Right-click on\r\n\t\techo mpv-uninstall.bat and select \"Run as administrator\".\r\n\t\tcall :die\r\n\t)\r\n\tgoto :EOF\r\n"
  }
]