forked from wxxxcxx/ms-ra-forwarder
-
Notifications
You must be signed in to change notification settings - Fork 31
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
3 changed files
with
101 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
import { Request, Response } from "express"; | ||
function generateRandomString(length: number): string { | ||
const characters = | ||
"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789"; | ||
let result = ""; | ||
const charactersLength = characters.length; | ||
for (let i = 0; i < length; i++) { | ||
result += characters.charAt( | ||
Math.floor(Math.random() * charactersLength) | ||
); | ||
} | ||
return result; | ||
} | ||
|
||
module.exports = async (request: Request, response: Response) => { | ||
console.log("Import url: " + request.url); | ||
const api = request.query["api"]; | ||
const name = request.query["name"]; | ||
const voiceName = request.query["voiceName"] ?? "zh-CN-XiaoxiaoNeural"; | ||
const token = request.query["token"] ?? ""; | ||
|
||
const config = { | ||
loginUrl: "", | ||
_ClassName: "JxdAdvCustomTTS", | ||
_TTSConfigID: generateRandomString(16), | ||
httpConfigs: { | ||
headers: {}, | ||
}, | ||
ttsHandles: [ | ||
{ | ||
forGetMethod: 1, | ||
processType: 1, | ||
params: { | ||
text: "%@", | ||
voiceName: voiceName, | ||
}, | ||
url: api, | ||
parser: { | ||
playData: "ResponseData", | ||
}, | ||
httpConfigs: { | ||
useCookies: 1, | ||
headers: { | ||
authorization: `Bearer ${token}`, | ||
}, | ||
}, | ||
}, | ||
], | ||
_TTSName: name, | ||
}; | ||
response.status(200).json(config); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -13,7 +13,7 @@ | |
<nav class="navbar navbar-light bg-light"> | ||
<div class="container-fluid"> | ||
<a class="navbar-brand" target="_blank" href="https://github.com/yy4382/ms-ra-forwarder-for-ifreetime">ms-ra-forwarder-for-ifreetime</a> | ||
<ul class="navbar-nav d-flex justify-content-between align-items-center"> | ||
<ul class="navbar-nav d-flex flex-row justify-content-between align-items-center"> | ||
<li class="nav-item"> | ||
<a class="github-button" href="https://github.com/yy4382/ms-ra-forwarder-for-ifreetime" data-size="large" | ||
data-show-count="true" aria-label="Star yy4382/ms-ra-forwarder-for-ifreetime on GitHub">本项目 Star</a> | ||
|
@@ -96,8 +96,10 @@ | |
<div class="col"> | ||
<button id="previewButton" type="button" class="btn btn-secondary" onclick="preview()">测试</button> | ||
<button type="button" class="btn btn-primary" onclick='createLegadoUrl()'>生成阅读(legado)语音引擎链接</button> | ||
<button type="button" class="btn btn-primary" onclick='createIReadUrl()'>生成爱阅记导入链接</button> | ||
</div> | ||
</div> | ||
</div> | ||
</form> | ||
<div style="height:50px"></div> | ||
</div> | ||
|
@@ -123,6 +125,29 @@ <h5 class="modal-title">阅读链接</h5> | |
</div> | ||
</div> | ||
</div> | ||
<div id="iReadUrlModal" class="modal " tabindex="-1"> | ||
<div class="modal-dialog modal-lg"> | ||
<div class="modal-content"> | ||
<div class="modal-header"> | ||
<h5 class="modal-title">爱阅记链接</h5> | ||
<button type="button" class="btn-close" data-bs-dismiss="modal" aria-label="Close"></button> | ||
</div> | ||
<div class="modal-body"> | ||
<div id="iReadUrlQRCode" style="text-align:center"> | ||
</div> | ||
<div class="row"> | ||
<p>音频格式暂时未支持。</p> | ||
</div> | ||
<div class="row"> | ||
<textarea id="iReadUrl" class="form-control" readonly rows="3" cols="2" value></textarea> | ||
</div> | ||
<div class="row" style="margin-top: 10px;"> | ||
<a id="iReadImportButton" class="btn btn-primary" href="">一键导入到爱阅记</a> | ||
</div> | ||
</div> | ||
</div> | ||
</div> | ||
</div> | ||
<script async defer src="https://buttons.github.io/buttons.js"></script> | ||
<script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/js/bootstrap.bundle.min.js" | ||
integrity="sha384-ka7Sk0Gln4gmtz2MlQnikT1wXgYsOg+OMhuP+IlRH9sENBO0LRn5q+8nbTov4+1p" | ||
|
@@ -146,16 +171,16 @@ <h5 class="modal-title">阅读链接</h5> | |
}); | ||
|
||
function refreshVoice() { | ||
let voiceElelement = document.getElementsByName('voiceName')[0]; | ||
voiceElelement.innerHTMl = ''; | ||
let voiceElement = document.getElementsByName('voiceName')[0]; | ||
voiceElement.innerHTMl = ''; | ||
voices.forEach(item => { | ||
let option = document.createElement('option'); | ||
option.value = item['ShortName']; | ||
option.innerText = item['FriendlyName']; | ||
if (item['ShortName'] == 'zh-CN-XiaoxiaoNeural') { | ||
option.selected = true; | ||
} | ||
voiceElelement.append(option) | ||
voiceElement.append(option) | ||
}); | ||
updateConfigName(); | ||
} | ||
|
@@ -240,6 +265,25 @@ <h5 class="modal-title">阅读链接</h5> | |
document.getElementById('legadoUrl').value = url; | ||
document.getElementById('legadoImportButton').href = 'legado://import/httpTTS?src=' + encodeURIComponent(url); | ||
} | ||
function createIReadUrl() { | ||
let name = document.getElementsByName('name')[0].value; | ||
let voiceName = document.getElementsByName('voiceName')[0].value; | ||
let voiceFormat = document.getElementsByName('voiceFormat')[0].value; | ||
let token = document.getElementsByName('token')[0].value; | ||
let previewText = document.getElementsByName('previewText')[0].value; | ||
let url = window.location.protocol + '//' + window.location.host + '/api/ireadnote' | ||
+ '?api=' + encodeURIComponent(window.location.protocol + '//' + window.location.host + '/api/aiyue') | ||
+ '&name=' + encodeURIComponent(name) | ||
+ '&voiceName=' + encodeURIComponent(voiceName) | ||
// + '&voiceFormat=' + encodeURIComponent(voiceFormat) | ||
+ '&token=' + encodeURIComponent(token); | ||
let svg = new QRCode(url).svg(); | ||
let modal = new bootstrap.Modal(document.getElementById('iReadUrlModal')) | ||
modal.show(); | ||
document.getElementById('iReadUrlQRCode').innerHTML = svg; | ||
document.getElementById('iReadUrl').value = url; | ||
document.getElementById('iReadImportButton').href = 'iReadNote://import/itts=' + url; | ||
} | ||
</script> | ||
</body> | ||
|
||
|