├── .gitignore ├── README.md ├── mpv.reg ├── play-in-mpv.js ├── playinmpv.cpp ├── playinmpv.sln ├── playinmpv.vcxproj ├── playinmpv.vcxproj.filters └── playinmpv_gcc.cpp /.gitignore: -------------------------------------------------------------------------------- 1 | ## Ignore Visual Studio temporary files, build results, and 2 | ## files generated by popular Visual Studio add-ons. 3 | ## 4 | ## Get latest from https://github.com/github/gitignore/blob/master/VisualStudio.gitignore 5 | 6 | # User-specific files 7 | *.rsuser 8 | *.suo 9 | *.user 10 | *.userosscache 11 | *.sln.docstates 12 | 13 | # User-specific files (MonoDevelop/Xamarin Studio) 14 | *.userprefs 15 | 16 | # Mono auto generated files 17 | mono_crash.* 18 | 19 | # Build results 20 | [Dd]ebug/ 21 | [Dd]ebugPublic/ 22 | [Rr]elease/ 23 | [Rr]eleases/ 24 | x64/ 25 | x86/ 26 | [Aa][Rr][Mm]/ 27 | [Aa][Rr][Mm]64/ 28 | bld/ 29 | [Bb]in/ 30 | [Oo]bj/ 31 | [Ll]og/ 32 | [Ll]ogs/ 33 | 34 | # Visual Studio 2015/2017 cache/options directory 35 | .vs/ 36 | # Uncomment if you have tasks that create the project's static files in wwwroot 37 | #wwwroot/ 38 | 39 | # Visual Studio 2017 auto generated files 40 | Generated\ Files/ 41 | 42 | # MSTest test Results 43 | [Tt]est[Rr]esult*/ 44 | [Bb]uild[Ll]og.* 45 | 46 | # NUnit 47 | *.VisualState.xml 48 | TestResult.xml 49 | nunit-*.xml 50 | 51 | # Build Results of an ATL Project 52 | [Dd]ebugPS/ 53 | [Rr]eleasePS/ 54 | dlldata.c 55 | 56 | # Benchmark Results 57 | BenchmarkDotNet.Artifacts/ 58 | 59 | # .NET Core 60 | project.lock.json 61 | project.fragment.lock.json 62 | artifacts/ 63 | 64 | # StyleCop 65 | StyleCopReport.xml 66 | 67 | # Files built by Visual Studio 68 | *_i.c 69 | *_p.c 70 | *_h.h 71 | *.ilk 72 | *.meta 73 | *.obj 74 | *.iobj 75 | *.pch 76 | *.pdb 77 | *.ipdb 78 | *.pgc 79 | *.pgd 80 | *.rsp 81 | *.sbr 82 | *.tlb 83 | *.tli 84 | *.tlh 85 | *.tmp 86 | *.tmp_proj 87 | *_wpftmp.csproj 88 | *.log 89 | *.vspscc 90 | *.vssscc 91 | .builds 92 | *.pidb 93 | *.svclog 94 | *.scc 95 | 96 | # Chutzpah Test files 97 | _Chutzpah* 98 | 99 | # Visual C++ cache files 100 | ipch/ 101 | *.aps 102 | *.ncb 103 | *.opendb 104 | *.opensdf 105 | *.sdf 106 | *.cachefile 107 | *.VC.db 108 | *.VC.VC.opendb 109 | 110 | # Visual Studio profiler 111 | *.psess 112 | *.vsp 113 | *.vspx 114 | *.sap 115 | 116 | # Visual Studio Trace Files 117 | *.e2e 118 | 119 | # TFS 2012 Local Workspace 120 | $tf/ 121 | 122 | # Guidance Automation Toolkit 123 | *.gpState 124 | 125 | # ReSharper is a .NET coding add-in 126 | _ReSharper*/ 127 | *.[Rr]e[Ss]harper 128 | *.DotSettings.user 129 | 130 | # TeamCity is a build add-in 131 | _TeamCity* 132 | 133 | # DotCover is a Code Coverage Tool 134 | *.dotCover 135 | 136 | # AxoCover is a Code Coverage Tool 137 | .axoCover/* 138 | !.axoCover/settings.json 139 | 140 | # Visual Studio code coverage results 141 | *.coverage 142 | *.coveragexml 143 | 144 | # NCrunch 145 | _NCrunch_* 146 | .*crunch*.local.xml 147 | nCrunchTemp_* 148 | 149 | # MightyMoose 150 | *.mm.* 151 | AutoTest.Net/ 152 | 153 | # Web workbench (sass) 154 | .sass-cache/ 155 | 156 | # Installshield output folder 157 | [Ee]xpress/ 158 | 159 | # DocProject is a documentation generator add-in 160 | DocProject/buildhelp/ 161 | DocProject/Help/*.HxT 162 | DocProject/Help/*.HxC 163 | DocProject/Help/*.hhc 164 | DocProject/Help/*.hhk 165 | DocProject/Help/*.hhp 166 | DocProject/Help/Html2 167 | DocProject/Help/html 168 | 169 | # Click-Once directory 170 | publish/ 171 | 172 | # Publish Web Output 173 | *.[Pp]ublish.xml 174 | *.azurePubxml 175 | # Note: Comment the next line if you want to checkin your web deploy settings, 176 | # but database connection strings (with potential passwords) will be unencrypted 177 | *.pubxml 178 | *.publishproj 179 | 180 | # Microsoft Azure Web App publish settings. Comment the next line if you want to 181 | # checkin your Azure Web App publish settings, but sensitive information contained 182 | # in these scripts will be unencrypted 183 | PublishScripts/ 184 | 185 | # NuGet Packages 186 | *.nupkg 187 | # NuGet Symbol Packages 188 | *.snupkg 189 | # The packages folder can be ignored because of Package Restore 190 | **/[Pp]ackages/* 191 | # except build/, which is used as an MSBuild target. 192 | !**/[Pp]ackages/build/ 193 | # Uncomment if necessary however generally it will be regenerated when needed 194 | #!**/[Pp]ackages/repositories.config 195 | # NuGet v3's project.json files produces more ignorable files 196 | *.nuget.props 197 | *.nuget.targets 198 | 199 | # Microsoft Azure Build Output 200 | csx/ 201 | *.build.csdef 202 | 203 | # Microsoft Azure Emulator 204 | ecf/ 205 | rcf/ 206 | 207 | # Windows Store app package directories and files 208 | AppPackages/ 209 | BundleArtifacts/ 210 | Package.StoreAssociation.xml 211 | _pkginfo.txt 212 | *.appx 213 | *.appxbundle 214 | *.appxupload 215 | 216 | # Visual Studio cache files 217 | # files ending in .cache can be ignored 218 | *.[Cc]ache 219 | # but keep track of directories ending in .cache 220 | !?*.[Cc]ache/ 221 | 222 | # Others 223 | ClientBin/ 224 | ~$* 225 | *~ 226 | *.dbmdl 227 | *.dbproj.schemaview 228 | *.jfm 229 | *.pfx 230 | *.publishsettings 231 | orleans.codegen.cs 232 | 233 | # Including strong name files can present a security risk 234 | # (https://github.com/github/gitignore/pull/2483#issue-259490424) 235 | #*.snk 236 | 237 | # Since there are multiple workflows, uncomment next line to ignore bower_components 238 | # (https://github.com/github/gitignore/pull/1529#issuecomment-104372622) 239 | #bower_components/ 240 | 241 | # RIA/Silverlight projects 242 | Generated_Code/ 243 | 244 | # Backup & report files from converting an old project file 245 | # to a newer Visual Studio version. Backup files are not needed, 246 | # because we have git ;-) 247 | _UpgradeReport_Files/ 248 | Backup*/ 249 | UpgradeLog*.XML 250 | UpgradeLog*.htm 251 | ServiceFabricBackup/ 252 | *.rptproj.bak 253 | 254 | # SQL Server files 255 | *.mdf 256 | *.ldf 257 | *.ndf 258 | 259 | # Business Intelligence projects 260 | *.rdl.data 261 | *.bim.layout 262 | *.bim_*.settings 263 | *.rptproj.rsuser 264 | *- [Bb]ackup.rdl 265 | *- [Bb]ackup ([0-9]).rdl 266 | *- [Bb]ackup ([0-9][0-9]).rdl 267 | 268 | # Microsoft Fakes 269 | FakesAssemblies/ 270 | 271 | # GhostDoc plugin setting file 272 | *.GhostDoc.xml 273 | 274 | # Node.js Tools for Visual Studio 275 | .ntvs_analysis.dat 276 | node_modules/ 277 | 278 | # Visual Studio 6 build log 279 | *.plg 280 | 281 | # Visual Studio 6 workspace options file 282 | *.opt 283 | 284 | # Visual Studio 6 auto-generated workspace file (contains which files were open etc.) 285 | *.vbw 286 | 287 | # Visual Studio LightSwitch build output 288 | **/*.HTMLClient/GeneratedArtifacts 289 | **/*.DesktopClient/GeneratedArtifacts 290 | **/*.DesktopClient/ModelManifest.xml 291 | **/*.Server/GeneratedArtifacts 292 | **/*.Server/ModelManifest.xml 293 | _Pvt_Extensions 294 | 295 | # Paket dependency manager 296 | .paket/paket.exe 297 | paket-files/ 298 | 299 | # FAKE - F# Make 300 | .fake/ 301 | 302 | # CodeRush personal settings 303 | .cr/personal 304 | 305 | # Python Tools for Visual Studio (PTVS) 306 | __pycache__/ 307 | *.pyc 308 | 309 | # Cake - Uncomment if you are using it 310 | # tools/** 311 | # !tools/packages.config 312 | 313 | # Tabs Studio 314 | *.tss 315 | 316 | # Telerik's JustMock configuration file 317 | *.jmconfig 318 | 319 | # BizTalk build output 320 | *.btp.cs 321 | *.btm.cs 322 | *.odx.cs 323 | *.xsd.cs 324 | 325 | # OpenCover UI analysis results 326 | OpenCover/ 327 | 328 | # Azure Stream Analytics local run output 329 | ASALocalRun/ 330 | 331 | # MSBuild Binary and Structured Log 332 | *.binlog 333 | 334 | # NVidia Nsight GPU debugger configuration file 335 | *.nvuser 336 | 337 | # MFractors (Xamarin productivity tool) working folder 338 | .mfractor/ 339 | 340 | # Local History for Visual Studio 341 | .localhistory/ 342 | 343 | # BeatPulse healthcheck temp database 344 | healthchecksdb 345 | 346 | # Backup folder for Package Reference Convert tool in Visual Studio 2017 347 | MigrationBackup/ 348 | 349 | # Ionide (cross platform F# VS Code tools) working folder 350 | .ionide/ 351 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Bilibili-Playin-Mpv 2 | [![下载量](https://img.shields.io/github/downloads/diannaojiang/Bilibili-Playin-Mpv/total?label=%E4%B8%8B%E8%BD%BD%E9%87%8F)](https://tooomm.github.io/github-release-stats/?username=diannaojiang&repository=Bilibili-Playin-Mpv) 3 | ------------ 4 | 5 | 本项目旨在基于[Bilibili-Evolved](https://github.com/the1812/Bilibili-Evolved "Bilibili-Evolved")提供在本地播放器MPV中在线播放Bilibili视频的功能。 6 | 7 | 视频播放地址API随[Bilibili-Evolved](https://github.com/the1812/Bilibili-Evolved "Bilibili-Evolved")进行更新,使用Application URL的方式调用本地程序,进行参数转换后唤起mpv播放器进行播放。 8 | 9 | ------------ 10 | 11 | ## 编译 12 | 13 | - 用VS2022编译,其他版本的也应该可以 14 | 15 | ## 食用指南 16 | 17 | - 运行前确保系统已安装[Visual C++ 2022 Redistributable (x64)](https://aka.ms/vs/17/release/vc_redist.x64.exe)或[Visual C++ 2022 Redistributable (x86)](https://aka.ms/vs/17/release/vc_redist.x86.exe) 18 | - 下载[最新发行版](https://github.com/diannaojiang/Bilibili-Playin-Mpv/releases "最新发行版")并解压 19 | - 将**playinmpv.exe**放置到MPV安装目录中的**mpv.exe**程序同目录 20 | - 修改**mpv.reg**中的目录信息为你的MPV所在目录 21 | ```bash 22 | Windows Registry Editor Version 5.00 23 | 24 | [HKEY_CLASSES_ROOT\mpv] 25 | "URL Protocol"="" 26 | 27 | [HKEY_CLASSES_ROOT\mpv\DefaultIcon] 28 | @="你的MPV安装目录\\mpv.exe,1" 29 | 30 | [HKEY_CLASSES_ROOT\mpv\shell] 31 | 32 | [HKEY_CLASSES_ROOT\mpv\shell\open] 33 | @="" 34 | 35 | [HKEY_CLASSES_ROOT\mpv\shell\open\command] 36 | @="\"你的MPV安装目录\\playinmpv.exe\" \"%1\"" 37 | 38 | 39 | ``` 40 | 41 | 42 | - 双击运行**mpv.reg**导入注册表 43 | - 在[Bilibili-Evolved](https://github.com/the1812/Bilibili-Evolved "Bilibili-Evolved")中使用:**设置-插件-添加插件-在线**添加**MPV 输出支持** 44 | - 在视频页左侧呼出[Bilibili-Evolved](https://github.com/the1812/Bilibili-Evolved "Bilibili-Evolved")**-功能-下载视频** 45 | - 请注意使用时**格式**要选用**Dash-h.265或h.264或AV1** 46 | - **输出方式选择MPV**后点击开始屏幕左下方会弹出播放按钮,再次点击后即可呼出本地播放器进行播放 47 | 48 | 49 | ## Linux食用指南 50 | 51 | - 运行前确保系统已安装**xdg-open** 52 | - 下载[最新发行版](https://github.com/diannaojiang/Bilibili-Playin-Mpv/releases "最新发行版")并解压 53 | - 将压缩包解压后放置于你想将本程序安装到的位置 请确保你拥有所放置目录的权限 54 | - 运行install.sh 55 | - 在[Bilibili-Evolved](https://github.com/the1812/Bilibili-Evolved "Bilibili-Evolved")中使用:**设置-插件-添加插件-在线**添加**MPV 输出支持** 56 | - 在视频页左侧呼出[Bilibili-Evolved](https://github.com/the1812/Bilibili-Evolved "Bilibili-Evolved")**-功能-下载视频** 57 | - 请注意使用时**格式**要选用**Dash-h.265或h.264或AV1** 58 | - **输出方式选择MPV**后点击开始屏幕左下方会弹出播放按钮,再次点击后即可呼出本地播放器进行播放 59 | -------------------------------------------------------------------------------- /mpv.reg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/diannaojiang/Bilibili-Playin-Mpv/04a6f02b3ecbf22f1673be0cfe8a893c90d2672c/mpv.reg -------------------------------------------------------------------------------- /play-in-mpv.js: -------------------------------------------------------------------------------- 1 | !function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t():"function"==typeof define&&define.amd?define([],t):"object"==typeof exports?exports["video/play-in-mpv"]=t():e["video/play-in-mpv"]=t()}(self,(function(){return function(){var e={335:function(e,t,n){var i=n(645)((function(e){return e[1]}));i.push([e.id,".play-mpv-panel {\n font-size: 12px;\n top: 100px;\n left: 50%;\n transform: translateX(-50%) scale(0.95);\n transition: 0.2s ease-out;\n z-index: 1000;\n width: 320px;\n display: flex;\n flex-direction: column;\n align-items: flex-start;\n padding: 12px;\n background-color: #fff;\n color: black;\n border-radius: 8px;\n box-shadow: 0 4px 12px 0 rgba(0, 0, 0, 0.05);\n border: 1px solid rgba(136,136,136,0.13333);\n box-sizing: border-box;\n}\nbody.dark .play-mpv-panel {\n background-color: #282828;\n color: #eee;\n box-shadow: 0 4px 12px 0 rgba(0, 0, 0, 0.2);\n}\n.play-mpv-panel.open {\n transform: translateX(-50%);\n}\n.play-mpv-panel > :not(:first-child) {\n margin-top: 12px;\n}\n.play-mpv-panel .be-textbox,\n.play-mpv-panel .be-textarea {\n flex-grow: 1;\n}\n.play-mpv-panel-header {\n display: flex;\n align-items: center;\n grid-gap: 0;\n gap: 0;\n align-self: stretch;\n}\n.play-mpv-panel-header .title {\n font-size: 16px;\n font-weight: bold;\n flex-grow: 1;\n margin: 0 8px;\n}\n.play-mpv-panel-header .be-button {\n padding: 4px;\n}\n.play-mpv-panel .play-mpv-config-item {\n display: flex;\n align-items: center;\n grid-gap: 0;\n gap: 0;\n}\n.play-mpv-panel .play-mpv-config-item .play-mpv-config-title {\n margin-right: 8px;\n}\n.play-mpv-panel .play-mpv-config-item.error {\n color: #E57373;\n}\n.play-mpv-panel .play-mpv-config-section {\n align-self: stretch;\n}\n.play-mpv-panel .play-mpv-config-description {\n opacity: 0.5;\n margin-top: 4px;\n}\n.play-mpv-panel-footer {\n align-self: stretch;\n justify-content: center;\n display: flex;\n align-items: center;\n grid-gap: 0;\n gap: 0;\n}\n.play-mpv-panel .run-download {\n font-size: 13px;\n padding: 6px 12px;\n}",""]),e.exports=i},482:function(e,t,n){var i=n(645)((function(e){return e[1]}));i.push([e.id,".episodes-picker-header {\n display: flex;\n align-items: center;\n grid-gap: 0;\n gap: 0;\n}\n.episodes-picker-checked-ratio {\n flex-grow: 1;\n margin-left: 4px;\n}\n.episodes-picker-actions {\n display: flex;\n align-items: center;\n grid-gap: 0;\n gap: 0;\n}\n.episodes-picker-actions .be-button {\n padding: 4px;\n}\n.episodes-picker-actions .be-button.invert-selection .be-icon {\n font-size: 14px;\n}\n.episodes-picker-actions .be-button.select-all .be-icon, .episodes-picker-actions .be-button.deselect-all .be-icon {\n transform: translateY(1px);\n}\n.episodes-picker-items {\n max-height: 400px;\n overflow: auto;\n}\n.episodes-picker-items:not(:empty) {\n margin-top: 4px;\n border: 1px solid rgba(136,136,136,0.26667);\n border-radius: 6px;\n}\n.episodes-picker-items .be-check-box {\n padding: 2px 6px;\n}\n.episodes-picker-items .episode-duration {\n margin-right: 4px;\n text-align: right;\n flex: 1 1 0;\n opacity: 0.5;\n}",""]),e.exports=i},677:function(e,t,n){var i=n(645)((function(e){return e[1]}));i.push([e.id,".single-video-info.play-mpv-config-section {\n height: 125px;\n display: flex;\n align-items: center;\n justify-content: center;\n}\n.single-video-info.play-mpv-config-section img {\n height: 125px;\n -o-object-fit: contain;\n object-fit: contain;\n border-radius: 8px;\n}\n.single-video-info.play-mpv-config-section img.shadow {\n position: absolute;\n filter: blur(8px) brightness(0.8);\n transform: scaleY(0.95) translateY(4px);\n z-index: -1;\n opacity: 0.3;\n}",""]),e.exports=i},645:function(e){"use strict"; 2 | // eslint-disable-next-line func-names 3 | e.exports=function(e){var t=[];return t.toString=function(){return this.map((function(t){var n=e(t);return t[2]?"@media ".concat(t[2]," {").concat(n,"}"):n})).join("")}, 4 | // eslint-disable-next-line func-names 5 | t.i=function(e,n,i){"string"==typeof e&&( 6 | // eslint-disable-next-line no-param-reassign 7 | e=[[null,e,""]]);var s={};if(i)for(var a=0;a({episodeItems:[],maxCheckedItems:32,lastCheckedEpisodeIndex:-1}),computed:{checkedRatio(){return`(${this.episodeItems.filter((e=>e.isChecked)).length}/${this.episodeItems.length})`},inputItems(){return this.episodeItems.map((e=>e.inputItem))},checkedInputItems(){return this.episodeItems.filter((e=>e.isChecked)).map((e=>e.inputItem))}},created(){this.getEpisodeItems()},methods:{shiftSelect(e,t,n){e.shiftKey&&-1!==this.lastCheckedEpisodeIndex?e.shiftKey&&-1!==this.lastCheckedEpisodeIndex&&(this.episodeItems.slice(Math.min(this.lastCheckedEpisodeIndex,n)+1,Math.max(this.lastCheckedEpisodeIndex,n)).forEach((e=>{e.isChecked=!e.isChecked})),this.lastCheckedEpisodeIndex=n,e.preventDefault()):this.lastCheckedEpisodeIndex=n},forEachItem(e){this.episodeItems.forEach(e)},async getEpisodeItems(){this.episodeItems.length>0||(this.episodeItems=await this.api(this))}}}),g=n(379),y=n.n(g),b=n(482),x=n.n(b),_={insert:"head",singleton:!1},w=(y()(x(),_),x().locals,n(900)),I=(0,w.Z)(v,h,[],!1,null,null,null);I.options.__file="registry/lib/components/video/play-in-mpv/inputs/EpisodesPicker.vue";var k=I.exports;const C=e=>Vue.extend({computed:{checkedInputItems(){return this.$refs.picker.checkedInputItems}},render:t=>t(k,{props:{api:e},ref:"picker"})}),V={name:"bangumi.batch",displayName:"当前番剧 (多P)",match:m.bangumiUrls,getInputs:async e=>e?.checkedInputItems??[],component:async()=>C((async e=>{const t=document.querySelector("meta[property='og:url']");if(null===t)return(0,o.logError)("获取番剧数据失败: 无法找到 Season ID"),[];const n=t.getAttribute("content")?.match(/play\/ss(\d+)/)?.[1];if(void 0===n)return(0,o.logError)("获取番剧数据失败: 无法解析 Season ID"),[];const i=await(0,u.getJson)(`https://api.bilibili.com/pgc/web/season/section?season_id=${n}`);if(0!==i.code)return(0,o.logError)(`获取番剧数据失败: 无法获取番剧集数列表, message=${i.message}`),[];const a=i.result.main_section.episodes;return a.map(((t,n)=>{const i=t.long_title?t.title:(n+1).toString(),o=t.long_title?t.long_title:t.title;return{key:t.cid,title:`${i} - ${o}`,isChecked:ne?.checkedInputItems??[],component:async()=>C((async e=>{const{aid:t}=unsafeWindow,n=`https://api.bilibili.com/x/web-interface/view?aid=${t}`,i=await(0,u.getJson)(n);if(0!==i.code)return(0,o.logError)(`获取视频选集列表失败, message = ${i.message}`),[];const{pages:a}=i.data;return void 0===a?((0,o.logError)("获取视频选集列表失败, 没有找到选集信息."),[]):a.map(((n,i)=>({key:n.cid,title:`P${n.page} ${n.part}`,isChecked:i[{aid:unsafeWindow.aid,cid:unsafeWindow.cid,title:(0,f.getFriendlyTitle)(!0)}],component:()=>Promise.resolve().then(n.bind(n,477)).then((e=>e.default))};var D=coreApis.utils.sort;const S=(e,t)=>{e.quality&&t.currentQuality.value!==e.quality.value&&(e.allowQualityDrop?console.warn(`'${e.title}' 不支持选择的清晰度${e.quality.displayName}, 已降级为${t.currentQuality.displayName}`):(e=>{if(p.vipRequiredQualities.find((t=>t.value===e)))throw new Error("您选择的清晰度需要大会员, 请更改清晰度后重试.");if(p.loginRequiredQualities.find((t=>t.value===e)))throw new Error("您选择的清晰度需要先登录.");throw new Error("获取下载链接失败, 请尝试更换清晰度或更换格式.")})(e.quality.value))};var $=coreApis.download;function M(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}class O{constructor(e){M(this,"input",void 0),M(this,"fragments",void 0),M(this,"qualities",void 0),M(this,"currentQuality",void 0),M(this,"jsonData",void 0),Object.assign(this,e)}get totalSize(){return lodash.sumBy(this.fragments,(e=>e.size))}get totalLength(){return lodash.sumBy(this.fragments,(e=>e.length))}get titledFragments(){return this.fragments.map(((e,t)=>{const n=this.fragments.filter((t=>t.extension===e.extension)).length>1?` - ${(0,r.formatNumber)(t+1,this.fragments.length)}`:"";return{...e,title:`${this.input.title}${n}${e.extension}`}}))}}class q{constructor(e){this.infos=e,M(this,"inputs",[]),M(this,"extraAssets",[]),this.inputs=e.map((e=>e.input))}get isSingleVideo(){return this.inputs.length<2}async downloadExtraAssets(){console.log("[downloadExtraAssets]",this.extraAssets);const e=`${(0,f.getFriendlyTitle)(!1)}.zip`;await new $.DownloadPackage(this.extraAssets).emit(e)}} 13 | /* spell-checker: disable */ 14 | const P={video:".mp4",audio:".m4a"},Q=e=>({url:e.downloadUrl,backupUrls:e.backupUrls,length:e.duration,size:Math.trunc(e.bandWidth*e.duration/8),extension:P[e.type]??".m4s"}),T=async(e,t)=>{const{codec:n="AVC/H.264",filters:i}=t,s={video:()=>!0,audio:()=>!0,...i},{aid:o,cid:r,quality:l}=e,c={avid:o,cid:r,qn:l?.value??"",otype:"json",fourk:1,fnver:0,fnval:2e3},d=`https://api.bilibili.com/x/player/playurl?${(0,a.formData)(c)}`,f=await(0,u.bilibiliApi)((0,u.getJsonWithCredentials)(d),"获取视频链接失败");if(!f.dash)throw new Error("此视频没有 dash 格式, 请改用其他格式.");const m=p.allQualities.find((e=>e.value===f.quality)),{duration:h,video:v,audio:g}=f.dash,y=v.filter((e=>e.id===m.value)).map((e=>{const t=(()=>{switch(e.codecid){case 12:return"HEVC/H.265";default:case 7:return"AVC/H.264"}})();return{type:"video",quality:m,width:e.width,height:e.height,codecs:e.codecs,codecId:e.codecid,bandWidth:e.bandwidth,frameRate:e.frameRate,backupUrls:(e.backupUrl||e.backup_url||[]).map((e=>e.replace("http:","https:"))),downloadUrl:(e.baseUrl||e.base_url||"").replace("http:","https:"),duration:h,videoCodec:t}})).filter((e=>s.video(e))),b=(e=>{const{videoDashes:t,audioDashes:n,videoCodec:i}=e,s=[];if(0!==t.length){const e=e=>e.videoCodec===i;if(t.some(e)){const n=t.filter(e).sort((0,D.ascendingSort)((e=>e.bandWidth)))[0];s.push(Q(n))}else s.push(Q(t.sort((0,D.ascendingSort)((e=>e.bandWidth)))[0]))}if(0!==n.length){const e=n.sort((0,D.descendingSort)((e=>e.bandWidth)))[0];s.push(Q(e))}return s})({audioDashes:(g||[]).map((e=>({type:"audio",bandWidth:e.bandwidth,codecs:e.codecs,codecId:e.codecid,backupUrls:(e.backupUrl||e.backup_url||[]).map((e=>e.replace("http:","https:"))),downloadUrl:(e.baseUrl||e.base_url||"").replace("http:","https:"),duration:h}))).filter((e=>s.audio(e))),videoDashes:y,videoCodec:n}),x=f.accept_quality.map((e=>p.allQualities.find((t=>t.value===e)))).filter((e=>void 0!==e)),_=new O({input:e,jsonData:f,fragments:b,qualities:x,currentQuality:m});return S(e,_),_},j={name:"video.dash.avc",displayName:"dash (AVC/H.264)",description:"音画分离的 mp4 格式, 编码为 H.264, 兼容性较好. 下载后可以合并为单个 mp4 文件.",playMpvInfo:async e=>T(e,{codec:"AVC/H.264"})},U={name:"video.dash.hevc",displayName:"dash (HEVC/H.265)",description:"音画分离的 mp4 格式, 编码为 H.265, 体积较小, 兼容性较差. 下载后可以合并为单个 mp4 文件.",playMpvInfo:async e=>T(e,{codec:"HEVC/H.265"})},N={name:"video.dash.audio",displayName:"dash (仅音频)",description:"仅MPV播放中的音频轨道.",playMpvInfo:async e=>T(e,{filters:{video:()=>!1}})},z=(e,t)=>{const n=e=>t.length>e?t[e]:t[t.length-1];return{fragments:e.durl.map(((e,t)=>({length:e.length,size:e.size,url:e.url,backupUrls:e.backup_url,extension:n(t)}))),qualities:e.accept_quality.map((e=>p.allQualities.find((t=>t.value===e)))).filter((e=>void 0!==e)),currentQuality:p.allQualities.find((t=>t.value===e.quality))}},W={name:"video.flv",displayName:"flv",description:"使用 flv 格式下载, 兼容 H.264 编码.",playMpvInfo:async e=>{const{aid:t,cid:n,quality:i}=e,s={avid:t,cid:n,qn:i?.value??"",otype:"json",fourk:1,fnver:0,fnval:0},o=`https://api.bilibili.com/x/player/playurl?${(0,a.formData)(s)}`,r=await(0,u.bilibiliApi)((0,u.getJsonWithCredentials)(o),"获取视频链接失败"),l=new O({input:e,jsonData:r,...z(r,[".flv"])});return S(e,l),l}},B={name:"consoleLogDemo",displayName:"Toast",description:"弹一条消息显示出播放按钮,点击即可使用MPV进行播放",runAction:async e=>{const t=e.infos.flatMap((e=>e.titledFragments)),n=t.map((e=>e.url)).join("\n"),i='mpv://--http-header-fields="referer:https://www.bilibili.com/" "'+t[0].url+'" --audio-file="'+t[1].url+'"';console.log(i),d.Toast.show(`播放`,"MPV播放"),console.log(n),console.log(e)}},[F]=(0,c.registerAndGetData)("playMpv.inputs",[E,A,V]),[H]=(0,c.registerAndGetData)("playMpv.apis",[W,j,U,N]),[R]=(0,c.registerAndGetData)("playMpv.assets",[]),[G]=(0,c.registerAndGetData)("playMpv.outputs",[B]),{basicConfig:L}=(0,s.getComponentSettings)("playMpv").options;var J=Vue.extend({components:{VPopup:l.VPopup,VButton:l.VButton,VDropdown:l.VDropdown,VIcon:l.VIcon},props:{triggerElement:{required:!0}},data(){const e=L.api,t=L.output;return{open:!1,busy:!1,testData:{videoInfo:null,multiple:!1},assets:R,qualities:[],selectedQuality:void 0,inputs:[],selectedInput:void 0,apis:H,selectedApi:H.find((t=>t.name===e))||H[0],outputs:G,selectedOutput:G.find((e=>e.name===t))||G[0]}},computed:{assetsWithOptions(){return this.assets.filter((e=>e.component))},filteredQualities(){return 0===this.qualities.length?p.allQualities:this.qualities},canStartDownload(){if(this.busy||!this.open)return!1;return!Object.entries(this).filter((([e])=>e.startsWith("selected"))).some((([,e])=>!e))}},watch:{selectedInput(e){void 0!==e&&this.updateTestVideoInfo()},selectedApi(e){void 0!==e&&(this.updateTestVideoInfo(),L.api=e.name)},selectedOutput(e){void 0!==e&&(L.output=e.name)}},mounted(){coreApis.observer.videoChange((()=>{const e=F.filter((e=>e.match?.some((e=>(0,a.matchUrlPattern)(e)))??!0));this.inputs=e,this.selectedInput=e[0]}))},methods:{formatFileSize:r.formatFileSize,saveSelectedQuality(){const e=this.selectedQuality;void 0!==e&&(L.quality=e.value,this.updateTestVideoInfo())},async getVideoItems(){const e=this.selectedInput;return await e.getInputs(this.$refs.inputOptions)},async updateTestVideoInfo(){if(!this.selectedInput)return;this.testData.videoInfo=null;const e=await this.getVideoItems();console.log("[updateTestVideoInfo]",e),this.testData.multiple=e.length>1;const t=this.selectedApi,[n]=e;if(!this.selectedQuality){const e=await t.playMpvInfo(n);if(this.qualities=e.qualities,this.selectedQuality=e.qualities[0],L.quality){const[t]=e.qualities.filter((e=>e.value<=L.quality));t&&(this.selectedQuality=t)}}try{n.quality=this.selectedQuality;const e=await t.playMpvInfo(n);this.testData.videoInfo=e}catch(e){this.testData.videoInfo=void 0}},async startDownload(e,t){try{this.busy=!0;const n=this.selectedInput,i=this.selectedApi,s=await n.getInputs(this.$refs.inputOptions);if(0===s.length)return void d.Toast.info("未接收到视频, 如果输入源支持批量, 请至少选择一个视频.","MPV播放",3e3);s.forEach((e=>{e.quality=this.selectedQuality}));const a=await Promise.all(s.map((e=>i.playMpvInfo(e))));if(0===a.length||0===lodash.sumBy(a,(e=>e.fragments.length)))return void d.Toast.info("未接收到可下载数据, 请检查输入源和格式是否适用于当前视频.","MPV播放",3e3);const o=new q(a),r=(await Promise.all(R.map((e=>e.getAssets(a,this.$refs.assetsOptions.find((t=>t.$attrs.name===e.name))))))).flat();o.extraAssets.push(...r),await o.downloadExtraAssets(),await t.runAction(o,e)}catch(e){(0,o.logError)(e)}finally{this.busy=!1}}}}),Z=n(335),X=n.n(Z),Y={insert:"head",singleton:!1},K=(y()(X(),Y),X().locals,(0,w.Z)(J,i,[],!1,null,null,null));K.options.__file="registry/lib/components/video/play-in-mpv/PlayMpv.vue";var ee=K.exports},774:function(e,t,n){"use strict";n.r(t),n.d(t,{default:function(){return r}});var i=function(){var e=this,t=e.$createElement,n=e._self._c||t;return n("div",{staticClass:"multiple-widgets"},[n("DefaultWidget",{ref:"button",attrs:{name:"MPV播放",icon:"mdi-download"},on:{mouseover:function(t){return e.createDownloadPanel()},click:function(t){return e.toggleDownloadPanel()}}})],1)};let s;i._withStripped=!0;var a=Vue.extend({components:{DefaultWidget:coreApis.ui.DefaultWidget},methods:{async createDownloadPanel(){if(!s){const e=document.createElement("div");document.body.appendChild(e);const t=await Promise.resolve().then(n.bind(n,785)).then((e=>e.default));s=new t({propsData:{triggerElement:this.$refs.button}}).$mount(e)}},async toggleDownloadPanel(){s&&(s.open=!s.open)}}}),o=(0,n(900).Z)(a,i,[],!1,null,null,null);o.options.__file="registry/lib/components/video/play-in-mpv/Widget.vue";var r=o.exports},477:function(e,t,n){"use strict";n.r(t),n.d(t,{default:function(){return m}});var i=function(){var e=this,t=e.$createElement,n=e._self._c||t;return n("div",{staticClass:"single-video-info play-mpv-config-section"},[e.imageUrl?n("img",{staticClass:"shadow",attrs:{src:e.imageUrl}}):e._e(),e._v(" "),e.imageUrl?n("img",{attrs:{src:e.imageUrl}}):e._e()])};i._withStripped=!0;var s=coreApis.observer,a=n(729),o=coreApis.componentApis.video.videoInfo,r=Vue.extend({data:()=>({imageUrl:""}),created(){(0,s.videoChange)((async()=>{const{aid:e}=unsafeWindow,t=new o.VideoInfo(e);try{await t.fetchInfo()}catch(e){throw(0,a.logError)(e),e}this.imageUrl=t.coverUrl.replace("http:","https:")}))}}),l=n(379),c=n.n(l),p=n(677),d=n.n(p),u={insert:"head",singleton:!1},f=(c()(d(),u),d().locals,(0,n(900).Z)(r,i,[],!1,null,null,null));f.options.__file="registry/lib/components/video/play-in-mpv/inputs/video/SingleVideoInfo.vue";var m=f.exports},900:function(e,t,n){"use strict";function i(e,t,n,i,s,a,o,r){var l,c="function"==typeof e?e.options:e;if(t&&(c.render=t,c.staticRenderFns=n,c._compiled=!0),i&&(c.functional=!0),a&&(c._scopeId="data-v-"+a),o?(l=function(e){(e=e||this.$vnode&&this.$vnode.ssrContext||this.parent&&this.parent.$vnode&&this.parent.$vnode.ssrContext)||"undefined"==typeof __VUE_SSR_CONTEXT__||(e=__VUE_SSR_CONTEXT__),s&&s.call(this,e),e&&e._registeredComponents&&e._registeredComponents.add(o)},c._ssrRegister=l):s&&(l=r?function(){s.call(this,(c.functional?this.parent:this).$root.$options.shadowRoot)}:s),l)if(c.functional){c._injectStyles=l;var p=c.render;c.render=function(e,t){return l.call(t),p(e,t)}}else{var d=c.beforeCreate;c.beforeCreate=d?[].concat(d,l):[l]}return{exports:e,options:c}}n.d(t,{Z:function(){return i}})},729:function(e){"use strict";e.exports=coreApis.utils.log}},t={};function n(i){var s=t[i];if(void 0!==s)return s.exports;var a=t[i]={id:i,exports:{}};return e[i](a,a.exports,n),a.exports}n.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return n.d(t,{a:t}),t},n.d=function(e,t){for(var i in t)n.o(t,i)&&!n.o(e,i)&&Object.defineProperty(e,i,{enumerable:!0,get:t[i]})},n.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},n.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})};var i={};return function(){"use strict";n.d(i,{component:function(){return t}});var e=coreApis.spinQuery;const t={name:"playMpv",displayName:"MPV播放",description:"在功能面板中添加MPV播放支持.",entry:none,reload:none,unload:none,widget:{component:()=>Promise.resolve().then(n.bind(n,774)).then((e=>e.default)),condition:()=>(0,e.hasVideo)()},tags:[componentsTags.video],options:{basicConfig:{defaultValue:{},displayName:"基础配置",hidden:!0}},commitHash:"41ffbb0d55bf86d980dffedad09e4387181ce57d"}}(),i=i.component}()})); -------------------------------------------------------------------------------- /playinmpv.cpp: -------------------------------------------------------------------------------- 1 | // playinmpv.cpp : 此文件包含 "main" 函数。程序执行将在此处开始并结束。 2 | // 3 | 4 | #include 5 | #include 6 | #include 7 | #include 8 | #include 9 | #include 10 | using namespace std; 11 | 12 | unsigned char ToHex(unsigned char x) 13 | { 14 | return x > 9 ? x + 55 : x + 48; 15 | } 16 | 17 | unsigned char FromHex(unsigned char x) 18 | { 19 | unsigned char y; 20 | if (x >= 'A' && x <= 'Z') y = x - 'A' + 10; 21 | else if (x >= 'a' && x <= 'z') y = x - 'a' + 10; 22 | else if (x >= '0' && x <= '9') y = x - '0'; 23 | else assert(0); 24 | return y; 25 | } 26 | 27 | std::string UrlEncode(const std::string& str) 28 | { 29 | std::string strTemp = ""; 30 | size_t length = str.length(); 31 | for (size_t i = 0; i < length; i++) 32 | { 33 | if (isalnum((unsigned char)str[i]) || 34 | (str[i] == '-') || 35 | (str[i] == '_') || 36 | (str[i] == '.') || 37 | (str[i] == '~')) 38 | strTemp += str[i]; 39 | else if (str[i] == ' ') 40 | strTemp += "+"; 41 | else 42 | { 43 | strTemp += '%'; 44 | strTemp += ToHex((unsigned char)str[i] >> 4); 45 | strTemp += ToHex((unsigned char)str[i] % 16); 46 | } 47 | } 48 | return strTemp; 49 | } 50 | 51 | std::string UrlDecode(const std::string& str) 52 | { 53 | std::string strTemp = ""; 54 | size_t length = str.length(); 55 | for (size_t i = 0; i < length; i++) 56 | { 57 | if (str[i] == '+') strTemp += ' '; 58 | else if (str[i] == '%') 59 | { 60 | assert(i + 2 < length); 61 | unsigned char high = FromHex((unsigned char)str[++i]); 62 | unsigned char low = FromHex((unsigned char)str[++i]); 63 | strTemp += high * 16 + low; 64 | } 65 | else strTemp += str[i]; 66 | } 67 | return strTemp; 68 | } 69 | 70 | std::string GetMpvPlayerPathFromRegistry() 71 | { 72 | HKEY hKey; 73 | LPCWSTR subKey = L"mpv\\DefaultIcon"; 74 | std::wstring valueBuffer(MAX_PATH, '\0'); 75 | DWORD bufferSize = MAX_PATH; 76 | 77 | if (RegOpenKeyExW(HKEY_CLASSES_ROOT, subKey, 0, KEY_READ, &hKey) == ERROR_SUCCESS) 78 | { 79 | // Read the default value from the subkey 80 | RegQueryValueExW(hKey, NULL, NULL, NULL, reinterpret_cast(&valueBuffer[0]), &bufferSize); 81 | RegCloseKey(hKey); 82 | 83 | // Extract the path from the value 84 | std::wstring value = valueBuffer.substr(0, valueBuffer.find_first_of(L',')); 85 | return std::wstring_convert>{}.to_bytes(value); 86 | } 87 | 88 | return ""; 89 | } 90 | 91 | int main(int argc, char* argv[]) 92 | { 93 | std::string mpvPlayerPath = GetMpvPlayerPathFromRegistry(); 94 | 95 | string cmd; 96 | if (argc < 2) 97 | { 98 | std::cout << "can't get value" << endl; 99 | Sleep(1000 * 10); 100 | } 101 | else { 102 | cmd = argv[1]; 103 | std::cout << "输入url:" << endl; 104 | std::cout << cmd <“开始执行(不调试)”菜单 156 | // 调试程序: F5 或调试 >“开始调试”菜单 157 | 158 | // 入门使用技巧: 159 | // 1. 使用解决方案资源管理器窗口添加/管理文件 160 | // 2. 使用团队资源管理器窗口连接到源代码管理 161 | // 3. 使用输出窗口查看生成输出和其他消息 162 | // 4. 使用错误列表窗口查看错误 163 | // 5. 转到“项目”>“添加新项”以创建新的代码文件,或转到“项目”>“添加现有项”以将现有代码文件添加到项目 164 | // 6. 将来,若要再次打开此项目,请转到“文件”>“打开”>“项目”并选择 .sln 文件 165 | -------------------------------------------------------------------------------- /playinmpv.sln: -------------------------------------------------------------------------------- 1 |  2 | Microsoft Visual Studio Solution File, Format Version 12.00 3 | # Visual Studio Version 17 4 | VisualStudioVersion = 17.1.31911.260 5 | MinimumVisualStudioVersion = 10.0.40219.1 6 | Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "playinmpv", "playinmpv.vcxproj", "{B0891FA5-48A5-4BFC-8899-BF8D01AB5F24}" 7 | EndProject 8 | Global 9 | GlobalSection(SolutionConfigurationPlatforms) = preSolution 10 | Debug|ARM64 = Debug|ARM64 11 | Debug|x64 = Debug|x64 12 | Debug|x86 = Debug|x86 13 | Release|ARM64 = Release|ARM64 14 | Release|x64 = Release|x64 15 | Release|x86 = Release|x86 16 | EndGlobalSection 17 | GlobalSection(ProjectConfigurationPlatforms) = postSolution 18 | {B0891FA5-48A5-4BFC-8899-BF8D01AB5F24}.Debug|ARM64.ActiveCfg = Debug|ARM64 19 | {B0891FA5-48A5-4BFC-8899-BF8D01AB5F24}.Debug|ARM64.Build.0 = Debug|ARM64 20 | {B0891FA5-48A5-4BFC-8899-BF8D01AB5F24}.Debug|x64.ActiveCfg = Debug|x64 21 | {B0891FA5-48A5-4BFC-8899-BF8D01AB5F24}.Debug|x64.Build.0 = Debug|x64 22 | {B0891FA5-48A5-4BFC-8899-BF8D01AB5F24}.Debug|x86.ActiveCfg = Debug|Win32 23 | {B0891FA5-48A5-4BFC-8899-BF8D01AB5F24}.Debug|x86.Build.0 = Debug|Win32 24 | {B0891FA5-48A5-4BFC-8899-BF8D01AB5F24}.Release|ARM64.ActiveCfg = Release|ARM64 25 | {B0891FA5-48A5-4BFC-8899-BF8D01AB5F24}.Release|ARM64.Build.0 = Release|ARM64 26 | {B0891FA5-48A5-4BFC-8899-BF8D01AB5F24}.Release|x64.ActiveCfg = Release|x64 27 | {B0891FA5-48A5-4BFC-8899-BF8D01AB5F24}.Release|x64.Build.0 = Release|x64 28 | {B0891FA5-48A5-4BFC-8899-BF8D01AB5F24}.Release|x86.ActiveCfg = Release|Win32 29 | {B0891FA5-48A5-4BFC-8899-BF8D01AB5F24}.Release|x86.Build.0 = Release|Win32 30 | EndGlobalSection 31 | GlobalSection(SolutionProperties) = preSolution 32 | HideSolutionNode = FALSE 33 | EndGlobalSection 34 | GlobalSection(ExtensibilityGlobals) = postSolution 35 | SolutionGuid = {CBC1A3BD-029A-4090-83EF-B9B38202133E} 36 | EndGlobalSection 37 | EndGlobal 38 | -------------------------------------------------------------------------------- /playinmpv.vcxproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | Debug 6 | ARM64 7 | 8 | 9 | Debug 10 | Win32 11 | 12 | 13 | Release 14 | ARM64 15 | 16 | 17 | Release 18 | Win32 19 | 20 | 21 | Debug 22 | x64 23 | 24 | 25 | Release 26 | x64 27 | 28 | 29 | 30 | 16.0 31 | Win32Proj 32 | {b0891fa5-48a5-4bfc-8899-bf8d01ab5f24} 33 | playinmpv 34 | 10.0 35 | 36 | 37 | 38 | Application 39 | true 40 | v143 41 | Unicode 42 | 43 | 44 | Application 45 | true 46 | v143 47 | Unicode 48 | 49 | 50 | Application 51 | false 52 | v143 53 | true 54 | Unicode 55 | 56 | 57 | Application 58 | false 59 | v143 60 | true 61 | Unicode 62 | 63 | 64 | Application 65 | true 66 | v143 67 | Unicode 68 | 69 | 70 | Application 71 | false 72 | v143 73 | true 74 | Unicode 75 | 76 | 77 | 78 | 79 | 80 | 81 | 82 | 83 | 84 | 85 | 86 | 87 | 88 | 89 | 90 | 91 | 92 | 93 | 94 | 95 | 96 | 97 | 98 | 99 | 100 | 101 | true 102 | 103 | 104 | true 105 | 106 | 107 | false 108 | 109 | 110 | false 111 | 112 | 113 | true 114 | 115 | 116 | false 117 | 118 | 119 | 120 | Level3 121 | true 122 | WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions) 123 | true 124 | 125 | 126 | Console 127 | true 128 | 129 | 130 | 131 | 132 | Level3 133 | true 134 | WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions) 135 | true 136 | 137 | 138 | Console 139 | true 140 | 141 | 142 | 143 | 144 | Level3 145 | true 146 | true 147 | true 148 | WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions) 149 | true 150 | 151 | 152 | Console 153 | true 154 | true 155 | true 156 | 157 | 158 | 159 | 160 | Level3 161 | true 162 | true 163 | true 164 | WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions) 165 | true 166 | 167 | 168 | Console 169 | true 170 | true 171 | true 172 | 173 | 174 | 175 | 176 | Level3 177 | true 178 | _DEBUG;_CONSOLE;%(PreprocessorDefinitions) 179 | true 180 | 181 | 182 | Console 183 | true 184 | 185 | 186 | 187 | 188 | Level3 189 | true 190 | true 191 | true 192 | NDEBUG;_CONSOLE;%(PreprocessorDefinitions) 193 | true 194 | 195 | 196 | Console 197 | true 198 | true 199 | true 200 | 201 | 202 | 203 | 204 | 205 | 206 | 207 | 208 | -------------------------------------------------------------------------------- /playinmpv.vcxproj.filters: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | {4FC737F1-C7A5-4376-A066-2A32D752A2FF} 6 | cpp;c;cc;cxx;c++;cppm;ixx;def;odl;idl;hpj;bat;asm;asmx 7 | 8 | 9 | {93995380-89BD-4b04-88EB-625FBE52EBFB} 10 | h;hh;hpp;hxx;h++;hm;inl;inc;ipp;xsd 11 | 12 | 13 | {67DA6AB6-F800-4c08-8B7A-83BB121AAD01} 14 | rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms 15 | 16 | 17 | 18 | 19 | 源文件 20 | 21 | 22 | -------------------------------------------------------------------------------- /playinmpv_gcc.cpp: -------------------------------------------------------------------------------- 1 | // playinmpv.cpp : 此文件包含 "main" 函数。程序执行将在此处开始并结束。 2 | // 3 | 4 | #include 5 | //#include 6 | #include 7 | #include 8 | #include 9 | #include 10 | using namespace std; 11 | 12 | unsigned char ToHex(unsigned char x) 13 | { 14 | return x > 9 ? x + 55 : x + 48; 15 | } 16 | 17 | unsigned char FromHex(unsigned char x) 18 | { 19 | unsigned char y; 20 | if (x >= 'A' && x <= 'Z') y = x - 'A' + 10; 21 | else if (x >= 'a' && x <= 'z') y = x - 'a' + 10; 22 | else if (x >= '0' && x <= '9') y = x - '0'; 23 | else assert(0); 24 | return y; 25 | } 26 | 27 | std::string UrlEncode(const std::string& str) 28 | { 29 | std::string strTemp = ""; 30 | size_t length = str.length(); 31 | for (size_t i = 0; i < length; i++) 32 | { 33 | if (isalnum((unsigned char)str[i]) || 34 | (str[i] == '-') || 35 | (str[i] == '_') || 36 | (str[i] == '.') || 37 | (str[i] == '~')) 38 | strTemp += str[i]; 39 | else if (str[i] == ' ') 40 | strTemp += "+"; 41 | else 42 | { 43 | strTemp += '%'; 44 | strTemp += ToHex((unsigned char)str[i] >> 4); 45 | strTemp += ToHex((unsigned char)str[i] % 16); 46 | } 47 | } 48 | return strTemp; 49 | } 50 | 51 | std::string UrlDecode(const std::string& str) 52 | { 53 | std::string strTemp = ""; 54 | size_t length = str.length(); 55 | for (size_t i = 0; i < length; i++) 56 | { 57 | if (str[i] == '+') strTemp += ' '; 58 | else if (str[i] == '%') 59 | { 60 | assert(i + 2 < length); 61 | unsigned char high = FromHex((unsigned char)str[++i]); 62 | unsigned char low = FromHex((unsigned char)str[++i]); 63 | strTemp += high * 16 + low; 64 | } 65 | else strTemp += str[i]; 66 | } 67 | return strTemp; 68 | } 69 | 70 | int main(int argc, char* argv[]) 71 | { 72 | string cmd; 73 | if (argc < 2) 74 | { 75 | std::cout << "can't get value" << endl; 76 | sleep(1000 * 10); 77 | } 78 | else { 79 | cmd = argv[1]; 80 | std::cout << "输入url:" << endl; 81 | std::cout << cmd <“开始执行(不调试)”菜单 104 | // 调试程序: F5 或调试 >“开始调试”菜单 105 | 106 | // 入门使用技巧: 107 | // 1. 使用解决方案资源管理器窗口添加/管理文件 108 | // 2. 使用团队资源管理器窗口连接到源代码管理 109 | // 3. 使用输出窗口查看生成输出和其他消息 110 | // 4. 使用错误列表窗口查看错误 111 | // 5. 转到“项目”>“添加新项”以创建新的代码文件,或转到“项目”>“添加现有项”以将现有代码文件添加到项目 112 | // 6. 将来,若要再次打开此项目,请转到“文件”>“打开”>“项目”并选择 .sln 文件 113 | --------------------------------------------------------------------------------