huanxiong 发表于 2022-4-10 17:29

PHP调用逍遥一仙m3u8下载器下载部分失败

本帖最后由 huanxiong 于 2022-4-10 17:38 编辑

求大佬指点{:301_975:}

刚学习PHP,拿某讯课堂练手
已经可以获取到课程名称和视频m3u8的地址,整理成类似这样
[
    {
      "title":"截面法",
      "url":[
            "https://1258712167.vod2.myqcloud.com/5a81e359vodtranssh1258712167/e6800d125285890813737225495/drm/voddrm.token.dWluPTIyMzUxMTMxOTY7c2tleT07cHNrZXk9O3Bsc2tleT0wMDA0MDAwMDYyOGQ0ZjI0ZDhkNTZjYTZlM2Y2NGIwMDgxZjE4MGM1YTViODcxNmNiMTdmNjA5ZjNmMzRlMTlhMmEyZTE2ZjY5ZGFiMTFhYmU5MWRjODBlO2V4dD07dWlkX3R5cGU9MDt1aWRfb3JpZ2luX3VpZF90eXBlPTA7dWlkX29yaWdpbl9hdXRoX3R5cGU9MDtjaWQ9NDQyNTgxO3Rlcm1faWQ9MTAyMTMwMjYyO3ZvZF90eXBlPTA=.v.f30742.m3u8?t=625D29C4&exper=0&us=2029940670762813336&sign=fba547a53891c5855635df83805a9470",
            "https://1258712167.vod2.myqcloud.com/5a81e359vodtranssh1258712167/e6800d125285890813737225495/drm/voddrm.token.dWluPTIyMzUxMTMxOTY7c2tleT07cHNrZXk9O3Bsc2tleT0wMDA0MDAwMDYyOGQ0ZjI0ZDhkNTZjYTZlM2Y2NGIwMDgxZjE4MGM1YTViODcxNmNiMTdmNjA5ZjNmMzRlMTlhMmEyZTE2ZjY5ZGFiMTFhYmU5MWRjODBlO2V4dD07dWlkX3R5cGU9MDt1aWRfb3JpZ2luX3VpZF90eXBlPTA7dWlkX29yaWdpbl9hdXRoX3R5cGU9MDtjaWQ9NDQyNTgxO3Rlcm1faWQ9MTAyMTMwMjYyO3ZvZF90eXBlPTA=.v.f30741.m3u8?t=625D29C4&exper=0&us=7127235518283542733&sign=b6736c6bb3c4075ffea406a2f302adea",
            "https://1258712167.vod2.myqcloud.com/5a81e359vodtranssh1258712167/e6800d125285890813737225495/drm/voddrm.token.dWluPTIyMzUxMTMxOTY7c2tleT07cHNrZXk9O3Bsc2tleT0wMDA0MDAwMDYyOGQ0ZjI0ZDhkNTZjYTZlM2Y2NGIwMDgxZjE4MGM1YTViODcxNmNiMTdmNjA5ZjNmMzRlMTlhMmEyZTE2ZjY5ZGFiMTFhYmU5MWRjODBlO2V4dD07dWlkX3R5cGU9MDt1aWRfb3JpZ2luX3VpZF90eXBlPTA7dWlkX29yaWdpbl9hdXRoX3R5cGU9MDtjaWQ9NDQyNTgxO3Rlcm1faWQ9MTAyMTMwMjYyO3ZvZF90eXBlPTA=.v.f30740.m3u8?t=625D29C4&exper=0&us=4698840354260634299&sign=87dbbb556b381ba5c70b5444195223f3"
      ]
    },
    {
      "title":"拉压变形",
      "url":[
            "https://1258712167.vod2.myqcloud.com/5a81e359vodtranssh1258712167/e65d958c5285890813737208920/drm/voddrm.token.dWluPTIyMzUxMTMxOTY7c2tleT07cHNrZXk9O3Bsc2tleT0wMDA0MDAwMDYyOGQ0ZjI0ZDhkNTZjYTZlM2Y2NGIwMDgxZjE4MGM1YTViODcxNmNiMTdmNjA5ZjNmMzRlMTlhMmEyZTE2ZjY5ZGFiMTFhYmU5MWRjODBlO2V4dD07dWlkX3R5cGU9MDt1aWRfb3JpZ2luX3VpZF90eXBlPTA7dWlkX29yaWdpbl9hdXRoX3R5cGU9MDtjaWQ9NDQyNTgxO3Rlcm1faWQ9MTAyMTMwMjYyO3ZvZF90eXBlPTA=.v.f30742.m3u8?t=625D29C4&exper=0&us=5867580516719428455&sign=8361f81c321cd11bdedebff4b90a5f13",
            "https://1258712167.vod2.myqcloud.com/5a81e359vodtranssh1258712167/e65d958c5285890813737208920/drm/voddrm.token.dWluPTIyMzUxMTMxOTY7c2tleT07cHNrZXk9O3Bsc2tleT0wMDA0MDAwMDYyOGQ0ZjI0ZDhkNTZjYTZlM2Y2NGIwMDgxZjE4MGM1YTViODcxNmNiMTdmNjA5ZjNmMzRlMTlhMmEyZTE2ZjY5ZGFiMTFhYmU5MWRjODBlO2V4dD07dWlkX3R5cGU9MDt1aWRfb3JpZ2luX3VpZF90eXBlPTA7dWlkX29yaWdpbl9hdXRoX3R5cGU9MDtjaWQ9NDQyNTgxO3Rlcm1faWQ9MTAyMTMwMjYyO3ZvZF90eXBlPTA=.v.f30741.m3u8?t=625D29C4&exper=0&us=4608941062324352942&sign=16c93a8fa992475133ae0e06499560e6",
            "https://1258712167.vod2.myqcloud.com/5a81e359vodtranssh1258712167/e65d958c5285890813737208920/drm/voddrm.token.dWluPTIyMzUxMTMxOTY7c2tleT07cHNrZXk9O3Bsc2tleT0wMDA0MDAwMDYyOGQ0ZjI0ZDhkNTZjYTZlM2Y2NGIwMDgxZjE4MGM1YTViODcxNmNiMTdmNjA5ZjNmMzRlMTlhMmEyZTE2ZjY5ZGFiMTFhYmU5MWRjODBlO2V4dD07dWlkX3R5cGU9MDt1aWRfb3JpZ2luX3VpZF90eXBlPTA7dWlkX29yaWdpbl9hdXRoX3R5cGU9MDtjaWQ9NDQyNTgxO3Rlcm1faWQ9MTAyMTMwMjYyO3ZvZF90eXBlPTA=.v.f30740.m3u8?t=625D29C4&exper=0&us=1532996741176086724&sign=17e873523b9ca9926ab7192379a49b61"
      ]
    }
]
但是在调用逍遥一仙大佬的m3u8下载器的时候,出现了部分课程下载提示m3u8无效,或者是文件名称中部分字符变成“?”的问题


