├── LICENSE
├── README.md
├── current
├── README.md
├── krc
│ ├── README.md
│ └── parser
│ │ └── krc.js
├── qrc
│ ├── README.md
│ ├── parser
│ │ └── qrcjson.js
│ └── searcher
│ │ └── qqmusic_ex.js
└── yrc
│ ├── README.md
│ ├── parser
│ └── yrc.js
│ └── searcher
│ └── netease_ex.js
└── legacy
├── README.md
├── krc_parser_plus.js
└── qqmusic_plus.js
/LICENSE:
--------------------------------------------------------------------------------
1 | GNU GENERAL PUBLIC LICENSE
2 | Version 3, 29 June 2007
3 |
4 | Copyright (C) 2007 Free Software Foundation, Inc.
5 | Everyone is permitted to copy and distribute verbatim copies
6 | of this license document, but changing it is not allowed.
7 |
8 | Preamble
9 |
10 | The GNU General Public License is a free, copyleft license for
11 | software and other kinds of works.
12 |
13 | The licenses for most software and other practical works are designed
14 | to take away your freedom to share and change the works. By contrast,
15 | the GNU General Public License is intended to guarantee your freedom to
16 | share and change all versions of a program--to make sure it remains free
17 | software for all its users. We, the Free Software Foundation, use the
18 | GNU General Public License for most of our software; it applies also to
19 | any other work released this way by its authors. You can apply it to
20 | your programs, too.
21 |
22 | When we speak of free software, we are referring to freedom, not
23 | price. Our General Public Licenses are designed to make sure that you
24 | have the freedom to distribute copies of free software (and charge for
25 | them if you wish), that you receive source code or can get it if you
26 | want it, that you can change the software or use pieces of it in new
27 | free programs, and that you know you can do these things.
28 |
29 | To protect your rights, we need to prevent others from denying you
30 | these rights or asking you to surrender the rights. Therefore, you have
31 | certain responsibilities if you distribute copies of the software, or if
32 | you modify it: responsibilities to respect the freedom of others.
33 |
34 | For example, if you distribute copies of such a program, whether
35 | gratis or for a fee, you must pass on to the recipients the same
36 | freedoms that you received. You must make sure that they, too, receive
37 | or can get the source code. And you must show them these terms so they
38 | know their rights.
39 |
40 | Developers that use the GNU GPL protect your rights with two steps:
41 | (1) assert copyright on the software, and (2) offer you this License
42 | giving you legal permission to copy, distribute and/or modify it.
43 |
44 | For the developers' and authors' protection, the GPL clearly explains
45 | that there is no warranty for this free software. For both users' and
46 | authors' sake, the GPL requires that modified versions be marked as
47 | changed, so that their problems will not be attributed erroneously to
48 | authors of previous versions.
49 |
50 | Some devices are designed to deny users access to install or run
51 | modified versions of the software inside them, although the manufacturer
52 | can do so. This is fundamentally incompatible with the aim of
53 | protecting users' freedom to change the software. The systematic
54 | pattern of such abuse occurs in the area of products for individuals to
55 | use, which is precisely where it is most unacceptable. Therefore, we
56 | have designed this version of the GPL to prohibit the practice for those
57 | products. If such problems arise substantially in other domains, we
58 | stand ready to extend this provision to those domains in future versions
59 | of the GPL, as needed to protect the freedom of users.
60 |
61 | Finally, every program is threatened constantly by software patents.
62 | States should not allow patents to restrict development and use of
63 | software on general-purpose computers, but in those that do, we wish to
64 | avoid the special danger that patents applied to a free program could
65 | make it effectively proprietary. To prevent this, the GPL assures that
66 | patents cannot be used to render the program non-free.
67 |
68 | The precise terms and conditions for copying, distribution and
69 | modification follow.
70 |
71 | TERMS AND CONDITIONS
72 |
73 | 0. Definitions.
74 |
75 | "This License" refers to version 3 of the GNU General Public License.
76 |
77 | "Copyright" also means copyright-like laws that apply to other kinds of
78 | works, such as semiconductor masks.
79 |
80 | "The Program" refers to any copyrightable work licensed under this
81 | License. Each licensee is addressed as "you". "Licensees" and
82 | "recipients" may be individuals or organizations.
83 |
84 | To "modify" a work means to copy from or adapt all or part of the work
85 | in a fashion requiring copyright permission, other than the making of an
86 | exact copy. The resulting work is called a "modified version" of the
87 | earlier work or a work "based on" the earlier work.
88 |
89 | A "covered work" means either the unmodified Program or a work based
90 | on the Program.
91 |
92 | To "propagate" a work means to do anything with it that, without
93 | permission, would make you directly or secondarily liable for
94 | infringement under applicable copyright law, except executing it on a
95 | computer or modifying a private copy. Propagation includes copying,
96 | distribution (with or without modification), making available to the
97 | public, and in some countries other activities as well.
98 |
99 | To "convey" a work means any kind of propagation that enables other
100 | parties to make or receive copies. Mere interaction with a user through
101 | a computer network, with no transfer of a copy, is not conveying.
102 |
103 | An interactive user interface displays "Appropriate Legal Notices"
104 | to the extent that it includes a convenient and prominently visible
105 | feature that (1) displays an appropriate copyright notice, and (2)
106 | tells the user that there is no warranty for the work (except to the
107 | extent that warranties are provided), that licensees may convey the
108 | work under this License, and how to view a copy of this License. If
109 | the interface presents a list of user commands or options, such as a
110 | menu, a prominent item in the list meets this criterion.
111 |
112 | 1. Source Code.
113 |
114 | The "source code" for a work means the preferred form of the work
115 | for making modifications to it. "Object code" means any non-source
116 | form of a work.
117 |
118 | A "Standard Interface" means an interface that either is an official
119 | standard defined by a recognized standards body, or, in the case of
120 | interfaces specified for a particular programming language, one that
121 | is widely used among developers working in that language.
122 |
123 | The "System Libraries" of an executable work include anything, other
124 | than the work as a whole, that (a) is included in the normal form of
125 | packaging a Major Component, but which is not part of that Major
126 | Component, and (b) serves only to enable use of the work with that
127 | Major Component, or to implement a Standard Interface for which an
128 | implementation is available to the public in source code form. A
129 | "Major Component", in this context, means a major essential component
130 | (kernel, window system, and so on) of the specific operating system
131 | (if any) on which the executable work runs, or a compiler used to
132 | produce the work, or an object code interpreter used to run it.
133 |
134 | The "Corresponding Source" for a work in object code form means all
135 | the source code needed to generate, install, and (for an executable
136 | work) run the object code and to modify the work, including scripts to
137 | control those activities. However, it does not include the work's
138 | System Libraries, or general-purpose tools or generally available free
139 | programs which are used unmodified in performing those activities but
140 | which are not part of the work. For example, Corresponding Source
141 | includes interface definition files associated with source files for
142 | the work, and the source code for shared libraries and dynamically
143 | linked subprograms that the work is specifically designed to require,
144 | such as by intimate data communication or control flow between those
145 | subprograms and other parts of the work.
146 |
147 | The Corresponding Source need not include anything that users
148 | can regenerate automatically from other parts of the Corresponding
149 | Source.
150 |
151 | The Corresponding Source for a work in source code form is that
152 | same work.
153 |
154 | 2. Basic Permissions.
155 |
156 | All rights granted under this License are granted for the term of
157 | copyright on the Program, and are irrevocable provided the stated
158 | conditions are met. This License explicitly affirms your unlimited
159 | permission to run the unmodified Program. The output from running a
160 | covered work is covered by this License only if the output, given its
161 | content, constitutes a covered work. This License acknowledges your
162 | rights of fair use or other equivalent, as provided by copyright law.
163 |
164 | You may make, run and propagate covered works that you do not
165 | convey, without conditions so long as your license otherwise remains
166 | in force. You may convey covered works to others for the sole purpose
167 | of having them make modifications exclusively for you, or provide you
168 | with facilities for running those works, provided that you comply with
169 | the terms of this License in conveying all material for which you do
170 | not control copyright. Those thus making or running the covered works
171 | for you must do so exclusively on your behalf, under your direction
172 | and control, on terms that prohibit them from making any copies of
173 | your copyrighted material outside their relationship with you.
174 |
175 | Conveying under any other circumstances is permitted solely under
176 | the conditions stated below. Sublicensing is not allowed; section 10
177 | makes it unnecessary.
178 |
179 | 3. Protecting Users' Legal Rights From Anti-Circumvention Law.
180 |
181 | No covered work shall be deemed part of an effective technological
182 | measure under any applicable law fulfilling obligations under article
183 | 11 of the WIPO copyright treaty adopted on 20 December 1996, or
184 | similar laws prohibiting or restricting circumvention of such
185 | measures.
186 |
187 | When you convey a covered work, you waive any legal power to forbid
188 | circumvention of technological measures to the extent such circumvention
189 | is effected by exercising rights under this License with respect to
190 | the covered work, and you disclaim any intention to limit operation or
191 | modification of the work as a means of enforcing, against the work's
192 | users, your or third parties' legal rights to forbid circumvention of
193 | technological measures.
194 |
195 | 4. Conveying Verbatim Copies.
196 |
197 | You may convey verbatim copies of the Program's source code as you
198 | receive it, in any medium, provided that you conspicuously and
199 | appropriately publish on each copy an appropriate copyright notice;
200 | keep intact all notices stating that this License and any
201 | non-permissive terms added in accord with section 7 apply to the code;
202 | keep intact all notices of the absence of any warranty; and give all
203 | recipients a copy of this License along with the Program.
204 |
205 | You may charge any price or no price for each copy that you convey,
206 | and you may offer support or warranty protection for a fee.
207 |
208 | 5. Conveying Modified Source Versions.
209 |
210 | You may convey a work based on the Program, or the modifications to
211 | produce it from the Program, in the form of source code under the
212 | terms of section 4, provided that you also meet all of these conditions:
213 |
214 | a) The work must carry prominent notices stating that you modified
215 | it, and giving a relevant date.
216 |
217 | b) The work must carry prominent notices stating that it is
218 | released under this License and any conditions added under section
219 | 7. This requirement modifies the requirement in section 4 to
220 | "keep intact all notices".
221 |
222 | c) You must license the entire work, as a whole, under this
223 | License to anyone who comes into possession of a copy. This
224 | License will therefore apply, along with any applicable section 7
225 | additional terms, to the whole of the work, and all its parts,
226 | regardless of how they are packaged. This License gives no
227 | permission to license the work in any other way, but it does not
228 | invalidate such permission if you have separately received it.
229 |
230 | d) If the work has interactive user interfaces, each must display
231 | Appropriate Legal Notices; however, if the Program has interactive
232 | interfaces that do not display Appropriate Legal Notices, your
233 | work need not make them do so.
234 |
235 | A compilation of a covered work with other separate and independent
236 | works, which are not by their nature extensions of the covered work,
237 | and which are not combined with it such as to form a larger program,
238 | in or on a volume of a storage or distribution medium, is called an
239 | "aggregate" if the compilation and its resulting copyright are not
240 | used to limit the access or legal rights of the compilation's users
241 | beyond what the individual works permit. Inclusion of a covered work
242 | in an aggregate does not cause this License to apply to the other
243 | parts of the aggregate.
244 |
245 | 6. Conveying Non-Source Forms.
246 |
247 | You may convey a covered work in object code form under the terms
248 | of sections 4 and 5, provided that you also convey the
249 | machine-readable Corresponding Source under the terms of this License,
250 | in one of these ways:
251 |
252 | a) Convey the object code in, or embodied in, a physical product
253 | (including a physical distribution medium), accompanied by the
254 | Corresponding Source fixed on a durable physical medium
255 | customarily used for software interchange.
256 |
257 | b) Convey the object code in, or embodied in, a physical product
258 | (including a physical distribution medium), accompanied by a
259 | written offer, valid for at least three years and valid for as
260 | long as you offer spare parts or customer support for that product
261 | model, to give anyone who possesses the object code either (1) a
262 | copy of the Corresponding Source for all the software in the
263 | product that is covered by this License, on a durable physical
264 | medium customarily used for software interchange, for a price no
265 | more than your reasonable cost of physically performing this
266 | conveying of source, or (2) access to copy the
267 | Corresponding Source from a network server at no charge.
268 |
269 | c) Convey individual copies of the object code with a copy of the
270 | written offer to provide the Corresponding Source. This
271 | alternative is allowed only occasionally and noncommercially, and
272 | only if you received the object code with such an offer, in accord
273 | with subsection 6b.
274 |
275 | d) Convey the object code by offering access from a designated
276 | place (gratis or for a charge), and offer equivalent access to the
277 | Corresponding Source in the same way through the same place at no
278 | further charge. You need not require recipients to copy the
279 | Corresponding Source along with the object code. If the place to
280 | copy the object code is a network server, the Corresponding Source
281 | may be on a different server (operated by you or a third party)
282 | that supports equivalent copying facilities, provided you maintain
283 | clear directions next to the object code saying where to find the
284 | Corresponding Source. Regardless of what server hosts the
285 | Corresponding Source, you remain obligated to ensure that it is
286 | available for as long as needed to satisfy these requirements.
287 |
288 | e) Convey the object code using peer-to-peer transmission, provided
289 | you inform other peers where the object code and Corresponding
290 | Source of the work are being offered to the general public at no
291 | charge under subsection 6d.
292 |
293 | A separable portion of the object code, whose source code is excluded
294 | from the Corresponding Source as a System Library, need not be
295 | included in conveying the object code work.
296 |
297 | A "User Product" is either (1) a "consumer product", which means any
298 | tangible personal property which is normally used for personal, family,
299 | or household purposes, or (2) anything designed or sold for incorporation
300 | into a dwelling. In determining whether a product is a consumer product,
301 | doubtful cases shall be resolved in favor of coverage. For a particular
302 | product received by a particular user, "normally used" refers to a
303 | typical or common use of that class of product, regardless of the status
304 | of the particular user or of the way in which the particular user
305 | actually uses, or expects or is expected to use, the product. A product
306 | is a consumer product regardless of whether the product has substantial
307 | commercial, industrial or non-consumer uses, unless such uses represent
308 | the only significant mode of use of the product.
309 |
310 | "Installation Information" for a User Product means any methods,
311 | procedures, authorization keys, or other information required to install
312 | and execute modified versions of a covered work in that User Product from
313 | a modified version of its Corresponding Source. The information must
314 | suffice to ensure that the continued functioning of the modified object
315 | code is in no case prevented or interfered with solely because
316 | modification has been made.
317 |
318 | If you convey an object code work under this section in, or with, or
319 | specifically for use in, a User Product, and the conveying occurs as
320 | part of a transaction in which the right of possession and use of the
321 | User Product is transferred to the recipient in perpetuity or for a
322 | fixed term (regardless of how the transaction is characterized), the
323 | Corresponding Source conveyed under this section must be accompanied
324 | by the Installation Information. But this requirement does not apply
325 | if neither you nor any third party retains the ability to install
326 | modified object code on the User Product (for example, the work has
327 | been installed in ROM).
328 |
329 | The requirement to provide Installation Information does not include a
330 | requirement to continue to provide support service, warranty, or updates
331 | for a work that has been modified or installed by the recipient, or for
332 | the User Product in which it has been modified or installed. Access to a
333 | network may be denied when the modification itself materially and
334 | adversely affects the operation of the network or violates the rules and
335 | protocols for communication across the network.
336 |
337 | Corresponding Source conveyed, and Installation Information provided,
338 | in accord with this section must be in a format that is publicly
339 | documented (and with an implementation available to the public in
340 | source code form), and must require no special password or key for
341 | unpacking, reading or copying.
342 |
343 | 7. Additional Terms.
344 |
345 | "Additional permissions" are terms that supplement the terms of this
346 | License by making exceptions from one or more of its conditions.
347 | Additional permissions that are applicable to the entire Program shall
348 | be treated as though they were included in this License, to the extent
349 | that they are valid under applicable law. If additional permissions
350 | apply only to part of the Program, that part may be used separately
351 | under those permissions, but the entire Program remains governed by
352 | this License without regard to the additional permissions.
353 |
354 | When you convey a copy of a covered work, you may at your option
355 | remove any additional permissions from that copy, or from any part of
356 | it. (Additional permissions may be written to require their own
357 | removal in certain cases when you modify the work.) You may place
358 | additional permissions on material, added by you to a covered work,
359 | for which you have or can give appropriate copyright permission.
360 |
361 | Notwithstanding any other provision of this License, for material you
362 | add to a covered work, you may (if authorized by the copyright holders of
363 | that material) supplement the terms of this License with terms:
364 |
365 | a) Disclaiming warranty or limiting liability differently from the
366 | terms of sections 15 and 16 of this License; or
367 |
368 | b) Requiring preservation of specified reasonable legal notices or
369 | author attributions in that material or in the Appropriate Legal
370 | Notices displayed by works containing it; or
371 |
372 | c) Prohibiting misrepresentation of the origin of that material, or
373 | requiring that modified versions of such material be marked in
374 | reasonable ways as different from the original version; or
375 |
376 | d) Limiting the use for publicity purposes of names of licensors or
377 | authors of the material; or
378 |
379 | e) Declining to grant rights under trademark law for use of some
380 | trade names, trademarks, or service marks; or
381 |
382 | f) Requiring indemnification of licensors and authors of that
383 | material by anyone who conveys the material (or modified versions of
384 | it) with contractual assumptions of liability to the recipient, for
385 | any liability that these contractual assumptions directly impose on
386 | those licensors and authors.
387 |
388 | All other non-permissive additional terms are considered "further
389 | restrictions" within the meaning of section 10. If the Program as you
390 | received it, or any part of it, contains a notice stating that it is
391 | governed by this License along with a term that is a further
392 | restriction, you may remove that term. If a license document contains
393 | a further restriction but permits relicensing or conveying under this
394 | License, you may add to a covered work material governed by the terms
395 | of that license document, provided that the further restriction does
396 | not survive such relicensing or conveying.
397 |
398 | If you add terms to a covered work in accord with this section, you
399 | must place, in the relevant source files, a statement of the
400 | additional terms that apply to those files, or a notice indicating
401 | where to find the applicable terms.
402 |
403 | Additional terms, permissive or non-permissive, may be stated in the
404 | form of a separately written license, or stated as exceptions;
405 | the above requirements apply either way.
406 |
407 | 8. Termination.
408 |
409 | You may not propagate or modify a covered work except as expressly
410 | provided under this License. Any attempt otherwise to propagate or
411 | modify it is void, and will automatically terminate your rights under
412 | this License (including any patent licenses granted under the third
413 | paragraph of section 11).
414 |
415 | However, if you cease all violation of this License, then your
416 | license from a particular copyright holder is reinstated (a)
417 | provisionally, unless and until the copyright holder explicitly and
418 | finally terminates your license, and (b) permanently, if the copyright
419 | holder fails to notify you of the violation by some reasonable means
420 | prior to 60 days after the cessation.
421 |
422 | Moreover, your license from a particular copyright holder is
423 | reinstated permanently if the copyright holder notifies you of the
424 | violation by some reasonable means, this is the first time you have
425 | received notice of violation of this License (for any work) from that
426 | copyright holder, and you cure the violation prior to 30 days after
427 | your receipt of the notice.
428 |
429 | Termination of your rights under this section does not terminate the
430 | licenses of parties who have received copies or rights from you under
431 | this License. If your rights have been terminated and not permanently
432 | reinstated, you do not qualify to receive new licenses for the same
433 | material under section 10.
434 |
435 | 9. Acceptance Not Required for Having Copies.
436 |
437 | You are not required to accept this License in order to receive or
438 | run a copy of the Program. Ancillary propagation of a covered work
439 | occurring solely as a consequence of using peer-to-peer transmission
440 | to receive a copy likewise does not require acceptance. However,
441 | nothing other than this License grants you permission to propagate or
442 | modify any covered work. These actions infringe copyright if you do
443 | not accept this License. Therefore, by modifying or propagating a
444 | covered work, you indicate your acceptance of this License to do so.
445 |
446 | 10. Automatic Licensing of Downstream Recipients.
447 |
448 | Each time you convey a covered work, the recipient automatically
449 | receives a license from the original licensors, to run, modify and
450 | propagate that work, subject to this License. You are not responsible
451 | for enforcing compliance by third parties with this License.
452 |
453 | An "entity transaction" is a transaction transferring control of an
454 | organization, or substantially all assets of one, or subdividing an
455 | organization, or merging organizations. If propagation of a covered
456 | work results from an entity transaction, each party to that
457 | transaction who receives a copy of the work also receives whatever
458 | licenses to the work the party's predecessor in interest had or could
459 | give under the previous paragraph, plus a right to possession of the
460 | Corresponding Source of the work from the predecessor in interest, if
461 | the predecessor has it or can get it with reasonable efforts.
462 |
463 | You may not impose any further restrictions on the exercise of the
464 | rights granted or affirmed under this License. For example, you may
465 | not impose a license fee, royalty, or other charge for exercise of
466 | rights granted under this License, and you may not initiate litigation
467 | (including a cross-claim or counterclaim in a lawsuit) alleging that
468 | any patent claim is infringed by making, using, selling, offering for
469 | sale, or importing the Program or any portion of it.
470 |
471 | 11. Patents.
472 |
473 | A "contributor" is a copyright holder who authorizes use under this
474 | License of the Program or a work on which the Program is based. The
475 | work thus licensed is called the contributor's "contributor version".
476 |
477 | A contributor's "essential patent claims" are all patent claims
478 | owned or controlled by the contributor, whether already acquired or
479 | hereafter acquired, that would be infringed by some manner, permitted
480 | by this License, of making, using, or selling its contributor version,
481 | but do not include claims that would be infringed only as a
482 | consequence of further modification of the contributor version. For
483 | purposes of this definition, "control" includes the right to grant
484 | patent sublicenses in a manner consistent with the requirements of
485 | this License.
486 |
487 | Each contributor grants you a non-exclusive, worldwide, royalty-free
488 | patent license under the contributor's essential patent claims, to
489 | make, use, sell, offer for sale, import and otherwise run, modify and
490 | propagate the contents of its contributor version.
491 |
492 | In the following three paragraphs, a "patent license" is any express
493 | agreement or commitment, however denominated, not to enforce a patent
494 | (such as an express permission to practice a patent or covenant not to
495 | sue for patent infringement). To "grant" such a patent license to a
496 | party means to make such an agreement or commitment not to enforce a
497 | patent against the party.
498 |
499 | If you convey a covered work, knowingly relying on a patent license,
500 | and the Corresponding Source of the work is not available for anyone
501 | to copy, free of charge and under the terms of this License, through a
502 | publicly available network server or other readily accessible means,
503 | then you must either (1) cause the Corresponding Source to be so
504 | available, or (2) arrange to deprive yourself of the benefit of the
505 | patent license for this particular work, or (3) arrange, in a manner
506 | consistent with the requirements of this License, to extend the patent
507 | license to downstream recipients. "Knowingly relying" means you have
508 | actual knowledge that, but for the patent license, your conveying the
509 | covered work in a country, or your recipient's use of the covered work
510 | in a country, would infringe one or more identifiable patents in that
511 | country that you have reason to believe are valid.
512 |
513 | If, pursuant to or in connection with a single transaction or
514 | arrangement, you convey, or propagate by procuring conveyance of, a
515 | covered work, and grant a patent license to some of the parties
516 | receiving the covered work authorizing them to use, propagate, modify
517 | or convey a specific copy of the covered work, then the patent license
518 | you grant is automatically extended to all recipients of the covered
519 | work and works based on it.
520 |
521 | A patent license is "discriminatory" if it does not include within
522 | the scope of its coverage, prohibits the exercise of, or is
523 | conditioned on the non-exercise of one or more of the rights that are
524 | specifically granted under this License. You may not convey a covered
525 | work if you are a party to an arrangement with a third party that is
526 | in the business of distributing software, under which you make payment
527 | to the third party based on the extent of your activity of conveying
528 | the work, and under which the third party grants, to any of the
529 | parties who would receive the covered work from you, a discriminatory
530 | patent license (a) in connection with copies of the covered work
531 | conveyed by you (or copies made from those copies), or (b) primarily
532 | for and in connection with specific products or compilations that
533 | contain the covered work, unless you entered into that arrangement,
534 | or that patent license was granted, prior to 28 March 2007.
535 |
536 | Nothing in this License shall be construed as excluding or limiting
537 | any implied license or other defenses to infringement that may
538 | otherwise be available to you under applicable patent law.
539 |
540 | 12. No Surrender of Others' Freedom.
541 |
542 | If conditions are imposed on you (whether by court order, agreement or
543 | otherwise) that contradict the conditions of this License, they do not
544 | excuse you from the conditions of this License. If you cannot convey a
545 | covered work so as to satisfy simultaneously your obligations under this
546 | License and any other pertinent obligations, then as a consequence you may
547 | not convey it at all. For example, if you agree to terms that obligate you
548 | to collect a royalty for further conveying from those to whom you convey
549 | the Program, the only way you could satisfy both those terms and this
550 | License would be to refrain entirely from conveying the Program.
551 |
552 | 13. Use with the GNU Affero General Public License.
553 |
554 | Notwithstanding any other provision of this License, you have
555 | permission to link or combine any covered work with a work licensed
556 | under version 3 of the GNU Affero General Public License into a single
557 | combined work, and to convey the resulting work. The terms of this
558 | License will continue to apply to the part which is the covered work,
559 | but the special requirements of the GNU Affero General Public License,
560 | section 13, concerning interaction through a network will apply to the
561 | combination as such.
562 |
563 | 14. Revised Versions of this License.
564 |
565 | The Free Software Foundation may publish revised and/or new versions of
566 | the GNU General Public License from time to time. Such new versions will
567 | be similar in spirit to the present version, but may differ in detail to
568 | address new problems or concerns.
569 |
570 | Each version is given a distinguishing version number. If the
571 | Program specifies that a certain numbered version of the GNU General
572 | Public License "or any later version" applies to it, you have the
573 | option of following the terms and conditions either of that numbered
574 | version or of any later version published by the Free Software
575 | Foundation. If the Program does not specify a version number of the
576 | GNU General Public License, you may choose any version ever published
577 | by the Free Software Foundation.
578 |
579 | If the Program specifies that a proxy can decide which future
580 | versions of the GNU General Public License can be used, that proxy's
581 | public statement of acceptance of a version permanently authorizes you
582 | to choose that version for the Program.
583 |
584 | Later license versions may give you additional or different
585 | permissions. However, no additional obligations are imposed on any
586 | author or copyright holder as a result of your choosing to follow a
587 | later version.
588 |
589 | 15. Disclaimer of Warranty.
590 |
591 | THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY
592 | APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT
593 | HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY
594 | OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO,
595 | THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
596 | PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM
597 | IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF
598 | ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
599 |
600 | 16. Limitation of Liability.
601 |
602 | IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
603 | WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS
604 | THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY
605 | GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE
606 | USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF
607 | DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD
608 | PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS),
609 | EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF
610 | SUCH DAMAGES.
611 |
612 | 17. Interpretation of Sections 15 and 16.
613 |
614 | If the disclaimer of warranty and limitation of liability provided
615 | above cannot be given local legal effect according to their terms,
616 | reviewing courts shall apply local law that most closely approximates
617 | an absolute waiver of all civil liability in connection with the
618 | Program, unless a warranty or assumption of liability accompanies a
619 | copy of the Program in return for a fee.
620 |
621 | END OF TERMS AND CONDITIONS
622 |
623 | How to Apply These Terms to Your New Programs
624 |
625 | If you develop a new program, and you want it to be of the greatest
626 | possible use to the public, the best way to achieve this is to make it
627 | free software which everyone can redistribute and change under these terms.
628 |
629 | To do so, attach the following notices to the program. It is safest
630 | to attach them to the start of each source file to most effectively
631 | state the exclusion of warranty; and each file should have at least
632 | the "copyright" line and a pointer to where the full notice is found.
633 |
634 |
635 | Copyright (C)
636 |
637 | This program is free software: you can redistribute it and/or modify
638 | it under the terms of the GNU General Public License as published by
639 | the Free Software Foundation, either version 3 of the License, or
640 | (at your option) any later version.
641 |
642 | This program is distributed in the hope that it will be useful,
643 | but WITHOUT ANY WARRANTY; without even the implied warranty of
644 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
645 | GNU General Public License for more details.
646 |
647 | You should have received a copy of the GNU General Public License
648 | along with this program. If not, see .
649 |
650 | Also add information on how to contact you by electronic and paper mail.
651 |
652 | If the program does terminal interaction, make it output a short
653 | notice like this when it starts in an interactive mode:
654 |
655 | Copyright (C)
656 | This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
657 | This is free software, and you are welcome to redistribute it
658 | under certain conditions; type `show c' for details.
659 |
660 | The hypothetical commands `show w' and `show c' should show the appropriate
661 | parts of the General Public License. Of course, your program's commands
662 | might be different; for a GUI interface, you would use an "about box".
663 |
664 | You should also get your employer (if you work as a programmer) or school,
665 | if any, to sign a "copyright disclaimer" for the program, if necessary.
666 | For more information on this, and how to apply and follow the GNU GPL, see
667 | .
668 |
669 | The GNU General Public License does not permit incorporating your program
670 | into proprietary programs. If your program is a subroutine library, you
671 | may consider it more useful to permit linking proprietary applications with
672 | the library. If this is what you want to do, use the GNU Lesser General
673 | Public License instead of this License. But first, please read
674 | .
675 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # ESLyric-LyricsSource
2 |
3 | 一些用于 ESLyric 的高级歌词源,将 KRC (酷狗)、QRC (QQ 音乐) 和 YRC (网易云音乐) 的逐字歌词和翻译歌词转换为 ESLyric 支持的格式。
4 |
5 | **不要**在这里反馈任何与 ESLyric 插件相关的问题,我**不是**其作者,不对其负任何责任!
6 |
7 | 佛系更新,有问题**肯定不会**及时解决。
8 |
9 | ## 用哪个版本
10 |
11 | ## Legacy
12 |
13 | 如果你的 ESLyric 是老版本,用这里的文件。
14 |
15 | 仅酷狗支持逐字歌词和翻译歌词。
16 |
17 | ## Current
18 |
19 | 新版本 ESlyric 使用这里的文件。
20 |
21 | 酷狗、QQ 音乐和网易云音乐三个歌词源都支持逐字和翻译歌词。
22 |
--------------------------------------------------------------------------------
/current/README.md:
--------------------------------------------------------------------------------
1 | # Current
2 |
3 | 仅供新版本 ESLyric 使用。
4 |
5 | 歌词将被转换为 LRC [增强格式](https://en.wikipedia.org/wiki/LRC_(file_format)#Enhanced_format),与旧版本 ESLyric 不兼容。
6 |
7 | 根据需要复制对应目录下的文件即可。
8 |
--------------------------------------------------------------------------------
/current/krc/README.md:
--------------------------------------------------------------------------------
1 | # KRC Parser Plus (新版 ESLyric)
2 |
3 | 用本仓库 `parser` 文件夹下的 `krc.js` 替换 ESLyric 对应的文件。
4 |
--------------------------------------------------------------------------------
/current/krc/parser/krc.js:
--------------------------------------------------------------------------------
1 | /**
2 | * KRC Parser Plus
3 | * Original Author: ohyeah
4 | * Modified by: Robotxm
5 | * Version: 0.1
6 | * License: GPL 3.0
7 | * Description: Make foobar2000 with ESLyric able to parse KRC and translated lyrics if exist.
8 | * Github: https://github.com/Robotxm/ESLyric-LyricsSource
9 | **/
10 |
11 | export function getConfig(cfg) {
12 | cfg.name = "KRC Parser Plus"
13 | cfg.version = "0.2"
14 | cfg.author = "Robotxm"
15 | cfg.parsePlainText = false
16 | cfg.fileType = "krc"
17 | }
18 |
19 | export function parseLyric(context) {
20 | let zipData = xorKRC(context.lyricData)
21 | if (!zipData) {
22 | return
23 | }
24 | let unzipData = zlib.uncompress(zipData.buffer)
25 | if (unzipData == null) {
26 | return
27 | }
28 | context.lyricText = krcToLrc(arrayBufferToString(unzipData))
29 | }
30 |
31 | function xorKRC(rawData) {
32 | if (null == rawData) {
33 | return
34 | }
35 |
36 | let dataView = new Uint8Array(rawData)
37 | let magicBytes = [0x6b, 0x72, 0x63, 0x31] // 'k' , 'r' , 'c' ,'1'
38 | if (dataView.length < magicBytes.length) {
39 | return
40 | }
41 | for (let i = 0; i < magicBytes.length; ++i) {
42 | if (dataView[i] != magicBytes[i]) {
43 | return
44 | }
45 | }
46 |
47 | let decryptedData = new Uint8Array(dataView.length - magicBytes.length)
48 | let encKey = [0x40, 0x47, 0x61, 0x77, 0x5e, 0x32, 0x74, 0x47, 0x51, 0x36, 0x31, 0x2d, 0xce, 0xd2, 0x6e, 0x69]
49 | let hdrOffset = magicBytes.length
50 | for (let i = hdrOffset; i < dataView.length; ++i) {
51 | let x = dataView[i]
52 | let y = encKey[(i - hdrOffset) % encKey.length]
53 | decryptedData[i - hdrOffset] = x ^ y
54 | }
55 |
56 | return decryptedData
57 | }
58 |
59 | function krcToLrc(krcContent) {
60 | const metaInfoRegex = /^\[([^\d:][^:]*):([^:]*)\]\s*$/
61 | const lineTimestampRegex = /^\[(\d+),(\d+)\]/
62 | const wordTimestampRegex = /<(\d+),(\d+),(\d+)>([^<]*)/g
63 | const lrcMetaTags = ["ar", "ti", "al", "by"]
64 |
65 | /* Start conversion */
66 |
67 | // Step 1: Parse translation
68 | let krcTranslation = []
69 | let lrcMetaLines = 0
70 | let hasTranslation = false
71 | if (krcContent.indexOf("language") != -1 && krcContent.indexOf("eyJjb250ZW50IjpbXSwidmVyc2lvbiI6MX0=") == -1) {
72 | let translationMatchResult = krcContent.match(/language:(.*)/g)
73 | let translationJson = atob(translationMatchResult[0].substring(0, translationMatchResult[0].length - 1).replace("language:", ""))
74 | let translationObject = JSON.parse(translationJson)
75 | for (let j = 0; j < translationObject.content.length; j++) {
76 | if (translationObject.content[j].type == 1) {
77 | hasTranslation = true
78 | krcTranslation = translationObject.content[j].lyricContent
79 | }
80 | }
81 | }
82 |
83 | // Step 2: Parse meta info and convert krc to advanced lrc
84 | let hasAddedMetaInfo = false
85 | let lrcMetaInfo = ""
86 | let lrcPlainContent = "" // Plain lrc content without translation
87 | let lines = krcContent.split(/[\n\r]/)
88 | for (const line of lines) {
89 | // Copy known meta tag
90 | let metaInfoMatches = []
91 | let lineTimestampMatches = []
92 | if (!hasAddedMetaInfo && (metaInfoMatches = metaInfoRegex.exec(line))) {
93 | for (const metaTag of lrcMetaTags) {
94 | if (metaTag == metaInfoMatches[1]) {
95 | lrcMetaInfo += `${metaInfoMatches[0]}\n`
96 | lrcMetaLines++
97 | break
98 | }
99 | }
100 | // Process case where 'offset' tags is named as 'manualoffset' in some krc files
101 | if (metaInfoMatches[1].endsWith("offset") && lrcMetaInfo.indexOf("[offset:") == -1) {
102 | lrcMetaInfo += `[offset:${metaInfoMatches[2]}]\n`
103 | lrcMetaLines++
104 | }
105 | lrcPlainContent = lrcMetaInfo
106 | } else if (lineTimestampMatches = lineTimestampRegex.exec(line)) {
107 | hasAddedMetaInfo = true
108 | let lineStartTime = parseInt(lineTimestampMatches[1], 10)
109 | let lyricLine = `[${formatTime(lineStartTime)}]`
110 | // Parse sub-timestamps
111 | let subMatches = []
112 | while (subMatches = wordTimestampRegex.exec(line)) {
113 | let subStartTime = parseInt(subMatches[1], 10)
114 | let subDuration = parseInt(subMatches[2], 10)
115 | let subWord = subMatches[4]
116 | lyricLine += `<${formatTime(lineStartTime + subStartTime)}>${subWord}<${formatTime(lineStartTime + subStartTime + subDuration)}>`
117 | }
118 | lrcPlainContent += `${lyricLine}\n`
119 | }
120 | }
121 |
122 | // Step 3: Add translation if exists
123 | if (!hasTranslation) {
124 | return lrcPlainContent
125 | }
126 |
127 | let lrcLines = lrcPlainContent.split("\n")
128 | let lrcContentWithTranslation = ""
129 | for (let translationCurrentLine = 0; translationCurrentLine < krcTranslation.length; translationCurrentLine++) {
130 | const lrcContentCurrentLineIndex = translationCurrentLine + lrcMetaLines
131 |
132 | const lrcContentCurrentLine = lrcLines[lrcContentCurrentLineIndex]
133 | if (!lrcContentCurrentLine) {
134 | continue
135 | }
136 |
137 | const lrcContentCurrentLineStartTimestamp = lrcContentCurrentLine.substring(1, 9)
138 |
139 | let currentLineTranslation = krcTranslation[translationCurrentLine][0]
140 | if (currentLineTranslation == '//') {
141 | currentLineTranslation = ' '
142 | }
143 |
144 | lrcContentWithTranslation += `${lrcContentCurrentLine}\n[${lrcContentCurrentLineStartTimestamp}]` + (currentLineTranslation ?? " ") + "\n"
145 | }
146 | return `${lrcMetaInfo}\n${lrcContentWithTranslation}`
147 | }
148 |
149 | function zpad(n) {
150 | const s = n.toString()
151 | return (s.length < 2) ? `0${s}` : s
152 | }
153 |
154 | function formatTime(time) {
155 | let t = Math.abs(time / 1000)
156 | let h = Math.floor(t / 3600)
157 | t -= h * 3600
158 | let m = Math.floor(t / 60)
159 | t -= m * 60
160 | let s = Math.floor(t)
161 | let ms = t - s
162 | let str = (h ? zpad(h) + ":" : "") + zpad(m) + ":" + zpad(s) + "." + zpad(Math.floor(ms * 100))
163 | return str
164 | }
165 |
--------------------------------------------------------------------------------
/current/qrc/README.md:
--------------------------------------------------------------------------------
1 | # QQ 音乐 Ex
2 |
3 | 复制 `parser` and `searcher` 两个文件夹到 ESLyric 的 `scripts` 文件夹下。
4 |
5 | ## 为什么会有 `qrcjson`?
6 |
7 | 为了能够在一次过程中同时处理原始歌词和翻译歌词所采用的中间格式。
8 |
9 | ## 为什么某些音乐在 QQ 音乐中有翻译歌词,但在 ESLyric 中使用本仓库的脚本之后也没有?
10 |
11 | QQ 音乐对于歌词翻译的处理规则相对复杂,本仓库的脚本无法处理所有情况。
12 |
--------------------------------------------------------------------------------
/current/qrc/parser/qrcjson.js:
--------------------------------------------------------------------------------
1 | /**
2 | * QRCJSON Parser
3 | * Author: Robotxm
4 | * Version: 0.2
5 | * License: GPL 3.0
6 | * Description: Make foobar2000 with ESLyric able to parse QRC Lyrics from QQMusic.
7 | * Github: https://github.com/Robotxm/ESLyric-LyricsSource
8 | **/
9 |
10 | import * as decoder from "parser_ext.so"
11 |
12 | export function getConfig(cfg) {
13 | cfg.name = "QRC JSON Parser"
14 | cfg.version = "0.2"
15 | cfg.author = "Robotxm"
16 | cfg.parsePlainText = true
17 | cfg.fileType = "qrcjson"
18 | }
19 |
20 | export function parseLyric(context) {
21 | const lyricObj = JSON.parse(context.lyricText)
22 |
23 | const plainLyrics = decryptQrc(lyricObj['lyric'])
24 | const plainTranslation = decryptQrc(lyricObj['trans'])
25 |
26 | const finalLyricText = mergeLyricsAndTranslation(plainLyrics, plainTranslation)
27 |
28 | context.lyricText = finalLyricText
29 | }
30 |
31 | function mergeLyricsAndTranslation(lyrics, translation) {
32 | if (!translation) {
33 | return lyrics
34 | }
35 |
36 | const lyricsLines = lyrics.split("\n")
37 | const translationLines = translation.split("\n")
38 |
39 | const metaInfoRegex = /^\[([^\d:][^:]*):([^:]*)\]\s*$/
40 |
41 | // Step 1: Parse meta info
42 | let hasAddedMetaInfo = false
43 | let lrcMetaInfo = ""
44 | const lines = lyrics.split(/[\n\r]/)
45 | for (const line of lines) {
46 | // Copy meta tags
47 | let metaInfoMatches = []
48 | if (!hasAddedMetaInfo && (metaInfoMatches = metaInfoRegex.exec(line))) {
49 | lrcMetaInfo += `${metaInfoMatches[0]}\n`
50 | }
51 | }
52 |
53 | // Step 2: Remove all meta info for future use
54 | let lyricsStartLineIndex = 0
55 | let translationStartLineIndex = 0
56 | for (var i = 0; i < 6; i++) {
57 | if (lyricsLines[i].indexOf("[ti:") >= 0 || lyricsLines[i].indexOf("[ar:") >= 0 || lyricsLines[i].indexOf("[al:") >= 0 || lyricsLines[i].indexOf("[by:") >= 0 || lyricsLines[i].indexOf("[offset:") >= 0 || lyricsLines[i].indexOf("[kana:") >= 0) {
58 | lyricsStartLineIndex++
59 | }
60 | if (translationLines[i].indexOf("[ti:") >= 0 || translationLines[i].indexOf("[ar:") >= 0 || translationLines[i].indexOf("[al:") >= 0 || translationLines[i].indexOf("[by:") >= 0 || translationLines[i].indexOf("[offset:") >= 0 || translationLines[i].indexOf("[kana:") >= 0) {
61 | translationStartLineIndex++
62 | }
63 | }
64 | lyricsLines.splice(0, lyricsStartLineIndex)
65 | translationLines.splice(0, translationStartLineIndex)
66 |
67 | // Step 3: Align lyrics and translation
68 | if (lyricsLines.length != translationLines.length) {
69 | for (var i = 0; i < lyricsLines.length; i++) {
70 | if (!lyricsLines[i] || trim(lyricsLines[i]) == "") {
71 | lyricsLines.splice(i, 1)
72 | i = i - 1
73 | }
74 | if (translationLines[i]) {
75 | if (trim(lyricsLines[i].substring(10)) == "" && trim(translationLines[i].substring(10)) != "") {
76 | lyricsLines.splice(i, 1)
77 | i = i - 1
78 | }
79 | } else {
80 | if (trim(lyricsLines[i].substring(10)) == "") {
81 | lyricsLines.splice(i, 1)
82 | i = i - 1
83 | }
84 | }
85 | }
86 | for (var i = 0; i < translationLines.length; i++) {
87 | if (!translationLines[i] || trim(translationLines[i]) == "") {
88 | translationLines.splice(i, 1)
89 | i = i - 1
90 | }
91 | if (lyricsLines[i]) {
92 | if (trim(translationLines[i].substring(10)) == "" && trim(lyricsLines[i].substring(10)) != "") {
93 | translationLines.splice(i, 1)
94 | i = i - 1
95 | }
96 | } else {
97 | if (trim(translationLines[i].substring(10)) == "") {
98 | translationLines.splice(i, 1)
99 | i = i - 1
100 | }
101 | }
102 | }
103 | }
104 |
105 | // Step 4: Add translation
106 | let lrcContentWithTranslation = ""
107 | for (var i = 0; i < lyricsLines.length; i++) {
108 | lrcContentWithTranslation += trim(lyricsLines[i]) + "\n"
109 |
110 | const timestamp = lyricsLines[i].substring(0, 10)
111 | const currentLineTranslation = trim(translationLines[i]).replace("//", " ")
112 | lrcContentWithTranslation += timestamp + currentLineTranslation.substring(10, currentLineTranslation.length) + "\n"
113 | }
114 |
115 | return `${lrcMetaInfo}\n${lrcContentWithTranslation}`
116 | }
117 |
118 | function trim(str) {
119 | return str.replace(/^(\s|\xA0)+|(\s|\xA0)+$/g, '')
120 | .replace(/'/g, '\'')
121 | .replace(/&/g, '&')
122 | }
123 |
124 | function decryptQrc(content) {
125 | if (!content) {
126 | return null
127 | }
128 |
129 | const zippedData = decoder.decodeQrc(restoreQrc(content))
130 | if (!zippedData) {
131 | return
132 | }
133 |
134 | const unzippedQrcData = zlib.uncompress(zippedData)
135 | if (!unzippedQrcData) {
136 | return
137 | }
138 |
139 | const decryptedContent = qrcToLrc(arrayBufferToString(unzippedQrcData))
140 | if (!decryptedContent) {
141 | return
142 | }
143 |
144 | return decryptedContent
145 | }
146 |
147 | function escapeXml(xmlText) {
148 | xmlText = xmlText.replace(/&/g, '&')
149 |
150 | const lyricContentArr = /LyricContent="([(\s\S)]*)"/gm.exec(xmlText)
151 | if (lyricContentArr && lyricContentArr.length >= 2) {
152 | const lyricContent = lyricContentArr[1]
153 | xmlText = xmlText.replace(lyricContent, lyricContent.replace(/\"/g, """))
154 | }
155 |
156 | return xmlText
157 | }
158 |
159 | function qrcToLrc(xmlText) {
160 | // Some xml texts are missing header, add it back
161 | if (xmlText && typeof xmlText === 'string' && xmlText.indexOf('")) {
162 | xmlText = '\n' + xmlText
163 | }
164 |
165 | if (xmlText && typeof xmlText === 'string' && xmlText.indexOf(' `[${formatTime(+base)}]<${formatTime(+base)}>`)
198 | .replace(/\((\d+),(\d+)\)/g, (_, start, offset) => `<${formatTime(+start + +offset)}>`)
199 | }
200 |
201 | function zpad(n) {
202 | let s = n.toString()
203 | return (s.length < 2) ? "0" + s : s
204 | }
205 |
206 | function formatTime(time) {
207 | let t = Math.abs(time / 1000)
208 | let h = Math.floor(t / 3600)
209 | t -= h * 3600
210 | let m = Math.floor(t / 60)
211 | t -= m * 60
212 | let s = Math.floor(t)
213 | let ms = t - s
214 | let str = (h ? zpad(h) + ":" : "") + zpad(m) + ":" + zpad(s) + "." + zpad(Math.floor(ms * 100))
215 | return str
216 | }
217 |
218 | function restoreQrc(hexText) {
219 | if (hexText.length % 2 != 0) return null
220 |
221 | const sig = "[offset:0]\n"
222 | let arrBuf = new Uint8Array(hexText.length / 2 + sig.length)
223 | for (let i = 0; i < sig.length; ++i) {
224 | arrBuf[i] = sig.charCodeAt(i)
225 | }
226 |
227 | const offset = sig.length
228 | for (let i = 0; i < hexText.length; i += 2) {
229 | arrBuf[offset + i / 2] = parseInt(hexText.slice(i, i + 2), 16)
230 | }
231 |
232 | return arrBuf.buffer
233 | }
234 |
--------------------------------------------------------------------------------
/current/qrc/searcher/qqmusic_ex.js:
--------------------------------------------------------------------------------
1 | /**
2 | * QQMusic Searcher Ex
3 | * Original Author: ohyeah
4 | * Modified by: Robotxm
5 | * Version: 0.2
6 | * License: GPL 3.0
7 | * Description: Make foobar2000 with ESLyric able to search QRC Lyrics from QQMusic.
8 | * Github: https://github.com/Robotxm/ESLyric-LyricsSource
9 | * Acknowledgement: https://github.com/jsososo/QQMusicApi
10 | https://github.com/xmcp/QRCD
11 | **/
12 |
13 | export function getConfig(cfg) {
14 | cfg.name = "QQ 音乐 Ex"
15 | cfg.version = "0.2"
16 | cfg.author = "Robotxm"
17 | }
18 |
19 | export function getLyrics(meta, man) {
20 |
21 | evalLib("querystring/querystring.min.js")
22 |
23 | // query QRC lyrics
24 | let url = 'https://c.y.qq.com/lyric/fcgi-bin/fcg_search_pc_lrc.fcg?'
25 | let data = {
26 | SONGNAME: meta.title,
27 | SINGERNAME: meta.artist,
28 | TYPE: 2,
29 | RANGE_MIN: 1,
30 | RANGE_MAX: 20
31 | }
32 | url += querystring.stringify(data)
33 |
34 | let headers = {}
35 | headers['Referer'] = 'https://y.qq.com'
36 |
37 | let settings = {
38 | method: 'get',
39 | url: url,
40 | headers: headers
41 | }
42 |
43 | let stageSongList = []
44 | request(settings, (err, res, body) => {
45 | if (err || res.statusCode != 200) {
46 | return
47 | }
48 | let xmlDoc = mxml.loadString(body)
49 | let songList = xmlDoc.findElement('songinfo') || []
50 | // Get singer name from common data
51 | const songName = decodeURIComponent(xmlDoc.findElement('songname').getFirstChild().getCDATA())
52 | const singerName = decodeURIComponent(xmlDoc.findElement('singer').getFirstChild().getCDATA())
53 | for (const song of songList) {
54 | let id = song.getAttr('id')
55 | if (id == null) continue
56 | let title = decodeURIComponent(getChildElementCDATA(song, 'name'))
57 | if (!title || title.length === 0) {
58 | title = songName
59 | }
60 |
61 | let artist = decodeURIComponent(getChildElementCDATA(song, 'singername'))
62 | if (!artist || artist.length === 0) {
63 | artist = singerName
64 | }
65 |
66 | let album = decodeURIComponent(getChildElementCDATA(song, 'albumname'))
67 |
68 | stageSongList.push({ id: id, title: title, artist: artist, album: album })
69 | }
70 |
71 | })
72 |
73 | if (stageSongList.length > 0) {
74 | let lyricCount = queryLyricV3(meta, man, stageSongList)
75 | if (lyricCount == null || lyricCount < 1) {
76 | queryLyricV2(meta, man, stageSongList)
77 | }
78 | }
79 |
80 | // obsolete
81 | //queryLyric(meta, man)
82 |
83 | }
84 |
85 | function queryLyricV3(meta, man, songList)
86 | {
87 | let lyricCount = 0
88 | let headers = {}
89 | headers['Referer'] = 'https://y.qq.com'
90 | headers['Host'] = 'u.y.qq.com'
91 | // notes: some params may not be required, I'm not tested.
92 | let postData = {
93 | comm: {
94 | _channelid: '0',
95 | _os_version: '6.2.9200-2',
96 | authst: '',
97 | ct: '19',
98 | cv: '1873',
99 | //guid: '30D1D7C616938DDB575AF16E56D44BD4',
100 | patch: '118',
101 | psrf_access_token_expiresAt: 0,
102 | psrf_qqaccess_token: '',
103 | psrf_qqopenid: '',
104 | psrf_qqunionid: '',
105 | tmeAppID: 'qqmusic',
106 | tmeLoginType: 2,
107 | uin: '0',
108 | wid: '0'
109 | },
110 | 'music.musichallSong.PlayLyricInfo.GetPlayLyricInfo': {
111 | method: 'GetPlayLyricInfo',
112 | module: 'music.musichallSong.PlayLyricInfo'
113 | }
114 | }
115 |
116 | for(const song of songList) {
117 | let songID = song.id | 0
118 | postData['music.musichallSong.PlayLyricInfo.GetPlayLyricInfo']['param'] = {
119 | albumName : btoa(song.album),
120 | crypt : 1,
121 | ct : 19,
122 | cv : 1873,
123 | interval : meta.duration | 0,
124 | lrc_t : 0,
125 | qrc : 1,
126 | qrc_t : 0,
127 | roma : 1,
128 | roma_t : 0,
129 | singerName : btoa(song.album),
130 | songID : songID,
131 | songName : btoa(song.artist),
132 | trans : 1,
133 | trans_t : 0,
134 | type : -1
135 | }
136 |
137 | let url = 'https://u.y.qq.com/cgi-bin/musicu.fcg?'
138 | let params = {
139 | pcachetime: new Date().getTime() | 0
140 | }
141 | url += querystring.stringify(params)
142 | let postDataString = JSON.stringify(postData)
143 | let settings = {
144 | method: 'post',
145 | url: url,
146 | headers: headers,
147 | body: postDataString
148 | }
149 |
150 | request(settings, (err, res, body) => {
151 | if (err || res.statusCode != 200) {
152 | return
153 | }
154 |
155 | try {
156 | let obj = JSON.parse(body)
157 | if (obj['code'] != 0) {
158 | return
159 | }
160 |
161 | let lyricObjRoot = obj['music.musichallSong.PlayLyricInfo.GetPlayLyricInfo']
162 | if (lyricObjRoot['code'] != 0) {
163 | return
164 | }
165 |
166 | let lyricObj = lyricObjRoot['data']
167 | if (lyricObj['songID'] != songID) {
168 | return
169 | }
170 |
171 | let lyricMeta = man.createLyric()
172 | lyricMeta.title = song.title
173 | lyricMeta.artist = song.artist
174 | lyricMeta.album = song.album
175 | lyricMeta.fileType = 'qrcjson'
176 | lyricMeta.lyricText = JSON.stringify(lyricObj)
177 |
178 | man.addLyric(lyricMeta)
179 | ++lyricCount
180 |
181 | } catch (e) {
182 | console.log("[qqmusic_ex] queryLyricV3 request lyric exception: " + e.message)
183 | }
184 | })
185 | }
186 |
187 | return lyricCount
188 | }
189 |
190 | function queryLyricV2(meta, man, songList)
191 | {
192 | let headers = {}
193 | headers['Referer'] = 'https://y.qq.com'
194 |
195 | for (const song of songList) {
196 | let url = 'https://c.y.qq.com/qqmusic/fcgi-bin/lyric_download.fcg?'
197 | let data = {
198 | version: '15',
199 | miniversion: '82',
200 | lrctype: '4',
201 | musicid: song.id,
202 | }
203 | url += querystring.stringify(data)
204 |
205 | let settings = {
206 | method: 'get',
207 | url: url,
208 | headers: headers
209 | }
210 |
211 | request(settings, (err, res, body) => {
212 | if (err || res.statusCode != 200) {
213 | return
214 | }
215 |
216 | body = body.replace('', '').replace(//, '').trim()
217 | let xmlRoot = mxml.loadString(body)
218 | if (xmlRoot != null) {
219 | let lyricMeta = man.createLyric()
220 | let lyrics = xmlRoot.findElement('lyric') || []
221 | for (const lyricEntry of lyrics) {
222 | let content = getChildElementCDATA(lyricEntry, 'content')
223 | if (content == null) continue
224 | let lyricData = restoreQrc(content)
225 | if (lyricData == null) continue
226 | lyricMeta.title = song.title
227 | lyricMeta.artist = song.artist
228 | lyricMeta.album = song.album
229 | lyricMeta.lyricData = lyricData
230 | lyricMeta.fileType = 'qrc'
231 | man.addLyric(lyricMeta)
232 | }
233 | }
234 | })
235 | }
236 | }
237 |
238 | function queryLyric(meta, man)
239 | {
240 | let headers = {}
241 | headers['Referer'] = 'https://y.qq.com'
242 |
243 | // qury LRC lyrics
244 | let queryNum = 10
245 | let url = 'http://c.y.qq.com/soso/fcgi-bin/client_search_cp?'
246 | let data = {
247 | format: 'json',
248 | n: queryNum,
249 | p: 0,
250 | w: meta.title + '+' + meta.artist,
251 | cr: 1,
252 | g_tk: 5381
253 | }
254 | url += querystring.stringify(data)
255 |
256 | let settings = {
257 | method: 'get',
258 | url: url,
259 | headers: headers
260 | }
261 |
262 | let stageSongList = []
263 | request(settings, (err, res, body) => {
264 | console.log("[qqmusic_ex] queryLyrics: " + err + " " + url)
265 | if (!err && res.statusCode === 200) {
266 | try {
267 | let obj = JSON.parse(body)
268 | let data = obj['data'] || {}
269 | let song = data['song'] || {}
270 | let song_list = song['list'] || {}
271 | for (const song_entry of song_list) {
272 | let title = song_entry['songname'] || ''
273 | let album = song_entry['albumname'] || ''
274 | let artist = ''
275 | let artist_list = song_entry['singer'] || []
276 | if (artist_list.length > 0) {
277 | artist = artist_list[0]['name'] || ''
278 | }
279 | let songmid = song_entry['songmid'] || ''
280 | if (songmid === '') {
281 | continue
282 | }
283 | stageSongList.push({ title: title, album: album, artist: artist, songmid: songmid })
284 | }
285 | } catch (e) {
286 | console.log('[qqmusic_ex] queryLyrics exception: ' + e.message)
287 | }
288 | }
289 | })
290 |
291 | let lyricMeta = man.createLyric()
292 | for (const result of stageSongList) {
293 | url = 'http://c.y.qq.com/lyric/fcgi-bin/fcg_query_lyric_new.fcg?'
294 | data = {
295 | songmid: result.songmid,
296 | pcachetime: new Date().getTime(),
297 | g_tk: 5381,
298 | loginUin: 0,
299 | hostUin: 0,
300 | inCharset: 'utf8',
301 | outCharset: 'utf-8',
302 | notice: 0,
303 | platform: 'yqq',
304 | needNewCode: 1,
305 | format: 'json'
306 | }
307 | url += querystring.stringify(data)
308 | settings = {
309 | method: 'get',
310 | url: url,
311 | headers: headers
312 | }
313 |
314 | request(settings, (err, res, body) => {
315 | if (!err && res.statusCode === 200) {
316 | lyricMeta.title = result.title
317 | lyricMeta.artist = result.artist
318 | lyricMeta.album = result.album
319 | try {
320 | let obj = JSON.parse(body)
321 | let b64lyric = obj['lyric'] || ''
322 | let b64tlyric = data['trans'] || ''
323 | let lyric = atob(b64lyric)
324 | let tlyric = atob(b64tlyric)
325 | if (tlyric != '') lyric += tlyric
326 | lyricMeta.lyricText = lyric
327 | man.addLyric(lyricMeta)
328 | } catch (e) {
329 | console.log('[qqmusic_ex] queryLyrics parse lyric response exception: ' + e.message)
330 | }
331 | }
332 | })
333 | }
334 | }
335 |
336 | function getChildElementCDATA(node, name) {
337 | let child = node.findElement(name)
338 | if (child == null) {
339 | return ''
340 | }
341 | let schild = child.getFirstChild()
342 | if (schild == null) {
343 | return ''
344 | }
345 | return schild.getCDATA() || ''
346 | }
347 |
348 | function restoreQrc(hexText) {
349 | if (hexText.length % 2 != 0) return null
350 |
351 | const sig = "[offset:0]\n"
352 | let arrBuf = new Uint8Array(hexText.length / 2 + sig.length)
353 | for (let i = 0; i < sig.length; ++i) {
354 | arrBuf[i] = sig.charCodeAt(i)
355 | }
356 |
357 | const offset = sig.length
358 | for (let i = 0; i < hexText.length; i += 2) {
359 | arrBuf[offset + i / 2] = parseInt(hexText.slice(i, i + 2), 16)
360 | }
361 |
362 | return arrBuf.buffer
363 | }
364 |
--------------------------------------------------------------------------------
/current/yrc/README.md:
--------------------------------------------------------------------------------
1 | # 网易云音乐 Ex
2 |
3 | 复制 `parser` and `searcher` 两个文件夹到 ESLyric 的 `scripts` 文件夹下。
4 |
5 | ## 什么是 `yrc`?为什么要使用它?
6 |
7 | `yrc` 是网易云音乐新提出的逐字歌词文件格式,与酷狗音乐的 `krc` 类似。
8 |
9 | 本仓库的脚本可以将 `yrc` 转换为 ESLyric 支持的 `lrc` 格式。
10 |
--------------------------------------------------------------------------------
/current/yrc/parser/yrc.js:
--------------------------------------------------------------------------------
1 | /**
2 | * NetEase Cloud Music YRC Lyrics Parser
3 | * Author: Robotxm
4 | * Version: 0.2
5 | * License: GPL 3.0
6 | * Description: Make foobar2000 with ESLyric able to parse YRC and translated lyrics if exist.
7 | * Github: https://github.com/Robotxm/ESLyric-LyricsSource
8 | **/
9 |
10 | export function getConfig(cfg) {
11 | cfg.name = "YRC Parser"
12 | cfg.version = "0.2"
13 | cfg.author = "Robotxm"
14 | cfg.parsePlainText = true
15 | cfg.fileType = "yrc"
16 | }
17 |
18 | export function parseLyric(context) {
19 | context.lyricText = yrcToLrc(context.lyricText)
20 | }
21 |
22 | function yrcToLrc(yrcContent) {
23 | const metaInfoRegex = /^\[([^\d:][^:]*):([^:]*)\]\s*$/gm
24 | const yrcLineTimestampRegex = /^\[(\d+),(\d+)\]/
25 | const yrcWordTimestampRegex = /\((\d+),(\d+),(\d+)\)([^\(]*)/g
26 | const lrcLineTimestampRegex = /^\[(\d+):(\d+).(\d+)\]|^\[(\d+):(\d+)\]/
27 | const lrcMetaTags = ["ar", "ti", "al", "by"]
28 |
29 | const lyricsObject = JSON.parse(yrcContent)
30 |
31 | /* Start conversion */
32 |
33 | // Step 1: Parse translation
34 | let yrcTranslation = []
35 | let yrcTranslationString = lyricsObject?.["ytlrc"]?.["lyric"]
36 | let hasYRCTranslation = yrcTranslationString != undefined && yrcTranslationString.trim() != ""
37 |
38 | let lrcMetaLines = 0
39 |
40 | let lrcTranslation = []
41 | let lrcTranslationString = lyricsObject?.["tlyric"]?.["lyric"]
42 | let hasLRCTranslation = lrcTranslationString != undefined && lrcTranslationString.trim() != ""
43 |
44 | const translationTimestampRegexA = /^\[(\d+):(\d+).(\d+)\]/
45 | const translationTimestampRegexB = /^\[(\d+):(\d+)\]/
46 |
47 | if (hasYRCTranslation) {
48 | yrcTranslation = yrcTranslationString.replace(metaInfoRegex, "").replace("\\n", "\n").trim().split(/[\n\r]/).map(line => {
49 | const startTimestamp = line.match(translationTimestampRegexA)[0]
50 | if (startTimestamp) {
51 | return line.replace(startTimestamp, convertTimestamp(startTimestamp))
52 | } else {
53 | return line
54 | }
55 | })
56 | }
57 | if (hasLRCTranslation) {
58 | lrcTranslation = lrcTranslationString.replace(metaInfoRegex, "").replace("\\n", "\n").trim().split(/[\n\r]/).map(line => line.replace(translationTimestampRegexA, "").replace(translationTimestampRegexB, ""))
59 | }
60 |
61 | // Step 2: Parse meta info and convert yrc to advanced lrc
62 | const containsYRC = lyricsObject?.["yrc"]?.["lyric"] != undefined
63 |
64 | let hasAddedMetaInfo = true // It seems that NetEase Cloud Music has no metadata in lyrics besides [by:] in translation which means the author of lyrics file
65 | let lrcMetaInfo = ""
66 | let lrcPlainContent = "" // Plain lrc content without translation
67 | let lines = containsYRC ? lyricsObject["yrc"]["lyric"].split(/[\n\r]/) : lyricsObject["lrc"]["lyric"].split(/[\n\r]/)
68 | for (const line of lines) {
69 | // Copy known meta tag
70 | let metaInfoMatches = []
71 | let lineTimestampMatches = []
72 | if (!hasAddedMetaInfo && (metaInfoMatches = metaInfoRegex.exec(line))) {
73 | for (const metaTag of lrcMetaTags) {
74 | if (metaTag == metaInfoMatches[1]) {
75 | lrcMetaInfo += `${metaInfoMatches[0]}\n`
76 | lrcMetaLines++
77 | break
78 | }
79 | }
80 | // Process case where 'offset' tags is named as 'manualoffset' in some yrc files
81 | if (metaInfoMatches[1].endsWith("offset") && lrcMetaInfo.indexOf("[offset:") == -1) {
82 | lrcMetaInfo += `[offset:${metaInfoMatches[2]}]\n`
83 | lrcMetaLines++
84 | }
85 | lrcPlainContent = lrcMetaInfo
86 | } else if (lineTimestampMatches = yrcLineTimestampRegex.exec(line)) { // YRC
87 | hasAddedMetaInfo = true
88 | let lineStartTime = parseInt(lineTimestampMatches[1], 10)
89 | let lyricLine = `[${formatTime(lineStartTime)}]`
90 | // Parse sub-timestamps
91 | let subMatches = []
92 | while (subMatches = yrcWordTimestampRegex.exec(line)) {
93 | let subStartTime = parseInt(subMatches[1], 10) - lineStartTime
94 | let subDuration = parseInt(subMatches[2], 10)
95 | let subWord = subMatches[4]
96 | lyricLine += `<${formatTime(lineStartTime + subStartTime)}>${subWord}<${formatTime(lineStartTime + subStartTime + subDuration)}>`
97 | }
98 | lrcPlainContent += `${lyricLine}\n`
99 | } else if (lineTimestampMatches = lrcLineTimestampRegex.exec(line)) { // Plain LRC
100 | hasAddedMetaInfo = true
101 | lrcPlainContent += `${line}\n`
102 | }
103 | }
104 |
105 | // Step 3: Add translation if exists
106 | if (!hasYRCTranslation && !hasLRCTranslation) {
107 | return lrcPlainContent
108 | }
109 |
110 | let lrcLines = lrcPlainContent.split("\n")
111 | let lrcContentWithTranslation = ""
112 |
113 | const tranlationLines = hasYRCTranslation ? yrcTranslation : lrcTranslation
114 |
115 | const translationStartTimestamp = tranlationLines[0]?.slice(0, 11)
116 | const translationFirstLineIndexInLrcContent = lrcLines.findIndex(line => line.startsWith(translationStartTimestamp))
117 |
118 | for (let lrcCurrentLine = 0; lrcCurrentLine < lrcLines.length; lrcCurrentLine++) {
119 | const lrcContentCurrentLine = lrcLines[lrcCurrentLine]
120 | lrcContentWithTranslation += `${lrcContentCurrentLine}\n`
121 |
122 | const expectedTranslationLineIndex = translationFirstLineIndexInLrcContent + lrcCurrentLine
123 | const expectedTranslationLine = tranlationLines[expectedTranslationLineIndex]
124 | if (expectedTranslationLine) {
125 | lrcContentWithTranslation += `${expectedTranslationLine}\n`
126 | }
127 | }
128 |
129 | return `${lrcMetaInfo}\n${lrcContentWithTranslation}`
130 | }
131 |
132 | function zpad(n) {
133 | const s = n.toString()
134 | return (s.length < 2) ? `0${s}` : s
135 | }
136 |
137 | function formatTime(time) {
138 | let t = Math.abs(time / 1000)
139 | let h = Math.floor(t / 3600)
140 | t -= h * 3600
141 | let m = Math.floor(t / 60)
142 | t -= m * 60
143 | const s = Math.floor(t)
144 | const ms = t - s
145 | const str = (h ? zpad(h) + ":" : "") + zpad(m) + ":" + zpad(s) + "." + zpad(Math.floor(ms * 100))
146 | return str
147 | }
148 |
149 | /**
150 | * Convert [xx:xx.xxx] to [xx:xx.xxx]
151 | */
152 | function convertTimestamp(originalTimestamp) {
153 | const minutes = parseInt(originalTimestamp.slice(1, 3), 10)
154 | const seconds = parseInt(originalTimestamp.slice(4, 6), 10)
155 | const milliseconds = parseInt(originalTimestamp.slice(7, 10), 10)
156 |
157 | return `[${formatTime(minutes * 60 * 1000 + seconds * 1000 + milliseconds)}]`
158 | }
159 |
--------------------------------------------------------------------------------
/current/yrc/searcher/netease_ex.js:
--------------------------------------------------------------------------------
1 | /**
2 | * NetEase Cloud Music Lyrics Searcher Ex
3 | * Original Author: ohyeah
4 | * Modified by: Robotxm
5 | * Version: 0.2
6 | * License: GPL 3.0
7 | * Description: Make foobar2000 with ESLyric able to parse lyrics provided by NetEase Cloud Music.
8 | * Github: https://github.com/Robotxm/ESLyric-LyricsSource
9 | *
10 | * All credits to:
11 | * https://github.com/Binaryify/NeteaseCloudMusicApi
12 | * https://github.com/entronad/crypto-es
13 | **/
14 |
15 | import crypto from 'crypto-es/lib/index.js'
16 |
17 | evalLib('querystring/querystring.min.js')
18 |
19 | const linuxApiIv = crypto.enc.Latin1.parse('0102030405060708')
20 | const linuxApiKey = crypto.enc.Latin1.parse('rFgB&h#%2?^eDg:Q')
21 | const eApiKey = crypto.enc.Latin1.parse('e82ckenh8dichen8')
22 |
23 | const aesEncrypt = (buffer, mode, key, iv) => {
24 | const cipher = crypto.AES.encrypt(buffer, key, { mode: mode, iv: iv })
25 | return cipher.ciphertext
26 | }
27 |
28 | const linuxApi = (object) => {
29 | const text = JSON.stringify(object)
30 | return {
31 | eparams: aesEncrypt(crypto.enc.Utf8.parse(text), crypto.mode.ECB, linuxApiKey, linuxApiIv).toString(crypto.enc.Hex).toUpperCase()
32 | }
33 | }
34 |
35 | const eApi = (url, object) => {
36 | const text = typeof object === 'object' ? JSON.stringify(object) : object
37 | const message = `nobody${url}use${text}md5forencrypt`
38 | const digest = crypto.MD5(message).toString()
39 | const data = `${url}-36cd479b6b5-${text}-36cd479b6b5-${digest}`
40 | return {
41 | params: aesEncrypt(crypto.enc.Utf8.parse(data), crypto.mode.ECB, eApiKey, '').toString(crypto.enc.Hex).toUpperCase()
42 | }
43 | }
44 |
45 | const doRequest = (method, url, data, options) => {
46 | return new Promise((resolve, reject) => {
47 | let headers = {}
48 | if (method.toUpperCase() === 'POST')
49 | headers['Content-Type'] = 'application/x-www-form-urlencoded'
50 | if (url.includes('music.163.com'))
51 | headers['Referer'] = 'https://music.163.com'
52 | if (options.crypto === 'linuxapi') {
53 | data = linuxApi({
54 | method: method,
55 | url: url.replace(/\w*api/, 'api'),
56 | params: data
57 | })
58 | headers['User-Agent'] = 'Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/60.0.3112.90 Safari/537.36'
59 | url = 'https://music.163.com/api/linux/forward'
60 | } else if (options.crypto === 'eapi') {
61 | const cookie = options.cookie || {}
62 | const csrfToken = cookie['__csrf'] || ''
63 | const header = {
64 | osver: cookie.osver,
65 | deviceId: cookie.deviceId,
66 | appver: cookie.appver || '8.7.01',
67 | versioncode: cookie.versioncode || '140',
68 | mobilename: cookie.mobilename,
69 | buildver: cookie.buildver || Date.now().toString().substr(0, 10),
70 | resolution: cookie.resolution || '1920x1080',
71 | __csrf: csrfToken,
72 | os: cookie.os || 'android',
73 | channel: cookie.channel,
74 | requestId: `${Date.now()}_${Math.floor(Math.random() * 1000)
75 | .toString()
76 | .padStart(4, '0')}`,
77 | }
78 | if (cookie.MUSIC_U) header['MUSIC_U'] = cookie.MUSIC_U
79 | if (cookie.MUSIC_A) header['MUSIC_A'] = cookie.MUSIC_A
80 | headers['Cookie'] = Object.keys(header)
81 | .map(
82 | (key) =>
83 | encodeURIComponent(key) + '=' + encodeURIComponent(header[key]),
84 | )
85 | .join('; ')
86 | data.header = header
87 | data = eApi(options.url, data)
88 | url = url.replace(/\w*api/, 'eapi')
89 | } else {
90 | reject()
91 | return
92 | }
93 | const settings = {
94 | method: method,
95 | url: url,
96 | headers: headers,
97 | body: querystring.stringify(data)
98 | }
99 | request(settings, (err, res, body) => {
100 | if (!err && res.statusCode === 200)
101 | resolve(body)
102 | else
103 | reject(err, res)
104 | })
105 | }).catch(error => console.log(error.message))
106 | }
107 |
108 | const procKeywords = (str) => {
109 | let s = str
110 | s = s.toLowerCase()
111 | s = s.replace(/\'|·|\$|\&|–/g, "")
112 | //truncate all symbols
113 | s = s.replace(/\(.*?\)|\[.*?]|{.*?}|(.*?/g, "")
114 | s = s.replace(/[-/:-@[-`{-~]+/g, "")
115 | s = s.replace(/[\u2014\u2018\u201c\u2026\u3001\u3002\u300a\u300b\u300e\u300f\u3010\u3011\u30fb\uff01\uff08\uff09\uff0c\uff1a\uff1b\uff1f\uff5e\uffe5]+/g, "")
116 | return s
117 | }
118 |
119 | export function getConfig(config) {
120 | config.name = "网易云音乐 Ex"
121 | config.version = "0.2"
122 | config.author = "Robotxm"
123 | }
124 |
125 | export function getLyrics(meta, man) {
126 | const title = procKeywords(meta.rawTitle)
127 | const artist = procKeywords(meta.rawArtist)
128 | const data = {
129 | s: title + " " + artist,
130 | type: 1,
131 | limit: 10,
132 | offset: 0
133 | }
134 |
135 | doRequest('POST',
136 | 'https://music.163.com/weapi/search/get',
137 | data,
138 | { crypto: 'linuxapi' }
139 | ).then((body) => {
140 | let candicates = []
141 | candicates = parseSearchResults(body)
142 | for (const item of candicates) {
143 | const queryData = {
144 | id: item.id,
145 | cp: false,
146 | tv: 0,
147 | lv: 0,
148 | rv: 0,
149 | kv: 0,
150 | yv: 0,
151 | ytv: 0,
152 | yrv: 0,
153 | }
154 | // Mobile API whose response may contain yrc (an advanced lyrics format like krc)
155 | doRequest(
156 | 'POST',
157 | 'https://interface3.music.163.com/eapi/song/lyric/v1',
158 | queryData,
159 | {
160 | crypto: 'eapi',
161 | url: '/api/song/lyric/v1'
162 | }
163 | ).then((body) => {
164 | parseLyricResponse(item, man, body)
165 | })
166 | }
167 | })
168 | // loop to 'wait' callback(promise)
169 | messageLoop(0)
170 | }
171 |
172 | function parseSearchResults(body) {
173 | let candicates = []
174 | try {
175 | let obj = JSON.parse(body)
176 | let results = obj['result'] || {}
177 | let songs = results['songs'] || []
178 | for (const song of songs) {
179 | if (typeof (song['id']) === 'undefined' || typeof (song['name']) === 'undefined')
180 | continue
181 | let id = song['id']
182 | let title = song['name']
183 | let artist = ''
184 | let artists = song['artists'] || []
185 | for (const item of artists) {
186 | if ('name' in item) {
187 | artist = item['name']
188 | break
189 | }
190 | }
191 | let album = song['album'] || {}
192 | album = album['name'] || ''
193 | candicates.push({ id: id, title: title, artist: artist, album: album })
194 | }
195 | } catch (e) {
196 | console.log(e)
197 | }
198 |
199 | return candicates
200 | }
201 |
202 | function parseLyricResponse(item, man, body) {
203 | try {
204 | let lyricObj = JSON.parse(body)
205 |
206 | const lyricsMetadata = man.createLyric()
207 |
208 | if (lyricObj['yrc']) {
209 | lyricsMetadata.title = item.title
210 | lyricsMetadata.artist = item.artist
211 | lyricsMetadata.album = item.album
212 | lyricsMetadata.lyricText = body
213 | lyricsMetadata.fileType = 'yrc'
214 | man.addLyric(lyricsMetadata)
215 | } else {
216 | let lyricText = ''
217 | if (lyricObj['lrc']) {
218 | lyricText = lyricObj['lrc']['lyric']?.replace(/^\{(.*)\}\s*/mg, "")?.trim() ?? ''
219 |
220 | let version = lyricObj['lrc']['version'] || 0
221 | if (version == 1) return
222 | }
223 |
224 | // Append translation if exists
225 | if (lyricObj['tlyric']) {
226 | lyricText += "\n" + lyricObj['tlyric']['lyric']?.replace(/^\{(.*)\}\s*/mg, "")?.trim() ?? ''
227 | }
228 |
229 | lyricsMetadata.title = item.title
230 | lyricsMetadata.artist = item.artist
231 | lyricsMetadata.album = item.album
232 | lyricsMetadata.lyricText = lyricText
233 | man.addLyric(lyricsMetadata)
234 | }
235 | } catch (e) {
236 | console.log(e)
237 | }
238 | }
239 |
--------------------------------------------------------------------------------
/legacy/README.md:
--------------------------------------------------------------------------------
1 | # Legacy
2 |
3 | 仅供旧版本 ESLyric 使用。
4 |
5 | 对于 KRC 格式的歌词,将被转换为旧版 ESLyric 的私有格式。注意新版本 ESLyric 并不支持该格式。新版本 ESLyric 请使用 `Current` 的脚本。
6 |
--------------------------------------------------------------------------------
/legacy/krc_parser_plus.js:
--------------------------------------------------------------------------------
1 | /**
2 | * KRC Parser Plus (Original 'KRC Parser')
3 | * Original Author: btx258
4 | * Modified by: Robotxm
5 | * Version: 0.3.8
6 | * License: GPL 3.0
7 | * Description: Make foobar2000 with ESLyric able to parse
8 | * KRC and translated lyrics if they exist.
9 | * Github: https://github.com/Robotxm/ESLyric-LyricsSource
10 | **/
11 |
12 |
13 | /**
14 | * Define whether to show dual-line desktop lyrics or not when translated lyrics doesn't exsit.
15 | * NOTICE: No matter what value is set, you must set ESLyric to show dual-line lyric.
16 | * true: Dual line
17 | * false: Single line
18 | * 当没有翻译歌词存在时,是否以双行样式显示桌面歌词。
19 | * 注意:无论此处设置为何值,都必须在 ESLyric 中设置桌面歌词的“显示模式”为“双行显示”。
20 | * true: 以双行显示
21 | * false: 以单行显示
22 | **/
23 | var dual_line = false;
24 |
25 | function get_my_name() {
26 | return "KRC Parser Plus";
27 | }
28 |
29 | function get_version() {
30 | return "0.3.8";
31 | }
32 |
33 | function get_author() {
34 | return "Robotxm & wistaria";
35 | }
36 |
37 | function is_our_type(type) {
38 | return type.toLowerCase() == "krc";
39 | }
40 |
41 | function start_parse(data) {
42 | var zip_data = null;
43 | var krc_text = null;
44 | zip_data = krchex_xor(data);
45 | if (!zip_data)
46 | return;
47 | unzip_data = utils.ZUnCompress(zip_data);
48 | if (!unzip_data)
49 | return;
50 | krc_text = utils.UTF8ToUnicode(unzip_data);
51 | return krc2lrc(krc_text);
52 | }
53 |
54 | function krchex_xor(s) {
55 | var magic_bytes = [0x6b, 0x72, 0x63, 0x31]; // 'k' , 'r' , 'c' ,'1'
56 | if (s.length < magic_bytes.length) return;
57 | for (var i = 0; i < magic_bytes.length; ++i) {
58 | var c = s.charCodeAt(i);
59 | if (c != magic_bytes[i]) return;
60 | }
61 | var enc_key = [0x40, 0x47, 0x61, 0x77, 0x5e, 0x32, 0x74, 0x47, 0x51, 0x36, 0x31, 0x2d, 0xce, 0xd2, 0x6e, 0x69];
62 | var buf = "";
63 | var krc_header = magic_bytes.length; // First 4 bytes
64 | for (var i = krc_header; i < s.length; ++i) {
65 | var x1 = s.charCodeAt(i);;
66 | var x2 = enc_key[(i - krc_header) % 16];
67 | buf += String.fromCharCode(x1 ^ x2);
68 | }
69 | return buf;
70 | }
71 |
72 | function krc2lrc(text) {
73 |
74 | var lrcBuf = "";
75 | var regx_meta_info = /^\[([^\d:][^:]*):([^:]*)\]\s*$/;
76 | var regx_timestamps1 = /^\[(\d*,\d*)\]/;
77 | var regx_timestamps2 = /<(\d*,\d*,\d*)>([^<]*)/g;
78 | var lrcMetaInfo = ["ar", "ti", "al", "by", "offset"];
79 | var metaInfoUnlock = true;
80 | var line, arr;
81 | var _end = 0;
82 |
83 | // Get translation
84 | var jkrc, trans;
85 | var lrcBuf2 = "";
86 | var lc = 0; // LRC metadata lines
87 | var btrans = false;
88 | if (text.indexOf("language") != -1 && text.indexOf("eyJjb250ZW50IjpbXSwidmVyc2lvbiI6MX0=") == -1) {
89 | var regx_lrc = text.match(/language:(.*)/g);
90 | regx_lrc[0] = regx_lrc[0].substring(0, regx_lrc[0].length - 1);
91 | var lrc = unescape(base64decode(regx_lrc[0].replace("language:", "")).replace(/\\u/g, '%u'));
92 | var jkrc = eval('(' + lrc + ')');
93 | for (var j = 0; j < jkrc.content.length; j++) {
94 | if (jkrc.content[j].type == 1) {
95 | btrans = true;
96 | var trans = jkrc.content[j].lyricContent;
97 | }
98 | }
99 | }
100 | var lines = text.split(/[\n\r]/);
101 |
102 | // Start conversion
103 | for (var i = 0; i < lines.length; ++i) {
104 | line = lines[i];
105 | // Copy known meta tag back
106 | if (metaInfoUnlock && (arr = regx_meta_info.exec(line))) {
107 | for (var idx in lrcMetaInfo) {
108 | if (lrcMetaInfo[idx] == arr[1]) {
109 | lrcBuf = lrcBuf + arr[0] + "\r\n";
110 | lc++;
111 | break;
112 | }
113 | }
114 | var lrcMeta = lrcBuf;
115 | }
116 | else if ((arr = regx_timestamps1.exec(line))) {
117 | // Parse lyric line
118 | metaInfoUnlock = false;
119 | var buf = "";
120 | var _time_array = arr[1].split(',');
121 | var _start = parseInt(_time_array[0], 10);
122 | var _duaration = parseInt(_time_array[1], 10);
123 | while ((arr = regx_timestamps2.exec(line))) {
124 | var _sub_time = arr[1].split(',');
125 | var _sub_start = parseInt(_sub_time[0], 10);
126 | var _sub_duaration = parseInt(_sub_time[1], 10);
127 | var cnt = arr[2];
128 | buf = buf + "[" + format_time(_start + _sub_start) + "]" + cnt + "[" + format_time(_start + _sub_start + _sub_duaration) + "]";
129 | _duaration = parseInt(_sub_start + _sub_duaration, 10);
130 | }
131 | _end = _start + _duaration;
132 | lrcBuf += buf + "\r\n";
133 | }
134 | }
135 |
136 | // Add translation if exists
137 | if (btrans) {
138 | var lrc_lines = lrcBuf.split("\r\n");
139 | for (var k = 0; k < trans.length; k++) {
140 | if (k != trans.length - 1) {
141 | if (k == 0) {
142 | if (ToMilliSec(lrc_lines[k + lc].substr(lrc_lines[k + lc].length - 9, 8)) < ToMilliSec(lrc_lines[k + lc + 1].substr(1, 8)))
143 | lrcBuf2 += lrc_lines[k + lc] + "\r\n" + lrc_lines[k + lc].slice(-10) + (trans[k] == "" ? " " : trans[k]) + lrc_lines[k + lc].slice(-10) + "\r\n";
144 | else
145 | lrcBuf2 += lrc_lines[k + lc] + "\r\n" + lrc_lines[k + lc + 1].substr(0, 10) + (trans[k] == "" ? " " : trans[k]) + lrc_lines[k + lc + 1].substr(0, 10) + "\r\n";
146 | }
147 | else {
148 | if (ToMilliSec(lrc_lines[k + lc - 1].substr(lrc_lines[k + lc - 1].length - 9, 8)) < ToMilliSec(lrc_lines[k + lc].substr(1, 8))) {
149 | if (ToMilliSec(lrc_lines[k + lc].substr(lrc_lines[k + lc].length - 9, 8)) < ToMilliSec(lrc_lines[k + lc + 1].substr(1, 8)))
150 | lrcBuf2 += lrc_lines[k + lc - 1].slice(-10) + " " + lrc_lines[k + lc] + "\r\n" + lrc_lines[k + lc].slice(-10) + (trans[k] == "" ? " " : trans[k]) + lrc_lines[k + lc].slice(-10) + "\r\n";
151 | else
152 | lrcBuf2 += lrc_lines[k + lc - 1].slice(-10) + " " + lrc_lines[k + lc] + "\r\n" + lrc_lines[k + lc + 1].substr(0, 10) + (trans[k] == "" ? " " : trans[k]) + lrc_lines[k + lc + 1].substr(0, 10) + "\r\n";
153 | }
154 | else {
155 | if (ToMilliSec(lrc_lines[k + lc].substr(lrc_lines[k + lc].length - 9, 8)) < ToMilliSec(lrc_lines[k + lc + 1].substr(1, 8)))
156 | lrcBuf2 += lrc_lines[k + lc] + "\r\n" + lrc_lines[k + lc].slice(-10) + (trans[k] == "" ? " " : trans[k]) + lrc_lines[k + lc].slice(-10) + "\r\n";
157 | else
158 | lrcBuf2 += lrc_lines[k + lc] + "\r\n" + lrc_lines[k + lc + 1].substr(0, 10) + (trans[k] == "" ? " " : trans[k]) + lrc_lines[k + lc + 1].substr(0, 10) + "\r\n";
159 | }
160 | }
161 | }
162 | else {
163 | if (ToMilliSec(lrc_lines[k + lc - 1].substr(lrc_lines[k + lc - 1].length - 9, 8)) < ToMilliSec(lrc_lines[k + lc].substr(1, 8)))
164 | lrcBuf2 += lrc_lines[k + lc - 1].slice(-10) + " " + lrc_lines[k + lc] + "\r\n" + "[" + format_time(_end + 1000) + "]" + (trans[k] == "" ? " " : trans[k]) + "[" + format_time(_end + 1000) + "]" + "\r\n" + "[" + format_time(_end + 1001) + "] \r\n";
165 | else
166 | lrcBuf2 += lrc_lines[k + lc] + "\r\n[" + format_time(_end + 1001) + "]" + (trans[k] == "" ? " " : trans[k]) + "[" + format_time(_end + 1001) + "]" + "\r\n" + "[" + format_time(_end + 1001) + "] \r\n";
167 | }
168 | }
169 | lrcBuf = lrcMeta + "\r\n" + lrcBuf2;
170 | }
171 |
172 | // Process something about single-line mode
173 | if (!dual_line && !btrans) {
174 | var lrc_lines = lrcBuf.split("\r\n");
175 | for (var k = lc; k < lrc_lines.length; k++) {
176 | if (k != lrc_lines.length - 1) {
177 | if (ToMilliSec(lrc_lines[k + 1].substr(1, 8)) < ToMilliSec(lrc_lines[k].substr(lrc_lines[k].length - 9, 8)))
178 | lrcBuf2 += lrc_lines[k] + "\r\n" + lrc_lines[k + 1].substr(0, 10) + " " + lrc_lines[k + 1].substr(0, 10) + "\r\n";
179 | else
180 | lrcBuf2 += lrc_lines[k] + "\r\n" + lrc_lines[k].slice(-10) + " " + lrc_lines[k].slice(-10) + "\r\n";
181 | }
182 | else
183 | lrcBuf2 += lrc_lines[k] + "\r\n" + lrc_lines[k].slice(-10) + " " + lrc_lines[k].slice(-10) + "\r\n";
184 | }
185 | lrcBuf = lrcBuf2;
186 | }
187 |
188 | return lrcBuf;
189 | }
190 |
191 | function ToMilliSec(timeString) {
192 | return parseInt(timeString.slice(0, 2), 10) * 60000 + parseInt(timeString.substr(3, 2), 10) * 1000 + parseInt(timeString.substr(6, 2), 10);
193 | }
194 |
195 | function zpad(n) {
196 | var s = n.toString();
197 | return (s.length < 2) ? "0" + s : s;
198 | }
199 |
200 | function format_time(time) {
201 | var t = Math.abs(time / 1000);
202 | var h = Math.floor(t / 3600);
203 | t -= h * 3600;
204 | var m = Math.floor(t / 60);
205 | t -= m * 60;
206 | var s = Math.floor(t);
207 | var ms = t - s;
208 | var str = (h ? zpad(h) + ":" : "") + zpad(m) + ":" + zpad(s) + "." + zpad(Math.floor(ms * 100));
209 | return str;
210 | }
211 |
212 | var base64DecodeChars = new Array(- 1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 62, -1, -1, -1, 63, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, -1, -1, -1, -1, -1, -1, -1, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, -1, -1, -1, -1, -1, -1, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, -1, -1, -1, -1, -1);
213 |
214 | function base64decode(str) {
215 | var c1, c2, c3, c4;
216 | var i, len, out;
217 |
218 | len = str.length;
219 | i = 0;
220 | out = "";
221 | while (i < len) {
222 | /* c1 */
223 | do {
224 | c1 = base64DecodeChars[str.charCodeAt(i++) & 0xff];
225 | } while (i < len && c1 == - 1);
226 | if (c1 == -1) break;
227 |
228 | /* c2 */
229 | do {
230 | c2 = base64DecodeChars[str.charCodeAt(i++) & 0xff];
231 | } while (i < len && c2 == - 1);
232 | if (c2 == -1) break;
233 |
234 | out += String.fromCharCode((c1 << 2) | ((c2 & 0x30) >> 4));
235 |
236 | /* c3 */
237 | do {
238 | c3 = str.charCodeAt(i++) & 0xff;
239 | if (c3 == 61) return out;
240 | c3 = base64DecodeChars[c3];
241 | } while (i < len && c3 == - 1);
242 | if (c3 == -1) break;
243 |
244 | out += String.fromCharCode(((c2 & 0xF) << 4) | ((c3 & 0x3C) >> 2));
245 |
246 | /* c4 */
247 | do {
248 | c4 = str.charCodeAt(i++) & 0xff;
249 | if (c4 == 61) return out;
250 | c4 = base64DecodeChars[c4];
251 | } while (i < len && c4 == - 1);
252 | if (c4 == -1) break;
253 | out += String.fromCharCode(((c3 & 0x03) << 6) | c4);
254 | }
255 | return out;
256 | }
--------------------------------------------------------------------------------
/legacy/qqmusic_plus.js:
--------------------------------------------------------------------------------
1 | /**
2 | * QQ Music Lyrics Source for ESLyric
3 | * Original Author: btx258
4 | * Modified by: Robotxm
5 | * Version: 0.1.2
6 | * License: GPL 3.0
7 | * Description: Make foobar2000 with ESLyric able to show
8 | * lyrics (and translation if it exists)
9 | * from QQ Music server.
10 | * Github: https://github.com/Robotxm/ESLyric-LyricsSource
11 | **/
12 |
13 | /**
14 | * Define whether to show dual-line desktop lyrics or not when translated lyrics doesn't exsit.
15 | * NOTICE: No matter what value is set, you must set ESLyric to show dual-line lyric.
16 | * true: Dual line
17 | * false: Single line
18 | * 当没有翻译歌词存在时,是否以双行样式显示桌面歌词。
19 | * 注意:无论此处设置为何值,都必须在 ESLyric 中设置桌面歌词的“显示模式”为“双行显示”。
20 | * true: 以双行显示
21 | * false: 以单行显示
22 | **/
23 | var dual_line = false;
24 |
25 | var QM_CFG = {
26 | DEBUG: false,
27 | E_SRV: "http://y.qq.com/portal/player.html",
28 | S_SRV: "http://c.y.qq.com/soso/fcgi-bin/client_search_cp",
29 | L_SRV: "http://c.y.qq.com/lyric/fcgi-bin/fcg_query_lyric_new.fcg",
30 | G_PRM: "&format=json&inCharset=utf8&outCharset=utf-8",
31 | P_MAX: 3,
32 | P_NUM: 30,
33 | L_LOW: 5,
34 | L_MAX: 10,
35 | RETRY: 1,
36 | };
37 |
38 | var qm_http = {
39 | handle: null,
40 | type: null
41 | };
42 |
43 | var qm_abort = {
44 | handle: null,
45 | isvalid: true
46 | };
47 |
48 | function get_my_name() {
49 | return "QQMusic|QQ音乐";
50 | }
51 |
52 | function get_version() {
53 | return "0.1.2";
54 | }
55 |
56 | function get_author() {
57 | return "Robotxm & btx258 & hheng101";
58 | }
59 |
60 | function start_search(info, callback) {
61 | var json_text = null, new_lyric = null;
62 | var song = null, lyric = null, i = null, j = null;
63 | var page = null, count = null;
64 | qm_abort.handle = callback;
65 | qm_abort.isvalid = true;
66 | for (var page = 0, count = 0; page < QM_CFG.P_MAX && count < QM_CFG.L_LOW; page++) {
67 | if (qm_is_aborting()) {
68 | break;
69 | }
70 | json_text = qm_download(QM_CFG.S_SRV,
71 | "w=" + qm_normalize(info.Title) + "+" + qm_normalize(info.Artist)
72 | + "&p=" + (page + 1)
73 | + "&n=" + QM_CFG.P_NUM
74 | + "&new_json=1&cr=1"
75 | + QM_CFG.G_PRM
76 | );
77 | if (json_text) {
78 | try {
79 | song = qm_json(json_text);
80 | } catch (e) {
81 | song = null;
82 | }
83 | }
84 | if (song && !song.code) {
85 | if (song.subcode || !song.data.song.totalnum) {
86 | break;
87 | }
88 | new_lyric = fb.CreateLyric();
89 | for (i = 0; i < song.data.song.list.length && count < QM_CFG.L_MAX; i++) {
90 | if (qm_is_aborting()) {
91 | break;
92 | }
93 | new_lyric.Title = song.data.song.list[i].title;
94 | new_lyric.Album = song.data.song.list[i].album.title;
95 | for (j = 0, new_lyric.Artist = ""; j < song.data.song.list[i].singer.length; j++) {
96 | new_lyric.Artist += (j === 0 ? "" : ",") + song.data.song.list[i].singer[j].title;
97 | }
98 | // qm_trace("INFO-start_search-new_lyric Title: " + new_lyric.Title + ", Album: " + new_lyric.Album + ", Artist: " + new_lyric.Artist);
99 | new_lyric.Source = get_my_name();
100 | json_text = qm_download(QM_CFG.L_SRV,
101 | "songmid=" + song.data.song.list[i].mid
102 | + "&g_tk=5381"
103 | + QM_CFG.G_PRM
104 | );
105 | if (json_text) {
106 | try {
107 | lyric = qm_json(json_text.replace(/(^\w+\()|(\)$)/g, ""));
108 | } catch (e) {
109 | lyric = null;
110 | }
111 | }
112 | if (lyric && !lyric.code) {
113 | if (lyric.lyric.length > 128) {
114 | if (lyric.trans.length > 128) {
115 | new_lyric.Source = get_my_name() + " (含翻译)";
116 | new_lyric.LyricText = qm_generate_translation(Base64.decode(lyric.lyric), Base64.decode(lyric.trans));
117 | callback.AddLyric(new_lyric);
118 | } else {
119 | if (!dual_line) {
120 | new_lyric.LyricText = qm_generate_single_line(Base64.decode(lyric.lyric));
121 | callback.AddLyric(new_lyric);
122 | } else {
123 | new_lyric.LyricText = Base64.decode(lyric.lyric);
124 | callback.AddLyric(new_lyric);
125 | }
126 | }
127 | count++;
128 | }
129 | }
130 | if (count % 2 === 0) {
131 | callback.Refresh();
132 | }
133 | }
134 | new_lyric.Dispose();
135 | }
136 | }
137 | }
138 |
139 | function qm_download(url, param) {
140 | // qm_trace("INFO-qm_download-url: " + url + ", param: " + param);
141 | // retry several times at most
142 | var i = null, xml_text = null;
143 | for (i = 0; i < QM_CFG.RETRY; i++) {
144 | if (!qm_http.handle) {
145 | try {
146 | qm_http.handle = utils.CreateHttpClient();
147 | qm_http.type = "u_c";
148 | } catch (e) {
149 | // qm_trace("ERROR-qm_download-CreateHttpClient message: " + e.message);
150 | try {
151 | qm_http.handle = utils.CreateHttpRequest("GET");
152 | qm_http.type = "u_r";
153 | } catch (err) {
154 | // qm_trace("ERROR-qm_download-CreateHttpRequest message: " + err.message);
155 | try {
156 | qm_http.handle = new ActiveXObject("Microsoft.XMLHTTP");
157 | qm_http.type = "ie";
158 | } catch (error) {
159 | // qm_trace("ERROR-qm_download-ActiveXObject message: " + error.message);
160 | qm_http.handle = null;
161 | qm_http.type = null;
162 | continue;
163 | }
164 | }
165 | }
166 | // qm_trace("INFO-qm_download-qm_http.type: " + qm_http.type);
167 | }
168 | try {
169 | if (param) {
170 | url += "?" + encodeURI(param);
171 | }
172 | if (qm_http.type == "u_c") {
173 | qm_http.handle.addHttpHeader("Referer", QM_CFG.E_SRV);
174 | xml_text = qm_http.handle.Request(url, "GET");
175 | if (qm_http.handle.StatusCode == 200) {
176 | return xml_text;
177 | }
178 | } else if (qm_http.type == "u_r") {
179 | qm_http.AddHeader("Referer", QM_CFG.E_SRV);
180 | xml_text = qm_http.handle.Run(url);
181 | return xml_text;
182 | } else if (qm_http.type == "ie") {
183 | qm_http.handle.open("GET", url, false);
184 | qm_http.handle.setRequestHeader("Referer", QM_CFG.E_SRV);
185 | qm_http.handle.send();
186 | if (qm_http.handle.readyState == 4 && qm_http.handle.status == 200) {
187 | xml_text = qm_http.handle.responseText;
188 | return xml_text;
189 | }
190 | }
191 | } catch (e) {
192 | // qm_trace("ERROR-qm_download-request message: " + e.message);
193 | continue;
194 | }
195 | }
196 | // qm_trace("FAILED-qm_download");
197 | return null;
198 | }
199 |
200 | function qm_json(str) {
201 | if (typeof JSON == 'object') {
202 | return JSON.parse(str);
203 | } else {
204 | try {
205 | // Method 1: eval
206 | return eval("(" + str + ")");
207 | } catch (e) {
208 | // qm_trace("ERROR-qm_json-eval message: " + e.message);
209 | try {
210 | // Method 2: new Function
211 | return (new Function('return ' + str))();
212 | } catch (err) {
213 | // qm_trace("ERROR-qm_json-Function message: " + e.message);
214 | throw new SyntaxError('FAILED-qm_json');
215 | // Method 3: json2.js
216 | }
217 | }
218 | }
219 | }
220 |
221 | function qm_normalize(str) {
222 | var s = null;
223 | if (str) {
224 | s = str;
225 | // !"#$%&'()*+,-./:;<=>?@[\]^_`{|}~
226 | s = s.replace(/([\u0021-\u002F]|[\u003A-\u0040]|[\u005B-\u0060]|[\u007B-\u007E])+/g, " ");
227 | // !"#$%&'()*+,-./:;<=>?@[\]^_`{|}~
228 | s = s.replace(/([\uFF01-\uFF20]|[\uFF3B-\uFF40]|[\uFF5B-\uFF5E])+/g, " ");
229 | // ·×‐‑‒–—―‖‗‘’‚‛“”„‟…‧‰、。〇〈〉《》「」『』【】〔〕〖〗〜・
230 | s = s.replace(/(\u00B7|\u00D7|[\u2010-\u201F]|[\u2026-\u2027]|\u2030|[\u3001-\u3002]|[\u3007-\u3011]|[\u3014-\u3017]|\u301C|\u30FB)+/g, " ");
231 | s = s.replace(/\s+/g, " ");
232 | } else {
233 | s = "";
234 | }
235 | return s;
236 | }
237 |
238 | function qm_capitalize(str) {
239 | var s = null;
240 | if (str) {
241 | s = str;
242 | s = s.toLowerCase().replace(/(\b[a-z])/g, function (c) {
243 | return c.toUpperCase();
244 | }
245 | );
246 | } else {
247 | s = "";
248 | }
249 | return s;
250 | }
251 |
252 | function qm_is_aborting() {
253 | if (qm_abort.isvalid) {
254 | try {
255 | return qm_abort.handle.IsAborting();
256 | } catch (e) {
257 | // qm_trace("ERROR-qm_is_aborting message: " + e.message);
258 | qm_abort.isvalid = false;
259 | }
260 | }
261 | return false;
262 | }
263 |
264 | function qm_trace(str) {
265 | if (QM_CFG.DEBUG) {
266 | fb.trace("QM_DEBUG> " + str);
267 | }
268 | }
269 |
270 |
271 | function qm_generate_translation(plain, translation) {
272 | // qm_trace(plain);
273 | // qm_trace("############################################");
274 | // qm_trace(translation);
275 |
276 | var arr_plain = plain.split("\n");
277 | var arr_translation = translation.split("\n");
278 |
279 | // 歌词和翻译顶部信息不一定都有,会导致翻译对不齐,所以删掉
280 | var plain_start_line = 0;
281 | var trans_start_line = 0;
282 | for (var i = 0; i < 6; i++) {
283 | if (arr_plain[i].indexOf("[ti:") >= 0 || arr_plain[i].indexOf("[ar:") >= 0 || arr_plain[i].indexOf("[al:") >= 0 || arr_plain[i].indexOf("[by:") >= 0 || arr_plain[i].indexOf("[offset:") >= 0 || arr_plain[i].indexOf("[kana:") >= 0) {
284 | plain_start_line ++;
285 | }
286 | if (arr_translation[i].indexOf("[ti:") >= 0 || arr_translation[i].indexOf("[ar:") >= 0 || arr_translation[i].indexOf("[al:") >= 0 || arr_translation[i].indexOf("[by:") >= 0 || arr_translation[i].indexOf("[offset:") >= 0 || arr_translation[i].indexOf("[kana:") >= 0) {
287 | trans_start_line ++;
288 | }
289 | }
290 | arr_plain.splice(0, plain_start_line);
291 | arr_translation.splice(0, trans_start_line);
292 |
293 | // 有的歌词和翻译对不齐,处理一下
294 | if (arr_plain.length != arr_translation.length) {
295 | for (var i = 0; i < arr_plain.length; i++) {
296 | if (arr_plain[i] == null || trim(arr_plain[i]) == "") {
297 | arr_plain.splice(i, 1);
298 | i = i - 1;
299 | }
300 | if (arr_translation[i] != null) {
301 | if (trim(arr_plain[i].substring(10)) == "" && trim(arr_translation[i].substring(10)) != "") {
302 | arr_plain.splice(i, 1);
303 | i = i - 1;
304 | }
305 | } else {
306 | if (trim(arr_plain[i].substring(10)) == "") {
307 | arr_plain.splice(i, 1);
308 | i = i - 1;
309 | }
310 | }
311 | }
312 | for (var i = 0; i < arr_translation.length; i++) {
313 | if (arr_translation[i] == null || trim(arr_translation[i]) == "") {
314 | arr_translation.splice(i, 1);
315 | i = i - 1;
316 | }
317 | if (arr_plain[i] != null) {
318 | if (trim(arr_translation[i].substring(10)) == "" && trim(arr_plain[i].substring(10)) != "") {
319 | arr_translation.splice(i, 1);
320 | i = i - 1;
321 | }
322 | } else {
323 | if (trim(arr_translation[i].substring(10)) == "") {
324 | arr_translation.splice(i, 1);
325 | i = i - 1;
326 | }
327 | }
328 | }
329 | }
330 |
331 | // for (var i = 0; i < arr_plain.length; i++) {
332 | // qm_trace(arr_plain[i]);
333 | // }
334 | // qm_trace("########################################");
335 | // for (var i = 0; i < arr_translation.length; i++) {
336 | // qm_trace(arr_translation[i]);
337 | // }
338 |
339 |
340 | // 开始拼接歌词和翻译
341 | var translated_lyrics = "";
342 | for (var i = 0; i < arr_plain.length; i++) {
343 | translated_lyrics += trim(arr_plain[i]) + "\r\n";
344 | var timestamp = "";
345 | if (i < arr_plain.length - 1 && arr_plain[i + 1].indexOf("[") != -1) {
346 | timestamp = "[" + format_time(to_millisecond(arr_plain[i + 1].substr(1, 8))) + "]";
347 | }
348 | else {
349 | timestamp = "[" + format_time(to_millisecond(arr_translation[i].substr(1, 8)) + 1000) + "]";
350 | }
351 |
352 | var translation_line = "";
353 | if (arr_translation[i] == "腾讯享有本翻译作品的著作权" || arr_translation[i].indexOf("//") != -1) {
354 | translation_line = arr_translation[i].substring(10).replace("//", " ");
355 | } else {
356 | translation_line = arr_translation[i].substring(10);
357 | }
358 |
359 | translation_line = trim(translation_line);
360 | if (translation_line == "" || translation_line == " " || translation_line == "腾讯享有本翻译作品的著作权") {
361 | translated_lyrics += timestamp + translation_line + "\r\n";
362 | } else {
363 | translated_lyrics += timestamp + "「" + translation_line + "」" + "\r\n";
364 | }
365 | }
366 | // qm_trace(translated_lyrics);
367 |
368 | return translated_lyrics;
369 | }
370 |
371 | function trim(str) {
372 | resultStr = str;
373 | resultStr = resultStr.replace(/^(\s|\xA0)+|(\s|\xA0)+$/g, '');
374 | resultStr = resultStr.replace(/'/g, '\'');
375 | resultStr = resultStr.replace(/&/g, '&');
376 | return resultStr;
377 | }
378 |
379 | function qm_generate_single_line(plain) {
380 | var arr_plain = plain.split("\n");
381 | var single_line_lyrics = "";
382 | for (var i = 0; i < arr_plain.length; i++) {
383 | single_line_lyrics += trim(arr_plain[i]) + "\r\n";
384 | var timestamp = "";
385 | if (i < arr_plain.length - 1) {
386 | timestamp = format_time(to_millisecond(arr_plain[i + 1].substr(1, 8)));
387 | }
388 | else {
389 | timestamp = format_time(to_millisecond(arr_plain[i].substr(1, 8)) + 1000);
390 | }
391 | if (!isNaN(timestamp)) {
392 | single_line_lyrics += "[" + timestamp + "]" + " " + "\r\n";
393 | }
394 | }
395 | return single_line_lyrics;
396 | }
397 |
398 | function to_millisecond(timeString) {
399 | return parseInt(timeString.slice(0, 2), 10) * 60000 + parseInt(timeString.substr(3, 2), 10) * 1000 + parseInt(timeString.substr(6, 2), 10) * 10;
400 | }
401 |
402 | function zpad(n) {
403 | var s = n.toString();
404 | if (s.length < 2) {
405 | return "0" + s;
406 | } else if (s.length > 2) {
407 | return s.substr(0, 2);
408 | } else {
409 | return s;
410 | }
411 | }
412 |
413 | function format_time(time) {
414 | var t = Math.abs((time - 20) / 1000);
415 | var h = Math.floor(t / 3600);
416 | t = t - h * 3600;
417 | var m = Math.floor(t / 60);
418 | t = t - m * 60;
419 | var s = Math.floor(t);
420 | var ms = t - s;
421 | var str = (h ? zpad(h) + ":" : "") + zpad(m) + ":" + zpad(s) + "." + zpad(Math.floor(ms * 100));
422 | return str;
423 | }
424 |
425 |
426 | // https://github.com/dankogai/js-base64
427 | // https://github.com/dankogai/js-base64/raw/master/base64.min.js
428 | (function (global) { "use strict"; var _Base64 = global.Base64; var version = "2.3.2"; var buffer; if (typeof module !== "undefined" && module.exports) { try { buffer = require("buffer").Buffer } catch (err) { } } var b64chars = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"; var b64tab = function (bin) { var t = {}; for (var i = 0, l = bin.length; i < l; i++)t[bin.charAt(i)] = i; return t }(b64chars); var fromCharCode = String.fromCharCode; var cb_utob = function (c) { if (c.length < 2) { var cc = c.charCodeAt(0); return cc < 128 ? c : cc < 2048 ? fromCharCode(192 | cc >>> 6) + fromCharCode(128 | cc & 63) : fromCharCode(224 | cc >>> 12 & 15) + fromCharCode(128 | cc >>> 6 & 63) + fromCharCode(128 | cc & 63) } else { var cc = 65536 + (c.charCodeAt(0) - 55296) * 1024 + (c.charCodeAt(1) - 56320); return fromCharCode(240 | cc >>> 18 & 7) + fromCharCode(128 | cc >>> 12 & 63) + fromCharCode(128 | cc >>> 6 & 63) + fromCharCode(128 | cc & 63) } }; var re_utob = /[\uD800-\uDBFF][\uDC00-\uDFFFF]|[^\x00-\x7F]/g; var utob = function (u) { return u.replace(re_utob, cb_utob) }; var cb_encode = function (ccc) { var padlen = [0, 2, 1][ccc.length % 3], ord = ccc.charCodeAt(0) << 16 | (ccc.length > 1 ? ccc.charCodeAt(1) : 0) << 8 | (ccc.length > 2 ? ccc.charCodeAt(2) : 0), chars = [b64chars.charAt(ord >>> 18), b64chars.charAt(ord >>> 12 & 63), padlen >= 2 ? "=" : b64chars.charAt(ord >>> 6 & 63), padlen >= 1 ? "=" : b64chars.charAt(ord & 63)]; return chars.join("") }; var btoa = global.btoa ? function (b) { return global.btoa(b) } : function (b) { return b.replace(/[\s\S]{1,3}/g, cb_encode) }; var _encode = buffer ? buffer.from && buffer.from !== Uint8Array.from ? function (u) { return (u.constructor === buffer.constructor ? u : buffer.from(u)).toString("base64") } : function (u) { return (u.constructor === buffer.constructor ? u : new buffer(u)).toString("base64") } : function (u) { return btoa(utob(u)) }; var encode = function (u, urisafe) { return !urisafe ? _encode(String(u)) : _encode(String(u)).replace(/[+\/]/g, function (m0) { return m0 == "+" ? "-" : "_" }).replace(/=/g, "") }; var encodeURI = function (u) { return encode(u, true) }; var re_btou = new RegExp(["[À-ß][-¿]", "[à-ï][-¿]{2}", "[ð-÷][-¿]{3}"].join("|"), "g"); var cb_btou = function (cccc) { switch (cccc.length) { case 4: var cp = (7 & cccc.charCodeAt(0)) << 18 | (63 & cccc.charCodeAt(1)) << 12 | (63 & cccc.charCodeAt(2)) << 6 | 63 & cccc.charCodeAt(3), offset = cp - 65536; return fromCharCode((offset >>> 10) + 55296) + fromCharCode((offset & 1023) + 56320); case 3: return fromCharCode((15 & cccc.charCodeAt(0)) << 12 | (63 & cccc.charCodeAt(1)) << 6 | 63 & cccc.charCodeAt(2)); default: return fromCharCode((31 & cccc.charCodeAt(0)) << 6 | 63 & cccc.charCodeAt(1)) } }; var btou = function (b) { return b.replace(re_btou, cb_btou) }; var cb_decode = function (cccc) { var len = cccc.length, padlen = len % 4, n = (len > 0 ? b64tab[cccc.charAt(0)] << 18 : 0) | (len > 1 ? b64tab[cccc.charAt(1)] << 12 : 0) | (len > 2 ? b64tab[cccc.charAt(2)] << 6 : 0) | (len > 3 ? b64tab[cccc.charAt(3)] : 0), chars = [fromCharCode(n >>> 16), fromCharCode(n >>> 8 & 255), fromCharCode(n & 255)]; chars.length -= [0, 0, 2, 1][padlen]; return chars.join("") }; var atob = global.atob ? function (a) { return global.atob(a) } : function (a) { return a.replace(/[\s\S]{1,4}/g, cb_decode) }; var _decode = buffer ? buffer.from && buffer.from !== Uint8Array.from ? function (a) { return (a.constructor === buffer.constructor ? a : buffer.from(a, "base64")).toString() } : function (a) { return (a.constructor === buffer.constructor ? a : new buffer(a, "base64")).toString() } : function (a) { return btou(atob(a)) }; var decode = function (a) { return _decode(String(a).replace(/[-_]/g, function (m0) { return m0 == "-" ? "+" : "/" }).replace(/[^A-Za-z0-9\+\/]/g, "")) }; var noConflict = function () { var Base64 = global.Base64; global.Base64 = _Base64; return Base64 }; global.Base64 = { VERSION: version, atob: atob, btoa: btoa, fromBase64: decode, toBase64: encode, utob: utob, encode: encode, encodeURI: encodeURI, btou: btou, decode: decode, noConflict: noConflict }; if (typeof Object.defineProperty === "function") { var noEnum = function (v) { return { value: v, enumerable: false, writable: true, configurable: true } }; global.Base64.extendString = function () { Object.defineProperty(String.prototype, "fromBase64", noEnum(function () { return decode(this) })); Object.defineProperty(String.prototype, "toBase64", noEnum(function (urisafe) { return encode(this, urisafe) })); Object.defineProperty(String.prototype, "toBase64URI", noEnum(function () { return encode(this, true) })) } } if (global["Meteor"]) { Base64 = global.Base64 } if (typeof module !== "undefined" && module.exports) { module.exports.Base64 = global.Base64 } else if (typeof define === "function" && define.amd) { define([], function () { return global.Base64 }) } })(typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : typeof global !== "undefined" ? global : this);
--------------------------------------------------------------------------------