commit
6bd2a41e1b
@ -1,147 +1,237 @@ |
|||||||
[ |
[ |
||||||
|
{ |
||||||
|
"id": -100, |
||||||
|
"name": "0", |
||||||
|
"url": "http://tts.baidu.com/text2audio,{\n \"method\": \"POST\",\n \"body\": \"tex={{java.encodeURI(java.encodeURI(speakText))}}&spd={{(speakSpeed + 5) / 10 + 4}}&per=4127&cuid=baidu_speech_demo&idx=1&cod=2&lan=zh&ctp=1&pdt=11&vol=5&aue=6&pit=3&_res_tag_=audio\"\n}" |
||||||
|
}, |
||||||
|
{ |
||||||
|
"id": -99, |
||||||
|
"name": "zaixianai.cn", |
||||||
|
"url": "<js>\nlet url='https://www.zaixianai.cn/voiceCompose';\n\nlet ua=\"Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/86.0.4240.198 Safari/537.36\";\n\nlet doc=java.get(url,{\"User-Agent\":ua});\nlet cookie=String(doc.header(\"set-cookie\")).match(/laravel_session=[^\\n]+/)[0];\nlet token=String(doc.body()).match(/token=\"([^\"]+)/)[1];\n\nurl='https://www.zaixianai.cn/Api_getVoice,'+JSON.stringify({\n\"method\": \"POST\",\n\"body\": \"content=\" + java.encodeURI(speakText) + \"&volume=50&speech_rate=0&voice=Aixia&_token=\"+token,\n\"headers\": {\n\"User-Agent\": ua,\n\"cookie\": cookie\n}\n});\n\nlet res=java.ajax(url);\n\n'https://www.zaixianai.cn/voice/'+JSON.parse(res).data.file_name+','+JSON.stringify({\n\"headers\": {\n\"User-Agent\": ua,\n\"accept\": \"*/*\",\n\"referer\": \"https://www.zaixianai.cn/voiceCompose\",\n\"cookie\": cookie,\n\"accept-encoding\": \"identity;q=1, *;q=0\"\n}\n})\n</js>" |
||||||
|
}, |
||||||
|
{ |
||||||
|
"id": -98, |
||||||
|
"name": "台湾女声", |
||||||
|
"url": "http://tts.baidu.com/text2audio,{\n \"method\": \"POST\",\n \"body\": \"tex={{java.encodeURI(java.encodeURI(speakText))}}&spd={{(speakSpeed + 5) / 10 + 4}}&per=4007&cuid=baidu_speech_demo&idx=1&cod=2&lan=zh&ctp=1&pdt=160&vol=5&aue=6&pit=5&_res_tag_=audio\"\n}" |
||||||
|
}, |
||||||
{ |
{ |
||||||
"id": -1, |
"id": -1, |
||||||
"name": "度丫丫", |
"name": "度丫丫", |
||||||
"url": "http://tts.baidu.com/text2audio,{\n \"method\": \"POST\",\n \"body\": \"tex={{java.encodeURI(java.encodeURI(speakText))}}&spd={{(speakSpeed + 5) / 10 + 4}}&per=4&cuid=baidu_speech_demo&idx=1&cod=2&lan=zh&ctp=1&pdt=301&vol=5&pit=5&_res_tag_=audio\"\n}" |
"url": "http://tts.baidu.com/text2audio,{\n \"method\": \"POST\",\n \"body\": \"tex={{java.encodeURI(java.encodeURI(speakText))}}&spd={{(speakSpeed + 5) / 10 + 4}}&per=4&cuid=baidu_speech_demo&idx=1&cod=2&lan=zh&ctp=1&pdt=301&vol=5&aue=6&pit=5&_res_tag_=audio\"\n}" |
||||||
}, |
}, |
||||||
{ |
{ |
||||||
"id": -2, |
"id": -2, |
||||||
"name": "度博文①", |
"name": "度博文①", |
||||||
"url": "http://tts.baidu.com/text2audio,{\n \"method\": \"POST\",\n \"body\": \"tex={{java.encodeURI(java.encodeURI(speakText))}}&spd={{(speakSpeed + 5) / 10 + 4}}&per=106&cuid=baidu_speech_demo&idx=1&cod=2&lan=zh&ctp=1&pdt=301&vol=5&pit=5&_res_tag_=audio\"\n}" |
"url": "http://tts.baidu.com/text2audio,{\n \"method\": \"POST\",\n \"body\": \"tex={{java.encodeURI(java.encodeURI(speakText))}}&spd={{(speakSpeed + 5) / 10 + 4}}&per=106&cuid=baidu_speech_demo&idx=1&cod=2&lan=zh&ctp=1&pdt=301&vol=5&aue=6&pit=5&_res_tag_=audio\"\n}" |
||||||
}, |
}, |
||||||
{ |
{ |
||||||
"id": -3, |
"id": -3, |
||||||
"name": "度博文②", |
"name": "度博文②", |
||||||
"url": "http://tts.baidu.com/text2audio,{\n \"method\": \"POST\",\n \"body\": \"tex={{java.encodeURI(java.encodeURI(speakText))}}&spd={{(speakSpeed + 5) / 10 + 4}}&per=4106&cuid=baidu_speech_demo&idx=1&cod=2&lan=zh&ctp=1&pdt=301&vol=5&pit=5&_res_tag_=audio\"\n}" |
"url": "http://tts.baidu.com/text2audio,{\n \"method\": \"POST\",\n \"body\": \"tex={{java.encodeURI(java.encodeURI(speakText))}}&spd={{(speakSpeed + 5) / 10 + 4}}&per=4106&cuid=baidu_speech_demo&idx=1&cod=2&lan=zh&ctp=1&pdt=301&vol=5&aue=6&pit=5&_res_tag_=audio\"\n}" |
||||||
}, |
}, |
||||||
{ |
{ |
||||||
"id": -4, |
"id": -4, |
||||||
"name": "度博文③", |
"name": "度博文③", |
||||||
"url": "http://tts.baidu.com/text2audio,{\n \"method\": \"POST\",\n \"body\": \"tex={{java.encodeURI(java.encodeURI(speakText))}}&spd={{(speakSpeed + 5) / 10 + 4}}&per=5106&cuid=baidu_speech_demo&idx=1&cod=2&lan=zh&ctp=1&pdt=301&vol=5&pit=5&_res_tag_=audio\"\n}" |
"url": "http://tsn.baidu.com/text2audio,{\n \"method\": \"POST\",\n \"body\": \"tex={{java.encodeURI(java.encodeURI(speakText))}}&spd={{(speakSpeed + 5) / 10 + 4}}&per=5106&cuid=baidu_speech_demo&idx=1&cod=2&lan=zh&ctp=1&pdt=160&vol=5&aue=6&pit=5&_res_tag_=audio\"\n}" |
||||||
|
}, |
||||||
|
{ |
||||||
|
"id": -97, |
||||||
|
"name": "度小乔", |
||||||
|
"url": "http://tts.baidu.com/text2audio,{\n \"method\": \"POST\",\n \"body\": \"tex={{java.encodeURI(java.encodeURI(speakText))}}&spd={{(speakSpeed + 5) / 10 + 4}}&per=1117&cuid=baidu_speech_demo&idx=1&cod=2&lan=zh&ctp=1&pdt=160=&vol=5&aue=6&pit=3&_res_tag_=audio\"\n}" |
||||||
}, |
}, |
||||||
{ |
{ |
||||||
"id": -5, |
"id": -5, |
||||||
"name": "度小娇", |
"name": "度小娇", |
||||||
"url": "http://tts.baidu.com/text2audio,{\n \"method\": \"POST\",\n \"body\": \"tex={{java.encodeURI(java.encodeURI(speakText))}}&spd={{(speakSpeed + 5) / 10 + 4}}&per=5&cuid=baidu_speech_demo&idx=1&cod=2&lan=zh&ctp=1&pdt=301&vol=5&pit=5&_res_tag_=audio\"\n}" |
"url": "http://tsn.baidu.com/text2audio,{\n \"method\": \"POST\",\n \"body\": \"tex={{java.encodeURI(java.encodeURI(speakText))}}&spd={{(speakSpeed + 5) / 10 + 4}}&per=5&cuid=baidu_speech_demo&idx=1&cod=2&lan=zh&ctp=1&pdt=160&vol=5&aue=6&pit=5&_res_tag_=audio\"\n}" |
||||||
}, |
}, |
||||||
{ |
{ |
||||||
"id": -6, |
"id": -6, |
||||||
"name": "度小宇", |
"name": "度小宇", |
||||||
"url": "http://tts.baidu.com/text2audio,{\n \"method\": \"POST\",\n \"body\": \"tex={{java.encodeURI(java.encodeURI(speakText))}}&spd={{(speakSpeed + 5) / 10 + 4}}&per=1&cuid=baidu_speech_demo&idx=1&cod=2&lan=zh&ctp=1&pdt=301&vol=5&pit=5&_res_tag_=audio\"\n}" |
"url": "http://tts.baidu.com/text2audio,{\n \"method\": \"POST\",\n \"body\": \"tex={{java.encodeURI(java.encodeURI(speakText))}}&spd={{(speakSpeed + 5) / 10 + 4}}&per=2&cuid=baidu_speech_demo&idx=1&cod=2&lan=zh&ctp=1&pdt=301&vol=5&aue=6&pit=5&_res_tag_=audio\"\n}" |
||||||
}, |
}, |
||||||
{ |
{ |
||||||
"id": -7, |
"id": -7, |
||||||
"name": "度小童", |
"name": "度小童", |
||||||
"url": "http://tts.baidu.com/text2audio,{\n \"method\": \"POST\",\n \"body\": \"tex={{java.encodeURI(java.encodeURI(speakText))}}&spd={{(speakSpeed + 5) / 10 + 4}}&per=110&cuid=baidu_speech_demo&idx=1&cod=2&lan=zh&ctp=1&pdt=301&vol=5&pit=5&_res_tag_=audio\"\n}" |
"url": "http://tts.baidu.com/text2audio,{\n \"method\": \"POST\",\n \"body\": \"tex={{java.encodeURI(java.encodeURI(speakText))}}&spd={{(speakSpeed + 5) / 10 + 4}}&per=110&cuid=baidu_speech_demo&idx=1&cod=2&lan=zh&ctp=1&pdt=301&vol=5&pit=5&_res_tag_=audio\"\n}" |
||||||
}, |
}, |
||||||
|
{ |
||||||
|
"id": -96, |
||||||
|
"name": "度小童", |
||||||
|
"url": "http://tsn.baidu.com/text2audio,{\n \"method\": \"POST\",\n \"body\": \"tex={{java.encodeURI(java.encodeURI(speakText))}}&spd={{(speakSpeed + 5) / 10 + 4}}&per=110&cuid=baidu_speech_demo&idx=1&cod=2&lan=zh&ctp=1&pdt=160&vol=5&aue=6&pit=5&_res_tag_=audio\"\n}" |
||||||
|
}, |
||||||
|
{ |
||||||
|
"id": -95, |
||||||
|
"name": "度小粤", |
||||||
|
"url": "http://tts.baidu.com/text2audio,{\n \"method\": \"POST\",\n \"body\": \"tex={{java.encodeURI(java.encodeURI(speakText))}}&spd={{(speakSpeed + 5) / 10 + 4}}&per=0&cuid=baidu_speech_demo&idx=1&cod=2&lan=cte&ctp=1&pdt=160&vol=5&aue=6&pit=5&_res_tag_=audio\"\n}" |
||||||
|
}, |
||||||
{ |
{ |
||||||
"id": -8, |
"id": -8, |
||||||
"name": "度小美", |
"name": "度小美", |
||||||
"url": "http://tts.baidu.com/text2audio,{\n \"method\": \"POST\",\n \"body\": \"tex={{java.encodeURI(java.encodeURI(speakText))}}&spd={{(speakSpeed + 5) / 10 + 4}}&per=0&cuid=baidu_speech_demo&idx=1&cod=2&lan=zh&ctp=1&pdt=301&vol=5&pit=5&_res_tag_=audio\"\n}" |
"url": "http://tts.baidu.com/text2audio,{\n \"method\": \"POST\",\n \"body\": \"tex={{java.encodeURI(java.encodeURI(speakText))}}&spd={{(speakSpeed + 5) / 10 + 4}}&per=0&cuid=baidu_speech_demo&idx=1&cod=2&lan=zh&ctp=1&pdt=160&vol=5&aue=6&pit=5&_res_tag_=audio\"\n}" |
||||||
|
}, |
||||||
|
{ |
||||||
|
"id": -94, |
||||||
|
"name": "度小芳", |
||||||
|
"url": "http://tts.baidu.com/text2audio,{\n \"method\": \"POST\",\n \"body\": \"tex={{java.encodeURI(java.encodeURI(speakText))}}&spd={{(speakSpeed + 5) / 10 + 4}}&per=4125&cuid=baidu_speech_demo&idx=1&cod=2&lan=zh&ctp=1&pdt=160&vol=5&aue=6&pit=5&_res_tag_=audio\"\n}" |
||||||
}, |
}, |
||||||
{ |
{ |
||||||
"id": -9, |
"id": -9, |
||||||
"name": "度小萌", |
"name": "度小萌", |
||||||
"url": "http://tts.baidu.com/text2audio,{\n \"method\": \"POST\",\n \"body\": \"tex={{java.encodeURI(java.encodeURI(speakText))}}&spd={{(speakSpeed + 5) / 10 + 4}}&per=111&cuid=baidu_speech_demo&idx=1&cod=2&lan=zh&ctp=1&pdt=301&vol=5&pit=5&_res_tag_=audio\"\n}" |
"url": "http://tts.baidu.com/text2audio,{\n \"method\": \"POST\",\n \"body\": \"tex={{java.encodeURI(java.encodeURI(speakText))}}&spd={{(speakSpeed + 5) / 10 + 4}}&per=111&cuid=baidu_speech_demo&idx=1&cod=2&lan=zh&ctp=1&pdt=301&vol=5&aue=6&pit=5&_res_tag_=audio\"\n}" |
||||||
|
}, |
||||||
|
{ |
||||||
|
"id": -93, |
||||||
|
"name": "度小贤", |
||||||
|
"url": "http://tts.baidu.com/text2audio,{\n \"method\": \"POST\",\n \"body\": \"tex={{java.encodeURI(java.encodeURI(speakText))}}&spd={{(speakSpeed + 5) / 10 + 4}}&per=4115&cuid=baidu_speech_demo&idx=1&cod=2&lan=zh&ctp=1&pdt=160=&vol=5&aue=6&pit=5&_res_tag_=audio\"}" |
||||||
|
}, |
||||||
|
{ |
||||||
|
"id": -92, |
||||||
|
"name": "度小雯", |
||||||
|
"url": "http://tts.baidu.com/text2audio,{\n \"method\": \"POST\",\n \"body\": \"tex={{java.encodeURI(java.encodeURI(speakText))}}&spd={{(speakSpeed + 5) / 10 + 4}}&per=5100&cuid=baidu_speech_demo&idx=1&cod=2&lan=zh&ctp=1&pdt=160=&vol=5&aue=6&pit=5&_res_tag_=audio\"\n}" |
||||||
}, |
}, |
||||||
{ |
{ |
||||||
"id": -10, |
"id": -10, |
||||||
"name": "度小鹿①", |
"name": "度小鹿①", |
||||||
"url": "http://tts.baidu.com/text2audio,{\n \"method\": \"POST\",\n \"body\": \"tex={{java.encodeURI(java.encodeURI(speakText))}}&spd={{(speakSpeed + 5) / 10 + 4}}&per=4118&cuid=baidu_speech_demo&idx=1&cod=2&lan=zh&ctp=1&pdt=301&vol=5&pit=5&_res_tag_=audio\"\n}" |
"url": "http://tts.baidu.com/text2audio,{\n \"method\": \"POST\",\n \"body\": \"tex={{java.encodeURI(java.encodeURI(speakText))}}&spd={{(speakSpeed + 5) / 10 + 4}}&per=4118&cuid=baidu_speech_demo&idx=1&cod=2&lan=zh&ctp=1&pdt=160&vol=5&aue=6&pit=5&_res_tag_=audio\"\n}" |
||||||
}, |
}, |
||||||
{ |
{ |
||||||
"id": -11, |
"id": -12, |
||||||
"name": "度小鹿②", |
"name": "度小鹿②", |
||||||
"url": "http://tts.baidu.com/text2audio,{\n \"method\": \"POST\",\n \"body\": \"tex={{java.encodeURI(java.encodeURI(speakText))}}&spd={{(speakSpeed + 5) / 10 + 4}}&per=5118&cuid=baidu_speech_demo&idx=1&cod=2&lan=zh&ctp=1&pdt=301&vol=5&pit=5&_res_tag_=audio\"\n}" |
"url": "http://tts.baidu.com/text2audio,{\n \"method\": \"POST\",\n \"body\": \"tex={{java.encodeURI(java.encodeURI(speakText))}}&spd={{(speakSpeed + 5) / 10 + 4}}&per=4119&cuid=baidu_speech_demo&idx=1&cod=2&lan=zh&ctp=1&pdt=160&vol=5&aue=6&pit=5&_res_tag_=audio\"\n}" |
||||||
}, |
}, |
||||||
{ |
{ |
||||||
"id": -12, |
"id": -11, |
||||||
"name": "度小鹿③", |
"name": "度小鹿③", |
||||||
"url": "http://tts.baidu.com/text2audio,{\n \"method\": \"POST\",\n \"body\": \"tex={{java.encodeURI(java.encodeURI(speakText))}}&spd={{(speakSpeed + 5) / 10 + 4}}&per=4119&cuid=baidu_speech_demo&idx=1&cod=2&lan=zh&ctp=1&pdt=301&vol=5&pit=5&_res_tag_=audio\"\n}" |
"url": "http://tsn.baidu.com/text2audio,{\n \"method\": \"POST\",\n \"body\": \"tex={{java.encodeURI(java.encodeURI(speakText))}}&spd={{(speakSpeed + 5) / 10 + 4}}&per=5118&cuid=baidu_speech_demo&idx=1&cod=2&lan=zh&ctp=1&pdt=160=&vol=5&aue=6&pit=5&_res_tag_=audio\"\n}" |
||||||
|
}, |
||||||
|
{ |
||||||
|
"id": -91, |
||||||
|
"name": "度灵儿", |
||||||
|
"url": "http://tts.baidu.com/text2audio,{\n \"method\": \"POST\",\n \"body\": \"tex={{java.encodeURI(java.encodeURI(speakText))}}&spd={{(speakSpeed + 5) / 10 + 4}}&per=5105&cuid=baidu_speech_demo&idx=1&cod=2&lan=zh&ctp=1&pdt=160=&vol=5&aue=6&pit=5&_res_tag_=audio\"\n}" |
||||||
}, |
}, |
||||||
{ |
{ |
||||||
"id": -13, |
"id": -13, |
||||||
"name": "度米朵①", |
"name": "度米朵①", |
||||||
"url": "http://tts.baidu.com/text2audio,{\n \"method\": \"POST\",\n \"body\": \"tex={{java.encodeURI(java.encodeURI(speakText))}}&spd={{(speakSpeed + 5) / 10 + 4}}&per=103&cuid=baidu_speech_demo&idx=1&cod=2&lan=zh&ctp=1&pdt=301&vol=5&pit=5&_res_tag_=audio\"\n}" |
"url": "http://tts.baidu.com/text2audio,{\n \"method\": \"POST\",\n \"body\": \"tex={{java.encodeURI(java.encodeURI(speakText))}}&spd={{(speakSpeed + 5) / 10 + 4}}&per=103&cuid=baidu_speech_demo&idx=1&cod=2&lan=zh&ctp=1&pdt=301&vol=5&aue=6&pit=5&_res_tag_=audio\"\n}" |
||||||
}, |
}, |
||||||
{ |
{ |
||||||
"id": -14, |
"id": -14, |
||||||
"name": "度米朵②", |
"name": "度米朵②", |
||||||
"url": "http://tts.baidu.com/text2audio,{\n \"method\": \"POST\",\n \"body\": \"tex={{java.encodeURI(java.encodeURI(speakText))}}&spd={{(speakSpeed + 5) / 10 + 4}}&per=4103&cuid=baidu_speech_demo&idx=1&cod=2&lan=zh&ctp=1&pdt=301&vol=5&pit=5&_res_tag_=audio\"\n}" |
"url": "http://tts.baidu.com/text2audio,{\n \"method\": \"POST\",\n \"body\": \"tex={{java.encodeURI(java.encodeURI(speakText))}}&spd={{(speakSpeed + 5) / 10 + 4}}&per=4103&cuid=baidu_speech_demo&idx=1&cod=2&lan=zh&ctp=1&pdt=160&vol=5&aue=6&pit=5&_res_tag_=audio\"\n}" |
||||||
}, |
}, |
||||||
{ |
{ |
||||||
"id": -15, |
"id": -15, |
||||||
"name": "度逍遥-基础", |
"name": "度逍遥-基础", |
||||||
"url": "http://tts.baidu.com/text2audio,{\n \"method\": \"POST\",\n \"body\": \"tex={{java.encodeURI(java.encodeURI(speakText))}}&spd={{(speakSpeed + 5) / 10 + 4}}&per=3&cuid=baidu_speech_demo&idx=1&cod=2&lan=zh&ctp=1&pdt=301&vol=5&pit=5&_res_tag_=audio\"\n}" |
"url": "http://tts.baidu.com/text2audio,{\n \"method\": \"POST\",\n \"body\": \"tex={{java.encodeURI(java.encodeURI(speakText))}}&spd={{(speakSpeed + 5) / 10 + 4}}&per=3&cuid=baidu_speech_demo&idx=1&cod=2&lan=zh&ctp=1&pdt=160&vol=5&aue=6&pit=5&_res_tag_=audio\"\n}" |
||||||
}, |
}, |
||||||
{ |
{ |
||||||
"id": -16, |
"id": -16, |
||||||
"name": "度逍遥-精品①", |
"name": "度逍遥-精品①", |
||||||
"url": "http://tts.baidu.com/text2audio,{\n \"method\": \"POST\",\n \"body\": \"tex={{java.encodeURI(java.encodeURI(speakText))}}&spd={{(speakSpeed + 5) / 10 + 4}}&per=4003&cuid=baidu_speech_demo&idx=1&cod=2&lan=zh&ctp=1&pdt=301&vol=5&pit=5&_res_tag_=audio\"\n}" |
"url": "http://tsn.baidu.com/text2audio,{\n \"method\": \"POST\",\n \"body\": \"tex={{java.encodeURI(java.encodeURI(speakText))}}&spd={{(speakSpeed + 5) / 10 + 4}}&per=4003&cuid=baidu_speech_demo&idx=1&cod=2&lan=zh&ctp=1&pdt=160&vol=5&aue=6&pit=5&_res_tag_=audio\"\n}" |
||||||
}, |
}, |
||||||
{ |
{ |
||||||
"id": -17, |
"id": -17, |
||||||
"name": "度逍遥-精品②", |
"name": "度逍遥-精品②", |
||||||
"url": "http://tts.baidu.com/text2audio,{\n \"method\": \"POST\",\n \"body\": \"tex={{java.encodeURI(java.encodeURI(speakText))}}&spd={{(speakSpeed + 5) / 10 + 4}}&per=5003&cuid=baidu_speech_demo&idx=1&cod=2&lan=zh&ctp=1&pdt=301&vol=5&pit=5&_res_tag_=audio\"\n}" |
"url": "http://tsn.baidu.com/text2audio,{\n \"method\": \"POST\",\n \"body\": \"tex={{java.encodeURI(java.encodeURI(speakText))}}&spd={{(speakSpeed + 5) / 10 + 4}}&per=5003&cuid=baidu_speech_demo&idx=1&cod=2&lan=zh&ctp=1&pdt=160&vol=5&aue=6&pit=5&_res_tag_=audio\"\n}" |
||||||
}, |
}, |
||||||
{ |
{ |
||||||
"id": -18, |
"id": -18, |
||||||
"name": "情感女声", |
"name": "情感女声", |
||||||
"url": "http://tts.baidu.com/text2audio,{\n \"method\": \"POST\",\n \"body\": \"tex={{java.encodeURI(java.encodeURI(speakText))}}&spd={{(speakSpeed + 5) / 10 + 4}}&per=4105&cuid=baidu_speech_demo&idx=1&cod=2&lan=zh&ctp=1&pdt=301&vol=5&pit=5&_res_tag_=audio\"\n}" |
"url": "http://tsn.baidu.com/text2audio,{\n \"method\": \"POST\",\n \"body\": \"tex={{java.encodeURI(java.encodeURI(speakText))}}&spd={{(speakSpeed + 5) / 10 + 4}}&per=4105&cuid=baidu_speech_demo&idx=1&cod=2&lan=zh&ctp=1&pdt=160=&vol=5&aue=6&pit=5&_res_tag_=audio\"\n}" |
||||||
}, |
}, |
||||||
{ |
{ |
||||||
"id": -19, |
"id": -19, |
||||||
"name": "情感男声", |
"name": "情感男声", |
||||||
"url": "http://tts.baidu.com/text2audio,{\n \"method\": \"POST\",\n \"body\": \"tex={{java.encodeURI(java.encodeURI(speakText))}}&spd={{(speakSpeed + 5) / 10 + 4}}&per=4115&cuid=baidu_speech_demo&idx=1&cod=2&lan=zh&ctp=1&pdt=301&vol=5&pit=5&_res_tag_=audio\"\n}" |
"url": "http://tsn.baidu.com/text2audio,{\n \"method\": \"POST\",\n \"body\": \"tex={{java.encodeURI(java.encodeURI(speakText))}}&spd={{(speakSpeed + 5) / 10 + 4}}&per=4115&cuid=baidu_speech_demo&idx=1&cod=2&lan=zh&ctp=1&pdt=160&vol=5&aue=6&pit=5&_res_tag_=audio\"\n}" |
||||||
}, |
}, |
||||||
{ |
{ |
||||||
"id": -20, |
"id": -20, |
||||||
"name": "标准女声", |
"name": "标准女声", |
||||||
"url": "http://tts.baidu.com/text2audio,{\n \"method\": \"POST\",\n \"body\": \"tex={{java.encodeURI(java.encodeURI(speakText))}}&spd={{(speakSpeed + 5) / 10 + 4}}&per=4100&cuid=baidu_speech_demo&idx=1&cod=2&lan=zh&ctp=1&pdt=301&vol=5&pit=5&_res_tag_=audio\"\n}" |
"url": "http://tsn.baidu.com/text2audio,{\n \"method\": \"POST\",\n \"body\": \"tex={{java.encodeURI(java.encodeURI(speakText))}}&spd={{(speakSpeed + 5) / 10 + 4}}&per=4100&cuid=baidu_speech_demo&idx=1&cod=2&lan=zh&ctp=1&pdt=160=&vol=5&aue=6&pit=5&_res_tag_=audio\"\n}" |
||||||
|
}, |
||||||
|
{ |
||||||
|
"id": -90, |
||||||
|
"name": "标准女声-基础", |
||||||
|
"url": "http://tts.baidu.com/text2audio,{\n \"method\": \"POST\",\n \"body\": \"tex={{java.encodeURI(java.encodeURI(speakText))}}&spd={{(speakSpeed + 5) / 10 + 4}}&per=100&cuid=baidu_speech_demo&idx=1&cod=2&lan=zh&ctp=1&pdt=160&vol=5&aue=6&pit=5&_res_tag_=audio\"\n}" |
||||||
}, |
}, |
||||||
{ |
{ |
||||||
"id": -21, |
"id": -21, |
||||||
"name": "标准男声", |
"name": "标准男声", |
||||||
"url": "http://tts.baidu.com/text2audio,{\n \"method\": \"POST\",\n \"body\": \"tex={{java.encodeURI(java.encodeURI(speakText))}}&spd={{(speakSpeed + 5) / 10 + 4}}&per=4121&cuid=baidu_speech_demo&idx=1&cod=2&lan=zh&ctp=1&pdt=301&vol=5&pit=5&_res_tag_=audio\"\n}" |
"url": "http://tsn.baidu.com/text2audio,{\n \"method\": \"POST\",\n \"body\": \"tex={{java.encodeURI(java.encodeURI(speakText))}}&spd={{(speakSpeed + 5) / 10 + 4}}&per=4121&cuid=baidu_speech_demo&idx=1&cod=2&lan=zh&ctp=1&pdt=160=&vol=5&aue=6&pit=5&_res_tag_=audio\"\n}" |
||||||
}, |
}, |
||||||
{ |
{ |
||||||
"id": -22, |
"id": -89, |
||||||
"name": "治愈女声", |
"name": "温柔女声", |
||||||
"url": "http://tts.baidu.com/text2audio,{\n \"method\": \"POST\",\n \"body\": \"tex={{java.encodeURI(java.encodeURI(speakText))}}&spd={{(speakSpeed + 5) / 10 + 4}}&per=5120&cuid=baidu_speech_demo&idx=1&cod=2&lan=zh&ctp=1&pdt=301&vol=5&pit=5&_res_tag_=audio\"\n}" |
"url": "http://tts.baidu.com/text2audio,{\n \"method\": \"POST\",\n \"body\": \"tex={{java.encodeURI(java.encodeURI(speakText))}}&spd={{(speakSpeed + 5) / 10 + 4}}&per=4126&cuid=baidu_speech_demo&idx=1&cod=2&lan=zh&ctp=1&pdt=160&vol=5&aue=6&pit=5&_res_tag_=audio\"\n}" |
||||||
}, |
}, |
||||||
{ |
{ |
||||||
"id": -23, |
"id": -88, |
||||||
"name": "治愈男声", |
"name": "甜美女声①", |
||||||
"url": "http://tts.baidu.com/text2audio,{\n \"method\": \"POST\",\n \"body\": \"tex={{java.encodeURI(java.encodeURI(speakText))}}&spd={{(speakSpeed + 5) / 10 + 4}}&per=5121&cuid=baidu_speech_demo&idx=1&cod=2&lan=zh&ctp=1&pdt=301&vol=5&pit=5&_res_tag_=audio\"\n}" |
"url": "http://tts.baidu.com/text2audio,{\n \"method\": \"POST\",\n \"body\": \"tex={{java.encodeURI(java.encodeURI(speakText))}}&spd={{(speakSpeed + 5) / 10 + 4}}&per=1200&cuid=baidu_speech_demo&idx=1&cod=2&lan=zh&ctp=1&pdt=160&vol=&rate=32=5&pit=5&_res_tag_=audio\"\n}" |
||||||
}, |
}, |
||||||
{ |
{ |
||||||
"id": -24, |
"id": -24, |
||||||
"name": "甜美女声①", |
"name": "甜美女声②", |
||||||
"url": "http://tts.baidu.com/text2audio,{\n \"method\": \"POST\",\n \"body\": \"tex={{java.encodeURI(java.encodeURI(speakText))}}&spd={{(speakSpeed + 5) / 10 + 4}}&per=4117&cuid=baidu_speech_demo&idx=1&cod=2&lan=zh&ctp=1&pdt=301&vol=5&pit=5&_res_tag_=audio\"\n}" |
"url": "http://tts.baidu.com/text2audio,{\n \"method\": \"POST\",\n \"body\": \"tex={{java.encodeURI(java.encodeURI(speakText))}}&spd={{(speakSpeed + 5) / 10 + 4}}&per=4117&cuid=baidu_speech_demo&idx=1&cod=2&lan=zh&ctp=1&pdt=160&vol=5&aue=6&pit=5&_res_tag_=audio\"\n}" |
||||||
}, |
}, |
||||||
{ |
{ |
||||||
"id": -25, |
"id": -25, |
||||||
"name": "甜美女声②", |
"name": "甜美女声③", |
||||||
"url": "http://tts.baidu.com/text2audio,{\n \"method\": \"POST\",\n \"body\": \"tex={{java.encodeURI(java.encodeURI(speakText))}}&spd={{(speakSpeed + 5) / 10 + 4}}&per=5117&cuid=baidu_speech_demo&idx=1&cod=2&lan=zh&ctp=1&pdt=301&vol=5&pit=5&_res_tag_=audio\"\n}" |
"url": "http://tsn.baidu.com/text2audio,{\n \"method\": \"POST\",\n \"body\": \"tex={{java.encodeURI(java.encodeURI(speakText))}}&spd={{(speakSpeed + 5) / 10 + 4}}&per=5117&cuid=baidu_speech_demo&idx=1&cod=2&lan=zh&ctp=1&pdt=160&vol=5&aue=6&pit=5&_res_tag_=audio\"\n}" |
||||||
|
}, |
||||||
|
{ |
||||||
|
"id": -22, |
||||||
|
"name": "电台女声", |
||||||
|
"url": "http://tsn.baidu.com/text2audio,{\n \"method\": \"POST\",\n \"body\": \"tex={{java.encodeURI(java.encodeURI(speakText))}}&spd={{(speakSpeed + 5) / 10 + 4}}&per=5120&cuid=baidu_speech_demo&idx=1&cod=2&lan=zh&ctp=1&pdt=160&vol=&rate=32=5&pit=5&_res_tag_=audio\"\n}" |
||||||
|
}, |
||||||
|
{ |
||||||
|
"id": -23, |
||||||
|
"name": "电台男声", |
||||||
|
"url": "http://tsn.baidu.com/text2audio,{\n \"method\": \"POST\",\n \"body\": \"tex={{java.encodeURI(java.encodeURI(speakText))}}&spd={{(speakSpeed + 5) / 10 + 4}}&per=5121&cuid=baidu_speech_demo&idx=1&cod=2&lan=zh&ctp=1&pdt=160&vol=5&aue=6&pit=5&_res_tag_=audio\"\n}" |
||||||
}, |
}, |
||||||
{ |
{ |
||||||
"id": -26, |
"id": -26, |
||||||
"name": "百度主持", |
"name": "百度主持", |
||||||
"url": "http://tts.baidu.com/text2audio,{\n \"method\": \"POST\",\n \"body\": \"tex={{java.encodeURI(java.encodeURI(speakText))}}&spd={{(speakSpeed + 5) / 10 + 4}}&per=9&cuid=baidu_speech_demo&idx=1&cod=2&lan=zh&ctp=1&pdt=301&vol=5&pit=5&_res_tag_=audio\"\n}" |
"url": "http://tts.baidu.com/text2audio,{\n \"method\": \"POST\",\n \"body\": \"tex={{java.encodeURI(java.encodeURI(speakText))}}&spd={{(speakSpeed + 5) / 10 + 4}}&per=9&cuid=baidu_speech_demo&idx=1&cod=2&lan=zh&ctp=1&pdt=301&vol=5&pit=5&_res_tag_=audio\"\n}" |
||||||
}, |
}, |
||||||
|
{ |
||||||
|
"id": -87, |
||||||
|
"name": "百度主持", |
||||||
|
"url": "http://tts.baidu.com/text2audio,{\n \"method\": \"POST\",\n \"body\": \"tex={{java.encodeURI(java.encodeURI(speakText))}}&spd={{(speakSpeed + 5) / 10 + 4}}&per=4127&cuid=baidu_speech_demo&idx=1&cod=2&lan=zh&ctp=1&pdt=11&vol=5&aue=6&pit=5&_res_tag_=audio\"\n}" |
||||||
|
}, |
||||||
|
{ |
||||||
|
"id": -86, |
||||||
|
"name": "百度解说①", |
||||||
|
"url": "http://tts.baidu.com/text2audio,{\n \"method\": \"POST\",\n \"body\": \"tex={{java.encodeURI(java.encodeURI(speakText))}}&spd={{(speakSpeed + 5) / 10 + 4}}&per=4123&cuid=baidu_speech_demo&idx=1&cod=2&lan=zh&ctp=1&pdt=12&vol=5&aue=6&pit=5&_res_tag_=audio\"\n}" |
||||||
|
}, |
||||||
|
{ |
||||||
|
"id": -85, |
||||||
|
"name": "百度解说②", |
||||||
|
"url": "http://tts.baidu.com/text2audio,{\n \"method\": \"POST\",\n \"body\": \"tex={{java.encodeURI(java.encodeURI(speakText))}}&spd={{(speakSpeed + 5) / 10 + 4}}&per=4128&cuid=baidu_speech_demo&idx=1&cod=2&lan=zh&ctp=1&pdt=12&vol=5&aue=6&pit=5&_res_tag_=audio\"\n}" |
||||||
|
}, |
||||||
|
{ |
||||||
|
"id": -84, |
||||||
|
"name": "百度解说③", |
||||||
|
"url": "http://tts.baidu.com/text2audio,{\n \"method\": \"POST\",\n \"body\": \"tex={{java.encodeURI(java.encodeURI(speakText))}}&spd={{(speakSpeed + 5) / 10 + 4}}&per=4129&cuid=baidu_speech_demo&idx=1&cod=2&lan=zh&ctp=1&pdt=12&vol=5&aue=6&pit=5&_res_tag_=audio\"\n}" |
||||||
|
}, |
||||||
{ |
{ |
||||||
"id": -27, |
"id": -27, |
||||||
"name": "百度评书①", |
"name": "百度评书①", |
||||||
"url": "http://tts.baidu.com/text2audio,{\n \"method\": \"POST\",\n \"body\": \"tex={{java.encodeURI(java.encodeURI(speakText))}}&spd={{(speakSpeed + 5) / 10 + 4}}&per=6&cuid=baidu_speech_demo&idx=1&cod=2&lan=zh&ctp=1&pdt=301&vol=5&pit=5&_res_tag_=audio\"\n}" |
"url": "http://tts.baidu.com/text2audio,{\n \"method\": \"POST\",\n \"body\": \"tex={{java.encodeURI(java.encodeURI(speakText))}}&spd={{(speakSpeed + 5) / 10 + 4}}&per=6&cuid=baidu_speech_demo&idx=1&cod=2&lan=zh&ctp=1&pdt=301&vol=5&aue=6&pit=5&_res_tag_=audio\"\n}" |
||||||
}, |
}, |
||||||
{ |
{ |
||||||
"id": -28, |
"id": -28, |
||||||
"name": "百度评书②", |
"name": "百度评书②", |
||||||
"url": "http://tts.baidu.com/text2audio,{\n \"method\": \"POST\",\n \"body\": \"tex={{java.encodeURI(java.encodeURI(speakText))}}&spd={{(speakSpeed + 5) / 10 + 4}}&per=4114&cuid=baidu_speech_demo&idx=1&cod=2&lan=zh&ctp=1&pdt=301&vol=5&pit=5&_res_tag_=audio\"\n}" |
"url": "http://tts.baidu.com/text2audio,{\n \"method\": \"POST\",\n \"body\": \"tex={{java.encodeURI(java.encodeURI(speakText))}}&spd={{(speakSpeed + 5) / 10 + 4}}&per=4114&cuid=baidu_speech_demo&idx=1&cod=2&lan=zh&ctp=1&pdt=160&vol=5&aue=6&pit=5&_res_tag_=audio\"\n}" |
||||||
|
}, |
||||||
|
{ |
||||||
|
"id": -83, |
||||||
|
"name": "萝莉少女音", |
||||||
|
"url": "http://tts.baidu.com/text2audio,{\n \"method\": \"POST\",\n \"body\": \"tex={{java.encodeURI(java.encodeURI(speakText))}}&spd={{(speakSpeed + 5) / 10 + 4}}&per=5201&cuid=baidu_speech_demo&idx=1&cod=2&lan=zh&ctp=1&pdt=160&vol=5&aue=6&pit=5&_res_tag_=audio\"\n}" |
||||||
}, |
}, |
||||||
{ |
{ |
||||||
"id": -29, |
"id": -29, |
||||||
"name": "阿里云语音", |
"name": "阿里云语音", |
||||||
"url": "<js>/*播音人Aiting可改其他https://cdn.jsdelivr.net/gh/Celeter/build/.github/scripts/speaker.json,详见https://ai.aliyun.com/nls/tts*/;eval(''+java.ajax('https://cdn.jsdelivr.net/gh/Celeter/build/.github/scripts/ttsDemo.js'));ttsDemo(speakText,speakSpeed,'Aiting')</js>" |
"url": "<js>/*播音人Aiting可改其他https://cdn.jsdelivr.net/gh/Celeter/build/.github/scripts/speaker.json,详见https://ai.aliyun.com/nls/tts*/;eval(''+java.ajax('https://cdn.jsdelivr.net/gh/Celeter/build/.github/scripts/ttsDemo.js'));ttsDemo(speakText,speakSpeed,'Aiting')</js>" |
||||||
} |
} |
||||||
] |
] |
@ -0,0 +1,122 @@ |
|||||||
|
package io.legado.app.help.http |
||||||
|
|
||||||
|
import io.legado.app.constant.AppConst |
||||||
|
import io.legado.app.help.AppConfig |
||||||
|
import io.legado.app.utils.EncodingDetect |
||||||
|
import io.legado.app.utils.UTF8BOMFighter |
||||||
|
import kotlinx.coroutines.suspendCancellableCoroutine |
||||||
|
import okhttp3.* |
||||||
|
import okhttp3.HttpUrl.Companion.toHttpUrl |
||||||
|
import okhttp3.MediaType.Companion.toMediaType |
||||||
|
import okhttp3.RequestBody.Companion.toRequestBody |
||||||
|
import java.io.IOException |
||||||
|
import java.nio.charset.Charset |
||||||
|
import kotlin.coroutines.resume |
||||||
|
import kotlin.coroutines.resumeWithException |
||||||
|
|
||||||
|
suspend fun OkHttpClient.newCall( |
||||||
|
retry: Int = 0, |
||||||
|
builder: Request.Builder.() -> Unit |
||||||
|
): ResponseBody { |
||||||
|
val requestBuilder = Request.Builder() |
||||||
|
requestBuilder.header(AppConst.UA_NAME, AppConfig.userAgent) |
||||||
|
requestBuilder.apply(builder) |
||||||
|
var response: Response? = null |
||||||
|
for (i in 0..retry) { |
||||||
|
response = this.newCall(requestBuilder.build()).await() |
||||||
|
if (response.isSuccessful) { |
||||||
|
return response.body!! |
||||||
|
} |
||||||
|
} |
||||||
|
throw IOException(response!!.message) |
||||||
|
} |
||||||
|
|
||||||
|
suspend fun OkHttpClient.newCallStrResponse( |
||||||
|
retry: Int = 0, |
||||||
|
builder: Request.Builder.() -> Unit |
||||||
|
): StrResponse { |
||||||
|
val requestBuilder = Request.Builder() |
||||||
|
requestBuilder.header(AppConst.UA_NAME, AppConfig.userAgent) |
||||||
|
requestBuilder.apply(builder) |
||||||
|
var response: Response? = null |
||||||
|
for (i in 0..retry) { |
||||||
|
response = this.newCall(requestBuilder.build()).await() |
||||||
|
if (response.isSuccessful) { |
||||||
|
return StrResponse(response, response.body!!.text()) |
||||||
|
} |
||||||
|
} |
||||||
|
throw IOException(response!!.message) |
||||||
|
} |
||||||
|
|
||||||
|
suspend fun Call.await(): Response = suspendCancellableCoroutine { block -> |
||||||
|
|
||||||
|
block.invokeOnCancellation { |
||||||
|
cancel() |
||||||
|
} |
||||||
|
|
||||||
|
enqueue(object : Callback { |
||||||
|
override fun onFailure(call: Call, e: IOException) { |
||||||
|
block.resumeWithException(e) |
||||||
|
} |
||||||
|
|
||||||
|
override fun onResponse(call: Call, response: Response) { |
||||||
|
block.resume(response) |
||||||
|
} |
||||||
|
}) |
||||||
|
|
||||||
|
} |
||||||
|
|
||||||
|
fun ResponseBody.text(encode: String? = null): String { |
||||||
|
val responseBytes = UTF8BOMFighter.removeUTF8BOM(bytes()) |
||||||
|
var charsetName: String? = encode |
||||||
|
|
||||||
|
charsetName?.let { |
||||||
|
return String(responseBytes, Charset.forName(charsetName)) |
||||||
|
} |
||||||
|
|
||||||
|
//根据http头判断 |
||||||
|
contentType()?.charset()?.let { |
||||||
|
return String(responseBytes, it) |
||||||
|
} |
||||||
|
|
||||||
|
//根据内容判断 |
||||||
|
charsetName = EncodingDetect.getHtmlEncode(responseBytes) |
||||||
|
return String(responseBytes, Charset.forName(charsetName)) |
||||||
|
} |
||||||
|
|
||||||
|
fun Request.Builder.addHeaders(headers: Map<String, String>) { |
||||||
|
headers.forEach { |
||||||
|
addHeader(it.key, it.value) |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
fun Request.Builder.get(url: String, queryMap: Map<String, String>, encoded: Boolean = false) { |
||||||
|
val httpBuilder = url.toHttpUrl().newBuilder() |
||||||
|
queryMap.forEach { |
||||||
|
if (encoded) { |
||||||
|
httpBuilder.addEncodedQueryParameter(it.key, it.value) |
||||||
|
} else { |
||||||
|
httpBuilder.addQueryParameter(it.key, it.value) |
||||||
|
} |
||||||
|
} |
||||||
|
url(httpBuilder.build()) |
||||||
|
} |
||||||
|
|
||||||
|
fun Request.Builder.postForm(form: Map<String, String>, encoded: Boolean = false) { |
||||||
|
val formBody = FormBody.Builder() |
||||||
|
form.forEach { |
||||||
|
if (encoded) { |
||||||
|
formBody.addEncoded(it.key, it.value) |
||||||
|
} else { |
||||||
|
formBody.add(it.key, it.value) |
||||||
|
} |
||||||
|
} |
||||||
|
post(formBody.build()) |
||||||
|
} |
||||||
|
|
||||||
|
fun Request.Builder.postJson(json: String?) { |
||||||
|
json?.let { |
||||||
|
val requestBody = json.toRequestBody("application/json; charset=UTF-8".toMediaType()) |
||||||
|
post(requestBody) |
||||||
|
} |
||||||
|
} |
@ -0,0 +1,12 @@ |
|||||||
|
package io.legado.app.help.http |
||||||
|
|
||||||
|
import okhttp3.Interceptor |
||||||
|
import okhttp3.Response |
||||||
|
|
||||||
|
class RetryInterceptor : Interceptor { |
||||||
|
|
||||||
|
override fun intercept(chain: Interceptor.Chain): Response { |
||||||
|
TODO("Not yet implemented") |
||||||
|
} |
||||||
|
|
||||||
|
} |
@ -1,13 +0,0 @@ |
|||||||
package io.legado.app.help.http.parser |
|
||||||
|
|
||||||
import okhttp3.Response |
|
||||||
import rxhttp.wrapper.annotation.Parser |
|
||||||
|
|
||||||
@Parser(name = "ByteArray") |
|
||||||
class ByteParser : rxhttp.wrapper.parse.Parser<ByteArray> { |
|
||||||
|
|
||||||
override fun onParse(response: Response): ByteArray { |
|
||||||
return response.body!!.bytes() |
|
||||||
} |
|
||||||
|
|
||||||
} |
|
@ -1,14 +0,0 @@ |
|||||||
package io.legado.app.help.http.parser |
|
||||||
|
|
||||||
import okhttp3.Response |
|
||||||
import rxhttp.wrapper.annotation.Parser |
|
||||||
import java.io.InputStream |
|
||||||
|
|
||||||
@Parser(name = "InputStream") |
|
||||||
class InputStreamParser : rxhttp.wrapper.parse.Parser<InputStream> { |
|
||||||
|
|
||||||
override fun onParse(response: Response): InputStream { |
|
||||||
return response.body!!.byteStream() |
|
||||||
} |
|
||||||
|
|
||||||
} |
|
@ -1,40 +0,0 @@ |
|||||||
package io.legado.app.help.http.parser |
|
||||||
|
|
||||||
import io.legado.app.help.http.StrResponse |
|
||||||
import io.legado.app.utils.EncodingDetect |
|
||||||
import io.legado.app.utils.UTF8BOMFighter |
|
||||||
import okhttp3.Response |
|
||||||
import rxhttp.wrapper.annotation.Parser |
|
||||||
import rxhttp.wrapper.exception.HttpStatusCodeException |
|
||||||
import java.nio.charset.Charset |
|
||||||
|
|
||||||
@Parser(name = "StrResponse") |
|
||||||
class StrResponseParser(private val encode: String? = null) : |
|
||||||
rxhttp.wrapper.parse.Parser<StrResponse> { |
|
||||||
|
|
||||||
override fun onParse(response: Response): StrResponse { |
|
||||||
val body = getString(response) |
|
||||||
return StrResponse(response, body) |
|
||||||
} |
|
||||||
|
|
||||||
private fun getString(response: Response): String { |
|
||||||
|
|
||||||
val responseBody = response.body ?: throw HttpStatusCodeException(response, "内容为空") |
|
||||||
val responseBytes = UTF8BOMFighter.removeUTF8BOM(responseBody.bytes()) |
|
||||||
var charsetName: String? = encode |
|
||||||
|
|
||||||
charsetName?.let { |
|
||||||
return String(responseBytes, Charset.forName(charsetName)) |
|
||||||
} |
|
||||||
|
|
||||||
//根据http头判断 |
|
||||||
responseBody.contentType()?.charset()?.let { |
|
||||||
return String(responseBytes, it) |
|
||||||
} |
|
||||||
|
|
||||||
//根据内容判断 |
|
||||||
charsetName = EncodingDetect.getHtmlEncode(responseBytes) |
|
||||||
return String(responseBytes, Charset.forName(charsetName)) |
|
||||||
} |
|
||||||
|
|
||||||
} |
|
@ -1,33 +0,0 @@ |
|||||||
package io.legado.app.help.http.parser |
|
||||||
|
|
||||||
import io.legado.app.utils.EncodingDetect |
|
||||||
import io.legado.app.utils.UTF8BOMFighter |
|
||||||
import okhttp3.Response |
|
||||||
import rxhttp.wrapper.annotation.Parser |
|
||||||
import rxhttp.wrapper.exception.HttpStatusCodeException |
|
||||||
import java.nio.charset.Charset |
|
||||||
|
|
||||||
@Parser(name = "Text") |
|
||||||
class TextParser(private val encode: String? = null) : rxhttp.wrapper.parse.Parser<String> { |
|
||||||
|
|
||||||
override fun onParse(response: Response): String { |
|
||||||
|
|
||||||
val responseBody = response.body ?: throw HttpStatusCodeException(response, "内容为空") |
|
||||||
val responseBytes = UTF8BOMFighter.removeUTF8BOM(responseBody.bytes()) |
|
||||||
var charsetName: String? = encode |
|
||||||
|
|
||||||
charsetName?.let { |
|
||||||
return String(responseBytes, Charset.forName(charsetName)) |
|
||||||
} |
|
||||||
|
|
||||||
//根据http头判断 |
|
||||||
responseBody.contentType()?.charset()?.let { |
|
||||||
return String(responseBytes, it) |
|
||||||
} |
|
||||||
|
|
||||||
//根据内容判断 |
|
||||||
charsetName = EncodingDetect.getHtmlEncode(responseBytes) |
|
||||||
return String(responseBytes, Charset.forName(charsetName)) |
|
||||||
} |
|
||||||
|
|
||||||
} |
|
@ -1,92 +0,0 @@ |
|||||||
package io.legado.app.ui.widget.recycler |
|
||||||
|
|
||||||
import android.annotation.SuppressLint |
|
||||||
import android.content.Context |
|
||||||
import android.util.AttributeSet |
|
||||||
import android.view.LayoutInflater |
|
||||||
import android.view.MotionEvent |
|
||||||
import android.view.View |
|
||||||
import android.widget.LinearLayout |
|
||||||
import androidx.recyclerview.widget.LinearLayoutManager |
|
||||||
import io.legado.app.R |
|
||||||
import io.legado.app.databinding.ViewRefreshRecyclerBinding |
|
||||||
import io.legado.app.lib.theme.ATH |
|
||||||
|
|
||||||
|
|
||||||
@SuppressLint("ClickableViewAccessibility") |
|
||||||
class RefreshRecyclerView(context: Context?, attrs: AttributeSet?) : LinearLayout(context, attrs) { |
|
||||||
private var binding: ViewRefreshRecyclerBinding |
|
||||||
private var durTouchX = -1000000f |
|
||||||
private var durTouchY = -1000000f |
|
||||||
|
|
||||||
var onRefreshStart: (() -> Unit)? = null |
|
||||||
|
|
||||||
init { |
|
||||||
orientation = VERTICAL |
|
||||||
val view = LayoutInflater.from(context).inflate(R.layout.view_refresh_recycler, this, true) |
|
||||||
binding = ViewRefreshRecyclerBinding.bind(view) |
|
||||||
ATH.applyEdgeEffectColor(binding.recyclerView) |
|
||||||
binding.recyclerView.setOnTouchListener(object : OnTouchListener { |
|
||||||
@SuppressLint("ClickableViewAccessibility") |
|
||||||
override fun onTouch(v: View?, event: MotionEvent?): Boolean { |
|
||||||
when (event?.action) { |
|
||||||
MotionEvent.ACTION_DOWN -> { |
|
||||||
durTouchX = event.x |
|
||||||
durTouchY = event.y |
|
||||||
} |
|
||||||
MotionEvent.ACTION_MOVE -> { |
|
||||||
if (durTouchX == -1000000f) { |
|
||||||
durTouchX = event.x |
|
||||||
} |
|
||||||
if (durTouchY == -1000000f) |
|
||||||
durTouchY = event.y |
|
||||||
|
|
||||||
val dY = event.y - durTouchY //>0下拉 |
|
||||||
durTouchY = event.y |
|
||||||
if (!binding.refreshProgressBar.isAutoLoading && |
|
||||||
binding.refreshProgressBar.getSecondDurProgress() == binding.refreshProgressBar.secondFinalProgress |
|
||||||
) { |
|
||||||
binding.recyclerView.adapter?.let { |
|
||||||
if (it.itemCount > 0) { |
|
||||||
if (0 == (binding.recyclerView.layoutManager as LinearLayoutManager).findFirstCompletelyVisibleItemPosition()) { |
|
||||||
binding.refreshProgressBar.setSecondDurProgress((binding.refreshProgressBar.getSecondDurProgress() + dY / 2).toInt()) |
|
||||||
} |
|
||||||
} else { |
|
||||||
binding.refreshProgressBar.setSecondDurProgress((binding.refreshProgressBar.getSecondDurProgress() + dY / 2).toInt()) |
|
||||||
} |
|
||||||
} |
|
||||||
return binding.refreshProgressBar.getSecondDurProgress() > 0 |
|
||||||
} |
|
||||||
} |
|
||||||
MotionEvent.ACTION_UP -> { |
|
||||||
if (!binding.refreshProgressBar.isAutoLoading && |
|
||||||
binding.refreshProgressBar.secondMaxProgress > 0 && |
|
||||||
binding.refreshProgressBar.getSecondDurProgress() > 0 |
|
||||||
) { |
|
||||||
if (binding.refreshProgressBar.getSecondDurProgress() >= binding.refreshProgressBar.secondMaxProgress) { |
|
||||||
binding.refreshProgressBar.isAutoLoading = true |
|
||||||
onRefreshStart?.invoke() |
|
||||||
} else { |
|
||||||
binding.refreshProgressBar.setSecondDurProgressWithAnim(0) |
|
||||||
} |
|
||||||
} |
|
||||||
durTouchX = -1000000f |
|
||||||
durTouchY = -1000000f |
|
||||||
} |
|
||||||
} |
|
||||||
return false |
|
||||||
} |
|
||||||
}) |
|
||||||
} |
|
||||||
|
|
||||||
val recyclerView get() = binding.recyclerView |
|
||||||
|
|
||||||
fun startLoading() { |
|
||||||
binding.refreshProgressBar.isAutoLoading = true |
|
||||||
onRefreshStart?.invoke() |
|
||||||
} |
|
||||||
|
|
||||||
fun stopLoading() { |
|
||||||
binding.refreshProgressBar.isAutoLoading = false |
|
||||||
} |
|
||||||
} |
|
@ -1,27 +0,0 @@ |
|||||||
package io.legado.app.utils |
|
||||||
|
|
||||||
import kotlinx.coroutines.suspendCancellableCoroutine |
|
||||||
import okhttp3.Call |
|
||||||
import okhttp3.Callback |
|
||||||
import okhttp3.Response |
|
||||||
import java.io.IOException |
|
||||||
import kotlin.coroutines.resume |
|
||||||
import kotlin.coroutines.resumeWithException |
|
||||||
|
|
||||||
suspend fun Call.await(): Response = suspendCancellableCoroutine { block -> |
|
||||||
|
|
||||||
block.invokeOnCancellation { |
|
||||||
cancel() |
|
||||||
} |
|
||||||
|
|
||||||
enqueue(object : Callback { |
|
||||||
override fun onFailure(call: Call, e: IOException) { |
|
||||||
block.resumeWithException(e) |
|
||||||
} |
|
||||||
|
|
||||||
override fun onResponse(call: Call, response: Response) { |
|
||||||
block.resume(response) |
|
||||||
} |
|
||||||
}) |
|
||||||
|
|
||||||
} |
|
@ -1,15 +1,12 @@ |
|||||||
<?xml version="1.0" encoding="utf-8"?> |
<?xml version="1.0" encoding="utf-8"?> |
||||||
<io.legado.app.ui.widget.dynamiclayout.DynamicFrameLayout xmlns:android="http://schemas.android.com/apk/res/android" |
<androidx.swiperefreshlayout.widget.SwipeRefreshLayout xmlns:android="http://schemas.android.com/apk/res/android" |
||||||
xmlns:app="http://schemas.android.com/apk/res-auto" |
android:id="@+id/refresh_layout" |
||||||
android:id="@+id/content_view" |
|
||||||
android:layout_width="match_parent" |
android:layout_width="match_parent" |
||||||
android:layout_height="0dp" |
android:layout_height="match_parent"> |
||||||
app:layout_constraintBottom_toBottomOf="parent" |
|
||||||
app:layout_constraintTop_toBottomOf="@id/title_bar"> |
|
||||||
|
|
||||||
<io.legado.app.ui.widget.recycler.RefreshRecyclerView |
<androidx.recyclerview.widget.RecyclerView |
||||||
android:id="@+id/refresh_recycler_view" |
android:id="@+id/recycler_view" |
||||||
android:layout_width="match_parent" |
android:layout_width="match_parent" |
||||||
android:layout_height="match_parent" /> |
android:layout_height="match_parent" /> |
||||||
|
|
||||||
</io.legado.app.ui.widget.dynamiclayout.DynamicFrameLayout> |
</androidx.swiperefreshlayout.widget.SwipeRefreshLayout> |
Loading…
Reference in new issue