文件名称有问号应该是编码的问题。而m3u8失效问题看下载器保存的失败详情,m3u8地址多出来这么一些奇怪的字符,感觉也是编码的问题


代码里面已经把字符编码从utf8转换成了下载器要的gbk

for ($i=0;$i<count($result);$i++) {
        $j = $i + 1;
        $data = $j.'.'.$result[$i]['title'].','.$result[$i]['url'][$definition];
        $data = iconv("UTF-8","gbk//TRANSLIT",$data);
        $data = base64_encode($data);
        $data = iconv("UTF-8","gbk//TRANSLIT",'data='.$data.',type=2');
        if (json_decode(postSubmit('127.0.0.1:8787',$data,[]),true)['stat'] == true) {
                $number++;
        }
}

求助大佬们看看这是我代码里面编码转换的问题还是哪里出错了,或者说怎么能解决这个问题
在此拜谢了!{:301_993:}

a634085832 发表于 2022-4-10 18:45

PHP 直接调用ffmpeg比调用软件来得方便

huanxiong 发表于 2022-4-10 19:00

a634085832 发表于 2022-4-10 18:45
PHP 直接调用ffmpeg比调用软件来得方便

刚刚突然感觉本地跑PHP不是很合适,
还是把这个写成一个获取信息的接口比较好
具体下载什么的用易语言之类写{:301_979:}

a634085832 发表于 2022-4-10 19:07

huanxiong 发表于 2022-4-10 19:00
刚刚突然感觉本地跑PHP不是很合适,
还是把这个写成一个获取信息的接口比较好
具体下载什么的用易语言 ...

我个人在用的都是直接写bat的

逍遥一仙 发表于 2022-4-10 19:20

使用type=2的情况下不需要转gbk吧

逍遥一仙 发表于 2022-4-10 19:23

如果改回utf8后依旧出现失败的问题。尝试直接导出请求内容,保存为txt上传下看看

huanxiong 发表于 2022-4-10 19:40

逍遥一仙 发表于 2022-4-10 19:23
如果改回utf8后依旧出现失败的问题。尝试直接导出请求内容,保存为txt上传下看看


刚试了下用易语言模块调用没问题,先吃个饭再试试PHP

xiadongming 发表于 2022-4-10 20:21

huanxiong 发表于 2022-4-10 22:36

逍遥一仙 发表于 2022-4-10 19:23
如果改回utf8后依旧出现失败的问题。尝试直接导出请求内容,保存为txt上传下看看


不是gbk编码的话,中文字符都是乱码

wasd3152 发表于 2022-4-10 23:01

可以可以,突然觉得自己又行了
页: [1] 2
查看完整版本: PHP调用逍遥一仙m3u8下载器下载部分失败