mirror of
https://github.com/openvk/openvk
synced 2025-04-23 16:43:02 +03:00
Add IDv3 autofill
This commit is contained in:
parent
371f8d7110
commit
4f4f9e2cb1
3 changed files with 29 additions and 2 deletions
|
@ -72,8 +72,10 @@
|
|||
</table>
|
||||
</div>
|
||||
|
||||
<script>
|
||||
u("#audio_input").on("change", function(e) {
|
||||
<script type="module">
|
||||
import * as id3 from "/assets/packages/static/openvk/js/node_modules/id3js/lib/id3.js";
|
||||
|
||||
u("#audio_input").on("change", async function(e) {
|
||||
if(e.currentTarget.files.length <= 0)
|
||||
return;
|
||||
|
||||
|
@ -99,6 +101,25 @@
|
|||
|
||||
Function.noop
|
||||
]);
|
||||
|
||||
let tags = await id3.fromFile(e.currentTarget.files[0]);
|
||||
if(tags != null) {
|
||||
console.log("ID" + tags.kind + " detected, setting values...");
|
||||
|
||||
if(tags.title != null)
|
||||
document.querySelector(".ovk-diag input[name=name]").value = tags.title;
|
||||
|
||||
if(tags.artist != null)
|
||||
document.querySelector(".ovk-diag input[name=performer]").value = tags.artist;
|
||||
|
||||
if(tags.genre != null) {
|
||||
if(document.querySelector(".ovk-diag select[name=genre] > option[value='" + tags.genre + "']") != null) {
|
||||
document.querySelector(".ovk-diag select[name=genre]").value = tags.genre;
|
||||
} else {
|
||||
console.warn("Unknown genre: " + tags.genre);
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
</script>
|
||||
{/block}
|
||||
|
|
|
@ -3,6 +3,7 @@
|
|||
"@atlassian/aui": "^8.5.1",
|
||||
"create-react-class": "^15.7.0",
|
||||
"dashjs": "^4.3.0",
|
||||
"id3js": "^2.1.1",
|
||||
"jquery": "^2.1.0",
|
||||
"knockout": "^3.5.1",
|
||||
"ky": "^0.19.0",
|
||||
|
|
|
@ -128,6 +128,11 @@ iconv-lite@^0.6.2:
|
|||
dependencies:
|
||||
safer-buffer ">= 2.1.2 < 3.0.0"
|
||||
|
||||
id3js@^2.1.1:
|
||||
version "2.1.1"
|
||||
resolved "https://registry.yarnpkg.com/id3js/-/id3js-2.1.1.tgz#0c307d0d2f194bc5fa7a809bbed0b1a93577f16d"
|
||||
integrity sha512-9Gi+sG0RHSa5qn8hkwi2KCl+2jV8YrtiZidXbOO3uLfRAxc2jilRg0fiQ3CbeoAmR7G7ap3RVs1kqUVhIyZaog==
|
||||
|
||||
ieee754@^1.1.8:
|
||||
version "1.2.1"
|
||||
resolved "https://registry.yarnpkg.com/ieee754/-/ieee754-1.2.1.tgz#8eb7a10a63fff25d15a57b001586d177d1b0d352"
|
||||
|
|
Loading…
Reference in a new issue