├── .gitignore ├── .pre-commit ├── CNAME ├── LICENSE ├── README.md ├── _config.yml ├── dist ├── getChannelDesc.js ├── getChannelDesc.js.map ├── getChannelVideos.js ├── getChannelVideos.js.map ├── getPlaylistVideos.js ├── getPlaylistVideos.js.map ├── getVideoDate.js ├── getVideoDate.js.map ├── getVideoDesc.js ├── getVideoDesc.js.map ├── getVideosFromDesc.js ├── getVideosFromDesc.js.map ├── helpers │ ├── cleanTitle.js │ ├── cleanTitle.js.map │ ├── decodeHex.js │ ├── decodeHex.js.map │ ├── findVal.js │ ├── findVal.js.map │ ├── formatVideo.js │ ├── formatVideo.js.map │ ├── formatYoutubeCount.js │ ├── formatYoutubeCount.js.map │ ├── getData.js │ ├── getData.js.map │ ├── getDateFromText.js │ ├── getDateFromText.js.map │ ├── wait.js │ └── wait.js.map ├── searchChannel.js ├── searchChannel.js.map ├── searchVideo.js ├── searchVideo.js.map ├── usetube.js └── usetube.js.map ├── logo.svg ├── package.json ├── request.json ├── src ├── getChannelDesc.ts ├── getChannelVideos.ts ├── getPlaylistVideos.ts ├── getVideoDate.ts ├── getVideoDesc.ts ├── getVideosFromDesc.ts ├── helpers │ ├── cleanTitle.ts │ ├── decodeHex.ts │ ├── findVal.ts │ ├── formatVideo.ts │ ├── formatYoutubeCount.ts │ ├── getData.ts │ ├── getDateFromText.ts │ └── wait.ts ├── searchChannel.ts ├── searchVideo.ts ├── types │ ├── channel.d.ts │ ├── searchResult.d.ts │ └── video.d.ts └── usetube.ts ├── test.js ├── tsconfig.json └── yarn.lock /.gitignore: -------------------------------------------------------------------------------- 1 | # Created by https://www.gitignore.io/api/node 2 | # Edit at https://www.gitignore.io/?templates=node 3 | 4 | ### Node ### 5 | # Logs 6 | logs 7 | *.log 8 | npm-debug.log* 9 | yarn-debug.log* 10 | yarn-error.log* 11 | lerna-debug.log* 12 | raw.json 13 | 14 | # Diagnostic reports (https://nodejs.org/api/report.html) 15 | report.[0-9]*.[0-9]*.[0-9]*.[0-9]*.json 16 | 17 | # Runtime data 18 | pids 19 | *.pid 20 | *.seed 21 | *.pid.lock 22 | 23 | # Directory for instrumented libs generated by jscoverage/JSCover 24 | lib-cov 25 | 26 | # Coverage directory used by tools like istanbul 27 | coverage 28 | *.lcov 29 | 30 | # nyc test coverage 31 | .nyc_output 32 | 33 | # Grunt intermediate storage (https://gruntjs.com/creating-plugins#storing-task-files) 34 | .grunt 35 | 36 | # Bower dependency directory (https://bower.io/) 37 | bower_components 38 | 39 | # node-waf configuration 40 | .lock-wscript 41 | 42 | # Compiled binary addons (https://nodejs.org/api/addons.html) 43 | build/Release 44 | 45 | # Dependency directories 46 | node_modules/ 47 | jspm_packages/ 48 | 49 | # TypeScript v1 declaration files 50 | typings/ 51 | 52 | # TypeScript cache 53 | *.tsbuildinfo 54 | 55 | # Optional npm cache directory 56 | .npm 57 | 58 | # Optional eslint cache 59 | .eslintcache 60 | 61 | # Optional REPL history 62 | .node_repl_history 63 | 64 | # Output of 'npm pack' 65 | *.tgz 66 | 67 | # Yarn Integrity file 68 | .yarn-integrity 69 | 70 | # dotenv environment variables file 71 | .env 72 | .env.test 73 | 74 | # parcel-bundler cache (https://parceljs.org/) 75 | .cache 76 | 77 | # next.js build output 78 | .next 79 | 80 | # vuepress build output 81 | .vuepress/dist 82 | 83 | # Serverless directories 84 | .serverless/ 85 | 86 | # FuseBox cache 87 | .fusebox/ 88 | 89 | # DynamoDB Local files 90 | .dynamodb/ 91 | 92 | # database excluding 93 | *.db 94 | 95 | # package lock 96 | package-lock.json 97 | -------------------------------------------------------------------------------- /.pre-commit: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | npm run build 4 | git add dist -------------------------------------------------------------------------------- /CNAME: -------------------------------------------------------------------------------- 1 | usetube.js.org -------------------------------------------------------------------------------- /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 |

2 | 3 | Usetube 4 | 5 |

6 | 7 | [![Version](https://img.shields.io/npm/v/usetube.svg)](https://www.npmjs.com/package/usetube) 8 | [![Downloads](https://img.shields.io/npm/dt/usetube.svg)](https://www.npmjs.com/package/usetube) 9 | 10 | ### Youtube Crawler 11 | 12 | ### search & get datas from youtube 13 | 14 | ### no google account needed 15 | 16 |
17 | 18 | This package is initially dev for the site https://massivemusic.fr/add-tracks/, 19 | It's here for sharing & contribute. 20 | 21 | # usage 22 | 23 | ```js 24 | const usetube = require('usetube') 25 | await usetube.searchVideo('Lorn') 26 | ``` 27 | 28 | # methods 29 | ```js 30 | searchVideo(terms) 31 | searchChannel(terms) 32 | getChannelVideos(channel_id) 33 | getPlaylistVideos(playlist_id) 34 | getChannelDesc(channel_id) 35 | getVideoDesc(video_id) 36 | getVideoDate(video_id) 37 | getVideosFromDesc(video_id) 38 | getVideoSubtitles(video_id) 39 | ``` 40 | 41 | # returned datas 42 | ```js 43 | video { 44 | id 45 | original_title 46 | title 47 | artist 48 | duration 49 | publishedAt 50 | } 51 | ``` 52 | ```js 53 | channel { 54 | name 55 | channel_id 56 | nb_videos 57 | nb_subscriber 58 | official 59 | channel_avatar_small 60 | channel_avatar_medium 61 | channel_avatar_large 62 | } 63 | ``` 64 | -------------------------------------------------------------------------------- /_config.yml: -------------------------------------------------------------------------------- 1 | theme: jekyll-theme-cayman -------------------------------------------------------------------------------- /dist/getChannelDesc.js: -------------------------------------------------------------------------------- 1 | "use strict"; 2 | var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { 3 | function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); } 4 | return new (P || (P = Promise))(function (resolve, reject) { 5 | function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } } 6 | function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } } 7 | function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); } 8 | step((generator = generator.apply(thisArg, _arguments || [])).next()); 9 | }); 10 | }; 11 | var __generator = (this && this.__generator) || function (thisArg, body) { 12 | var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g; 13 | return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g; 14 | function verb(n) { return function (v) { return step([n, v]); }; } 15 | function step(op) { 16 | if (f) throw new TypeError("Generator is already executing."); 17 | while (_) try { 18 | if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t; 19 | if (y = 0, t) op = [op[0] & 2, t.value]; 20 | switch (op[0]) { 21 | case 0: case 1: t = op; break; 22 | case 4: _.label++; return { value: op[1], done: false }; 23 | case 5: _.label++; y = op[1]; op = [0]; continue; 24 | case 7: op = _.ops.pop(); _.trys.pop(); continue; 25 | default: 26 | if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; } 27 | if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; } 28 | if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; } 29 | if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; } 30 | if (t[2]) _.ops.pop(); 31 | _.trys.pop(); continue; 32 | } 33 | op = body.call(thisArg, _); 34 | } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; } 35 | if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true }; 36 | } 37 | }; 38 | Object.defineProperty(exports, "__esModule", { value: true }); 39 | var getData_1 = require("./helpers/getData"); 40 | function getChannelDesc(id) { 41 | var _a, _b; 42 | return __awaiter(this, void 0, void 0, function () { 43 | var data, description, e_1; 44 | return __generator(this, function (_c) { 45 | switch (_c.label) { 46 | case 0: 47 | _c.trys.push([0, 2, , 3]); 48 | return [4 /*yield*/, (0, getData_1.default)('https://m.youtube.com/channel/' + id + '/videos')]; 49 | case 1: 50 | data = _c.sent(); 51 | description = ((_b = (_a = data.metadata) === null || _a === void 0 ? void 0 : _a.channelMetadataRenderer) === null || _b === void 0 ? void 0 : _b.description) || ''; 52 | return [2 /*return*/, description]; 53 | case 2: 54 | e_1 = _c.sent(); 55 | console.log('channel desc error for ' + id); 56 | return [3 /*break*/, 3]; 57 | case 3: return [2 /*return*/]; 58 | } 59 | }); 60 | }); 61 | } 62 | exports.default = getChannelDesc; 63 | //# sourceMappingURL=getChannelDesc.js.map -------------------------------------------------------------------------------- /dist/getChannelDesc.js.map: -------------------------------------------------------------------------------- 1 | {"version":3,"file":"getChannelDesc.js","sourceRoot":"","sources":["../src/getChannelDesc.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,6CAAuC;AAEvC,SAA8B,cAAc,CAAC,EAAU;;;;;;;;oBAEjC,qBAAM,IAAA,iBAAO,EAAC,gCAAgC,GAAC,EAAE,GAAC,SAAS,CAAC,EAAA;;oBAAxE,IAAI,GAAQ,SAA4D;oBAC1E,WAAW,GAAW,CAAA,MAAA,MAAA,IAAI,CAAC,QAAQ,0CAAE,uBAAuB,0CAAE,WAAW,KAAI,EAAE,CAAA;oBACnF,sBAAO,WAAW,EAAA;;;oBAElB,OAAO,CAAC,GAAG,CAAC,yBAAyB,GAAC,EAAE,CAAC,CAAA;;;;;;CAG5C;AATD,iCASC"} -------------------------------------------------------------------------------- /dist/getChannelVideos.js: -------------------------------------------------------------------------------- 1 | "use strict"; 2 | var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { 3 | function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); } 4 | return new (P || (P = Promise))(function (resolve, reject) { 5 | function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } } 6 | function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } } 7 | function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); } 8 | step((generator = generator.apply(thisArg, _arguments || [])).next()); 9 | }); 10 | }; 11 | var __generator = (this && this.__generator) || function (thisArg, body) { 12 | var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g; 13 | return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g; 14 | function verb(n) { return function (v) { return step([n, v]); }; } 15 | function step(op) { 16 | if (f) throw new TypeError("Generator is already executing."); 17 | while (_) try { 18 | if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t; 19 | if (y = 0, t) op = [op[0] & 2, t.value]; 20 | switch (op[0]) { 21 | case 0: case 1: t = op; break; 22 | case 4: _.label++; return { value: op[1], done: false }; 23 | case 5: _.label++; y = op[1]; op = [0]; continue; 24 | case 7: op = _.ops.pop(); _.trys.pop(); continue; 25 | default: 26 | if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; } 27 | if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; } 28 | if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; } 29 | if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; } 30 | if (t[2]) _.ops.pop(); 31 | _.trys.pop(); continue; 32 | } 33 | op = body.call(thisArg, _); 34 | } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; } 35 | if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true }; 36 | } 37 | }; 38 | Object.defineProperty(exports, "__esModule", { value: true }); 39 | var youtubei_1 = require("youtubei"); 40 | var formatVideo_1 = require("./helpers/formatVideo"); 41 | function getChannelVideos(id, published_after) { 42 | return __awaiter(this, void 0, void 0, function () { 43 | var youtube, data, channelsVideos, apikey, token, videos, i, video, e_1; 44 | return __generator(this, function (_a) { 45 | switch (_a.label) { 46 | case 0: 47 | _a.trys.push([0, 7, , 8]); 48 | youtube = new youtubei_1.Client(); 49 | return [4 /*yield*/, youtube.findOne(id, { type: 'channel' })]; 50 | case 1: 51 | data = _a.sent(); 52 | return [4 /*yield*/, data.videos.next()]; 53 | case 2: 54 | _a.sent(); 55 | channelsVideos = data.videos.items; 56 | apikey = ''; 57 | token = 0; 58 | videos = []; 59 | i = 0; 60 | _a.label = 3; 61 | case 3: 62 | if (!(i < channelsVideos.length)) return [3 /*break*/, 6]; 63 | return [4 /*yield*/, (0, formatVideo_1.default)(channelsVideos[i], false)]; 64 | case 4: 65 | video = _a.sent(); 66 | if (video && video !== undefined && video.publishedAt) { 67 | if ((published_after && video.publishedAt.getTime() > published_after.getTime()) || !published_after) { 68 | videos.push(video); 69 | } 70 | } 71 | _a.label = 5; 72 | case 5: 73 | i++; 74 | return [3 /*break*/, 3]; 75 | case 6: return [2 /*return*/, videos]; 76 | case 7: 77 | e_1 = _a.sent(); 78 | console.log('cannot get channel videos for id: ' + id + ', try again'); 79 | console.log(e_1); 80 | return [3 /*break*/, 8]; 81 | case 8: return [2 /*return*/]; 82 | } 83 | }); 84 | }); 85 | } 86 | exports.default = getChannelVideos; 87 | //# sourceMappingURL=getChannelVideos.js.map -------------------------------------------------------------------------------- /dist/getChannelVideos.js.map: -------------------------------------------------------------------------------- 1 | {"version":3,"file":"getChannelVideos.js","sourceRoot":"","sources":["../src/getChannelVideos.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AACA,qCAAiC;AACjC,qDAA+C;AAE/C,SAA8B,gBAAgB,CAAC,EAAU,EAAE,eAAsB;;;;;;;oBAEvE,OAAO,GAAG,IAAI,iBAAM,EAAE,CAAA;oBACf,qBAAM,OAAO,CAAC,OAAO,CAAC,EAAE,EAAE,EAAC,IAAI,EAAE,SAAS,EAAC,CAAC,EAAA;;oBAAnD,IAAI,GAAG,SAA4C;oBACzD,qBAAM,IAAI,CAAC,MAAM,CAAC,IAAI,EAAE,EAAA;;oBAAxB,SAAwB,CAAA;oBAClB,cAAc,GAAG,IAAI,CAAC,MAAM,CAAC,KAAK,CAAA;oBAClC,MAAM,GAAW,EAAE,CAAA;oBACrB,KAAK,GAAY,CAAC,CAAA;oBAClB,MAAM,GAAY,EAAE,CAAA;oBAChB,CAAC,GAAG,CAAC;;;yBAAE,CAAA,CAAC,GAAG,cAAc,CAAC,MAAM,CAAA;oBACnB,qBAAM,IAAA,qBAAW,EAAC,cAAc,CAAC,CAAC,CAAC,EAAE,KAAK,CAAC,EAAA;;oBAA1D,KAAK,GAAU,SAA2C;oBAC9D,IAAI,KAAK,IAAI,KAAK,KAAK,SAAS,IAAI,KAAK,CAAC,WAAW,EAAE;wBACrD,IAAI,CAAC,eAAe,IAAI,KAAK,CAAC,WAAW,CAAC,OAAO,EAAE,GAAG,eAAe,CAAC,OAAO,EAAE,CAAC,IAAK,CAAC,eAAe,EAAE;4BACrG,MAAM,CAAC,IAAI,CAAC,KAAK,CAAC,CAAA;yBACnB;qBACF;;;oBANuC,CAAC,EAAE,CAAA;;wBAS7C,sBAAO,MAAM,EAAA;;;oBAEb,OAAO,CAAC,GAAG,CAAC,oCAAoC,GAAC,EAAE,GAAC,aAAa,CAAC,CAAA;oBAClE,OAAO,CAAC,GAAG,CAAC,GAAC,CAAC,CAAA;;;;;;CAEjB;AAvBD,mCAuBC"} -------------------------------------------------------------------------------- /dist/getPlaylistVideos.js: -------------------------------------------------------------------------------- 1 | "use strict"; 2 | var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { 3 | function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); } 4 | return new (P || (P = Promise))(function (resolve, reject) { 5 | function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } } 6 | function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } } 7 | function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); } 8 | step((generator = generator.apply(thisArg, _arguments || [])).next()); 9 | }); 10 | }; 11 | var __generator = (this && this.__generator) || function (thisArg, body) { 12 | var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g; 13 | return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g; 14 | function verb(n) { return function (v) { return step([n, v]); }; } 15 | function step(op) { 16 | if (f) throw new TypeError("Generator is already executing."); 17 | while (_) try { 18 | if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t; 19 | if (y = 0, t) op = [op[0] & 2, t.value]; 20 | switch (op[0]) { 21 | case 0: case 1: t = op; break; 22 | case 4: _.label++; return { value: op[1], done: false }; 23 | case 5: _.label++; y = op[1]; op = [0]; continue; 24 | case 7: op = _.ops.pop(); _.trys.pop(); continue; 25 | default: 26 | if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; } 27 | if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; } 28 | if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; } 29 | if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; } 30 | if (t[2]) _.ops.pop(); 31 | _.trys.pop(); continue; 32 | } 33 | op = body.call(thisArg, _); 34 | } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; } 35 | if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true }; 36 | } 37 | }; 38 | Object.defineProperty(exports, "__esModule", { value: true }); 39 | var youtubei_1 = require("youtubei"); 40 | function getPlaylistVideos(id, speedDate) { 41 | return __awaiter(this, void 0, void 0, function () { 42 | var youtube, data, items, e_1; 43 | return __generator(this, function (_a) { 44 | switch (_a.label) { 45 | case 0: 46 | _a.trys.push([0, 2, , 3]); 47 | youtube = new youtubei_1.Client(); 48 | return [4 /*yield*/, youtube.findOne(id, { type: 'playlist' })]; 49 | case 1: 50 | data = _a.sent(); 51 | items = data; 52 | return [2 /*return*/, data 53 | // const apikey = '' 54 | // let token: number = '' 55 | // let videos: Video[] = [] 56 | // for(let i = 0; i < items.length; i++) { 57 | // if (items[i]) { 58 | // const formated = await formatVideo(items[i], speedDate) 59 | // if (formated) { 60 | // videos.push(formated) 61 | // } 62 | // } 63 | // } 64 | // while(token) { 65 | // try { 66 | // console.log('wip') 67 | // } catch(e) { 68 | // console.log('getPlaylistVideos failed') 69 | // // console.log(e) 70 | // token = '' 71 | // } 72 | // } 73 | // return videos 74 | ]; 75 | case 2: 76 | e_1 = _a.sent(); 77 | console.log('cannot get playlist ' + id + ', try again'); 78 | return [3 /*break*/, 3]; 79 | case 3: return [2 /*return*/]; 80 | } 81 | }); 82 | }); 83 | } 84 | exports.default = getPlaylistVideos; 85 | //# sourceMappingURL=getPlaylistVideos.js.map -------------------------------------------------------------------------------- /dist/getPlaylistVideos.js.map: -------------------------------------------------------------------------------- 1 | {"version":3,"file":"getPlaylistVideos.js","sourceRoot":"","sources":["../src/getPlaylistVideos.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AACA,qCAAiC;AAGjC,SAA8B,iBAAiB,CAAC,EAAU,EAAE,SAAmB;;;;;;;oBAErE,OAAO,GAAG,IAAI,iBAAM,EAAE,CAAA;oBACf,qBAAM,OAAO,CAAC,OAAO,CAAC,EAAE,EAAE,EAAC,IAAI,EAAE,UAAU,EAAC,CAAC,EAAA;;oBAApD,IAAI,GAAG,SAA6C;oBACpD,KAAK,GAAG,IAAI,CAAA;oBAClB,sBAAO,IAAI;wBACX,oBAAoB;wBACpB,yBAAyB;wBACzB,2BAA2B;wBAC3B,0CAA0C;wBAC1C,oBAAoB;wBACpB,8DAA8D;wBAC9D,sBAAsB;wBACtB,8BAA8B;wBAC9B,QAAQ;wBACR,MAAM;wBACN,IAAI;wBACJ,iBAAiB;wBACjB,UAAU;wBACV,yBAAyB;wBACzB,iBAAiB;wBACjB,8CAA8C;wBAC9C,wBAAwB;wBACxB,iBAAiB;wBACjB,MAAM;wBACN,IAAI;wBACJ,gBAAgB;sBArBL;;;oBAuBX,OAAO,CAAC,GAAG,CAAC,sBAAsB,GAAC,EAAE,GAAC,aAAa,CAAC,CAAA;;;;;;CAGvD;AA/BD,oCA+BC"} -------------------------------------------------------------------------------- /dist/getVideoDate.js: -------------------------------------------------------------------------------- 1 | "use strict"; 2 | var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { 3 | function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); } 4 | return new (P || (P = Promise))(function (resolve, reject) { 5 | function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } } 6 | function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } } 7 | function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); } 8 | step((generator = generator.apply(thisArg, _arguments || [])).next()); 9 | }); 10 | }; 11 | var __generator = (this && this.__generator) || function (thisArg, body) { 12 | var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g; 13 | return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g; 14 | function verb(n) { return function (v) { return step([n, v]); }; } 15 | function step(op) { 16 | if (f) throw new TypeError("Generator is already executing."); 17 | while (_) try { 18 | if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t; 19 | if (y = 0, t) op = [op[0] & 2, t.value]; 20 | switch (op[0]) { 21 | case 0: case 1: t = op; break; 22 | case 4: _.label++; return { value: op[1], done: false }; 23 | case 5: _.label++; y = op[1]; op = [0]; continue; 24 | case 7: op = _.ops.pop(); _.trys.pop(); continue; 25 | default: 26 | if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; } 27 | if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; } 28 | if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; } 29 | if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; } 30 | if (t[2]) _.ops.pop(); 31 | _.trys.pop(); continue; 32 | } 33 | op = body.call(thisArg, _); 34 | } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; } 35 | if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true }; 36 | } 37 | }; 38 | Object.defineProperty(exports, "__esModule", { value: true }); 39 | var youtubei_1 = require("youtubei"); 40 | var dayjs = require("dayjs"); 41 | function getVideoDate(id) { 42 | return __awaiter(this, void 0, void 0, function () { 43 | var youtube, data, stringDate, finalDate, e_1; 44 | return __generator(this, function (_a) { 45 | switch (_a.label) { 46 | case 0: 47 | _a.trys.push([0, 2, , 3]); 48 | youtube = new youtubei_1.Client(); 49 | return [4 /*yield*/, youtube.getVideo(id)]; 50 | case 1: 51 | data = _a.sent(); 52 | stringDate = data.uploadDate.replace(/^\D+/, ''); 53 | stringDate = stringDate.replace('janv.', 'jan').replace('févr.', 'feb').replace('mars', 'mar').replace('avr.', 'apr').replace('mai', 'may').replace('juin', 'jun').replace('juil.', 'jul').replace('août', 'aug').replace('déc.', 'dec'); 54 | finalDate = dayjs(stringDate).toDate(); 55 | console.log(stringDate + ': ' + finalDate); 56 | return [2 /*return*/, finalDate]; 57 | case 2: 58 | e_1 = _a.sent(); 59 | console.log('cannot get date for ' + id + ', try again'); 60 | return [3 /*break*/, 3]; 61 | case 3: return [2 /*return*/]; 62 | } 63 | }); 64 | }); 65 | } 66 | exports.default = getVideoDate; 67 | //# sourceMappingURL=getVideoDate.js.map -------------------------------------------------------------------------------- /dist/getVideoDate.js.map: -------------------------------------------------------------------------------- 1 | {"version":3,"file":"getVideoDate.js","sourceRoot":"","sources":["../src/getVideoDate.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,qCAAiC;AACjC,6BAA8B;AAE9B,SAA8B,YAAY,CAAC,EAAU;;;;;;;oBAE3C,OAAO,GAAG,IAAI,iBAAM,EAAE,CAAA;oBACf,qBAAM,OAAO,CAAC,QAAQ,CAAC,EAAE,CAAC,EAAA;;oBAAjC,IAAI,GAAG,SAA0B;oBACnC,UAAU,GAAG,IAAI,CAAC,UAAU,CAAC,OAAO,CAAC,MAAM,EAAC,EAAE,CAAC,CAAA;oBACnD,UAAU,GAAG,UAAU,CAAC,OAAO,CAAC,OAAO,EAAE,KAAK,CAAC,CAAC,OAAO,CAAC,OAAO,EAAE,KAAK,CAAC,CAAC,OAAO,CAAC,MAAM,EAAE,KAAK,CAAC,CAAC,OAAO,CAAC,MAAM,EAAE,KAAK,CAAC,CAAC,OAAO,CAAC,KAAK,EAAE,KAAK,CAAC,CAAC,OAAO,CAAC,MAAM,EAAE,KAAK,CAAC,CAAC,OAAO,CAAC,OAAO,EAAC,KAAK,CAAC,CAAC,OAAO,CAAC,MAAM,EAAC,KAAK,CAAC,CAAC,OAAO,CAAC,MAAM,EAAC,KAAK,CAAC,CAAA;oBAC/N,SAAS,GAAG,KAAK,CAAC,UAAU,CAAC,CAAC,MAAM,EAAE,CAAA;oBAC5C,OAAO,CAAC,GAAG,CAAC,UAAU,GAAC,IAAI,GAAC,SAAS,CAAC,CAAA;oBACtC,sBAAO,SAAS,EAAA;;;oBAEhB,OAAO,CAAC,GAAG,CAAC,sBAAsB,GAAC,EAAE,GAAC,aAAa,CAAC,CAAA;;;;;;CAGvD;AAbD,+BAaC"} -------------------------------------------------------------------------------- /dist/getVideoDesc.js: -------------------------------------------------------------------------------- 1 | "use strict"; 2 | var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { 3 | function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); } 4 | return new (P || (P = Promise))(function (resolve, reject) { 5 | function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } } 6 | function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } } 7 | function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); } 8 | step((generator = generator.apply(thisArg, _arguments || [])).next()); 9 | }); 10 | }; 11 | var __generator = (this && this.__generator) || function (thisArg, body) { 12 | var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g; 13 | return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g; 14 | function verb(n) { return function (v) { return step([n, v]); }; } 15 | function step(op) { 16 | if (f) throw new TypeError("Generator is already executing."); 17 | while (_) try { 18 | if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t; 19 | if (y = 0, t) op = [op[0] & 2, t.value]; 20 | switch (op[0]) { 21 | case 0: case 1: t = op; break; 22 | case 4: _.label++; return { value: op[1], done: false }; 23 | case 5: _.label++; y = op[1]; op = [0]; continue; 24 | case 7: op = _.ops.pop(); _.trys.pop(); continue; 25 | default: 26 | if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; } 27 | if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; } 28 | if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; } 29 | if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; } 30 | if (t[2]) _.ops.pop(); 31 | _.trys.pop(); continue; 32 | } 33 | op = body.call(thisArg, _); 34 | } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; } 35 | if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true }; 36 | } 37 | }; 38 | Object.defineProperty(exports, "__esModule", { value: true }); 39 | var getData_1 = require("./helpers/getData"); 40 | var findVal_1 = require("./helpers/findVal"); 41 | function getVideoDesc(id) { 42 | return __awaiter(this, void 0, void 0, function () { 43 | var data, description, e_1; 44 | return __generator(this, function (_a) { 45 | switch (_a.label) { 46 | case 0: 47 | _a.trys.push([0, 2, , 3]); 48 | return [4 /*yield*/, (0, getData_1.default)('https://m.youtube.com/watch?v=' + id)]; 49 | case 1: 50 | data = _a.sent(); 51 | description = (0, findVal_1.default)(data, 'descriptionBodyText').runs[0].text || ''; 52 | return [2 /*return*/, description]; 53 | case 2: 54 | e_1 = _a.sent(); 55 | console.log('video desc error for ' + id); 56 | console.log(e_1); 57 | return [3 /*break*/, 3]; 58 | case 3: return [2 /*return*/]; 59 | } 60 | }); 61 | }); 62 | } 63 | exports.default = getVideoDesc; 64 | //# sourceMappingURL=getVideoDesc.js.map -------------------------------------------------------------------------------- /dist/getVideoDesc.js.map: -------------------------------------------------------------------------------- 1 | {"version":3,"file":"getVideoDesc.js","sourceRoot":"","sources":["../src/getVideoDesc.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,6CAAuC;AACvC,6CAAuC;AAEvC,SAA8B,YAAY,CAAC,EAAU;;;;;;;oBAE/B,qBAAM,IAAA,iBAAO,EAAC,gCAAgC,GAAG,EAAE,CAAC,EAAA;;oBAAhE,IAAI,GAAQ,SAAoD;oBAClE,WAAW,GAAW,IAAA,iBAAO,EAAC,IAAI,EAAE,qBAAqB,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,IAAI,IAAI,EAAE,CAAA;oBACjF,sBAAO,WAAW,EAAA;;;oBAElB,OAAO,CAAC,GAAG,CAAC,uBAAuB,GAAC,EAAE,CAAC,CAAA;oBACvC,OAAO,CAAC,GAAG,CAAC,GAAC,CAAC,CAAA;;;;;;CAEjB;AATD,+BASC"} -------------------------------------------------------------------------------- /dist/getVideosFromDesc.js: -------------------------------------------------------------------------------- 1 | "use strict"; 2 | var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { 3 | function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); } 4 | return new (P || (P = Promise))(function (resolve, reject) { 5 | function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } } 6 | function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } } 7 | function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); } 8 | step((generator = generator.apply(thisArg, _arguments || [])).next()); 9 | }); 10 | }; 11 | var __generator = (this && this.__generator) || function (thisArg, body) { 12 | var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g; 13 | return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g; 14 | function verb(n) { return function (v) { return step([n, v]); }; } 15 | function step(op) { 16 | if (f) throw new TypeError("Generator is already executing."); 17 | while (_) try { 18 | if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t; 19 | if (y = 0, t) op = [op[0] & 2, t.value]; 20 | switch (op[0]) { 21 | case 0: case 1: t = op; break; 22 | case 4: _.label++; return { value: op[1], done: false }; 23 | case 5: _.label++; y = op[1]; op = [0]; continue; 24 | case 7: op = _.ops.pop(); _.trys.pop(); continue; 25 | default: 26 | if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; } 27 | if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; } 28 | if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; } 29 | if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; } 30 | if (t[2]) _.ops.pop(); 31 | _.trys.pop(); continue; 32 | } 33 | op = body.call(thisArg, _); 34 | } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; } 35 | if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true }; 36 | } 37 | }; 38 | Object.defineProperty(exports, "__esModule", { value: true }); 39 | var cleanTitle_1 = require("./helpers/cleanTitle"); 40 | var getVideoDesc_1 = require("./getVideoDesc"); 41 | var getVideoDate_1 = require("./getVideoDate"); 42 | var searchVideo_1 = require("./searchVideo"); 43 | function getVideosFromDesc(yt_id) { 44 | return __awaiter(this, void 0, void 0, function () { 45 | var videos, desc, i, content, elt, title, artist, videosSearched, y, track, original_title_lower, _a, e_1; 46 | return __generator(this, function (_b) { 47 | switch (_b.label) { 48 | case 0: 49 | _b.trys.push([0, 10, , 11]); 50 | videos = []; 51 | return [4 /*yield*/, (0, getVideoDesc_1.default)(yt_id)]; 52 | case 1: 53 | desc = _b.sent(); 54 | if (!desc) return [3 /*break*/, 9]; 55 | i = 0; 56 | _b.label = 2; 57 | case 2: 58 | if (!(i < desc.length)) return [3 /*break*/, 9]; 59 | content = desc[i].text; 60 | if (!(content.includes('-') && content.length < 100)) return [3 /*break*/, 8]; 61 | elt = (0, cleanTitle_1.default)(content); 62 | title = elt.split('-')[1].trim(); 63 | artist = elt.split('-')[0].trim(); 64 | return [4 /*yield*/, (0, searchVideo_1.default)(title + ' ' + artist)]; 65 | case 3: 66 | videosSearched = _b.sent(); 67 | y = 0; 68 | _b.label = 4; 69 | case 4: 70 | if (!(y < videosSearched.videos.length)) return [3 /*break*/, 8]; 71 | track = videosSearched.videos[y]; 72 | original_title_lower = track.original_title.toLowerCase(); 73 | if (!(original_title_lower.includes(artist.split(' ')[0].toLowerCase()) && original_title_lower.includes(title.split(' ')[0].toLowerCase()))) return [3 /*break*/, 6]; 74 | _a = track; 75 | return [4 /*yield*/, (0, getVideoDate_1.default)(track.id)]; 76 | case 5: 77 | _a.publishedAt = _b.sent(); 78 | videos.push(track); 79 | return [3 /*break*/, 8]; 80 | case 6: return [3 /*break*/, 7]; 81 | case 7: 82 | y++; 83 | return [3 /*break*/, 4]; 84 | case 8: 85 | i++; 86 | return [3 /*break*/, 2]; 87 | case 9: return [2 /*return*/, videos]; 88 | case 10: 89 | e_1 = _b.sent(); 90 | console.log('getVideosFromDesc error, maybe captcha to resolve'); 91 | return [3 /*break*/, 11]; 92 | case 11: return [2 /*return*/]; 93 | } 94 | }); 95 | }); 96 | } 97 | exports.default = getVideosFromDesc; 98 | //# sourceMappingURL=getVideosFromDesc.js.map -------------------------------------------------------------------------------- /dist/getVideosFromDesc.js.map: -------------------------------------------------------------------------------- 1 | {"version":3,"file":"getVideosFromDesc.js","sourceRoot":"","sources":["../src/getVideosFromDesc.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAEA,mDAA6C;AAC7C,+CAAyC;AACzC,+CAAyC;AACzC,6CAAuC;AAEvC,SAA8B,iBAAiB,CAAC,KAAK;;;;;;;oBAE7C,MAAM,GAAY,EAAE,CAAA;oBACR,qBAAM,IAAA,sBAAY,EAAC,KAAK,CAAC,EAAA;;oBAArC,IAAI,GAAQ,SAAyB;yBACrC,IAAI,EAAJ,wBAAI;oBAEE,CAAC,GAAG,CAAC;;;yBAAE,CAAA,CAAC,GAAG,IAAI,CAAC,MAAM,CAAA;oBACtB,OAAO,GAAG,IAAI,CAAC,CAAC,CAAC,CAAC,IAAI,CAAA;yBACxB,CAAA,OAAO,CAAC,QAAQ,CAAC,GAAG,CAAC,IAAI,OAAO,CAAC,MAAM,GAAG,GAAG,CAAA,EAA7C,wBAA6C;oBAC3C,GAAG,GAAG,IAAA,oBAAU,EAAC,OAAO,CAAC,CAAA;oBACzB,KAAK,GAAG,GAAG,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC,IAAI,EAAE,CAAA;oBAChC,MAAM,GAAG,GAAG,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC,IAAI,EAAE,CAAA;oBACF,qBAAM,IAAA,qBAAW,EAAC,KAAK,GAAC,GAAG,GAAC,MAAM,CAAC,EAAA;;oBAAlE,cAAc,GAAiB,SAAmC;oBAE9D,CAAC,GAAG,CAAC;;;yBAAE,CAAA,CAAC,GAAG,cAAc,CAAC,MAAM,CAAC,MAAM,CAAA;oBACzC,KAAK,GAAG,cAAc,CAAC,MAAM,CAAC,CAAC,CAAC,CAAA;oBAChC,oBAAoB,GAAG,KAAK,CAAC,cAAc,CAAC,WAAW,EAAE,CAAA;yBACzD,CAAA,oBAAoB,CAAC,QAAQ,CAAC,MAAM,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC,WAAW,EAAE,CAAC,IAAI,oBAAoB,CAAC,QAAQ,CAAC,KAAK,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC,WAAW,EAAE,CAAC,CAAA,EAArI,wBAAqI;oBACvI,KAAA,KAAK,CAAA;oBAAe,qBAAM,IAAA,sBAAY,EAAC,KAAK,CAAC,EAAE,CAAC,EAAA;;oBAAhD,GAAM,WAAW,GAAG,SAA4B,CAAA;oBAChD,MAAM,CAAC,IAAI,CAAC,KAAK,CAAC,CAAA;oBAClB,wBAAW;wBAGX,wBAAc;;oBAT+B,CAAC,EAAE,CAAA;;;oBARxB,CAAC,EAAE,CAAA;;wBAuBrC,sBAAO,MAAM,EAAA;;;oBAEb,OAAO,CAAC,GAAG,CAAC,mDAAmD,CAAC,CAAA;;;;;;CAGnE;AAlCD,oCAkCC"} -------------------------------------------------------------------------------- /dist/helpers/cleanTitle.js: -------------------------------------------------------------------------------- 1 | "use strict"; 2 | Object.defineProperty(exports, "__esModule", { value: true }); 3 | function cleanTitle(title) { 4 | var braketsRegex = /\[[^)]*\]/; 5 | var forbidenTerms = ['(full album)', '(official ep)', '(official video)', '(video official)', '(radio edit)', '(DEEP MEDi Musik)', '(Original Mix)', '(Official Music Video)']; 6 | title = title.replace(braketsRegex, ''); 7 | forbidenTerms.forEach(function (forbidenTerm) { 8 | title = title.replace(new RegExp(forbidenTerm, 'ig'), ''); 9 | title = title.replace('()', ''); 10 | title = title.replace(/\[(.*)\]/, ''); 11 | }); 12 | return title; 13 | } 14 | exports.default = cleanTitle; 15 | //# sourceMappingURL=cleanTitle.js.map -------------------------------------------------------------------------------- /dist/helpers/cleanTitle.js.map: -------------------------------------------------------------------------------- 1 | {"version":3,"file":"cleanTitle.js","sourceRoot":"","sources":["../../src/helpers/cleanTitle.ts"],"names":[],"mappings":";;AAAA,SAAwB,UAAU,CAAC,KAAK;IACtC,IAAM,YAAY,GAAG,WAAW,CAAA;IAChC,IAAI,aAAa,GAAG,CAAC,cAAc,EAAE,eAAe,EAAE,kBAAkB,EAAE,kBAAkB,EAAE,cAAc,EAAC,mBAAmB,EAAE,gBAAgB,EAAE,wBAAwB,CAAC,CAAA;IAC7K,KAAK,GAAG,KAAK,CAAC,OAAO,CAAC,YAAY,EAAE,EAAE,CAAC,CAAA;IACvC,aAAa,CAAC,OAAO,CAAC,UAAA,YAAY;QAChC,KAAK,GAAG,KAAK,CAAC,OAAO,CAAC,IAAI,MAAM,CAAC,YAAY,EAAE,IAAI,CAAC,EAAE,EAAE,CAAC,CAAA;QACzD,KAAK,GAAG,KAAK,CAAC,OAAO,CAAC,IAAI,EAAE,EAAE,CAAC,CAAA;QAC/B,KAAK,GAAG,KAAK,CAAC,OAAO,CAAC,UAAU,EAAE,EAAE,CAAC,CAAA;IACvC,CAAC,CAAC,CAAA;IACF,OAAO,KAAK,CAAA;AACd,CAAC;AAVD,6BAUC"} -------------------------------------------------------------------------------- /dist/helpers/decodeHex.js: -------------------------------------------------------------------------------- 1 | "use strict"; 2 | Object.defineProperty(exports, "__esModule", { value: true }); 3 | function decodeHex(hex) { 4 | return hex.replace(/\\x22/g, '"').replace(/\\x7b/g, '{').replace(/\\x7d/g, '}').replace(/\\x5b/g, '[').replace(/\\x5d/g, ']').replace(/\\x3b/g, ';').replace(/\\x3d/g, '=').replace(/\\x27/g, '\'').replace(/\\\\/g, 'doubleAntiSlash').replace(/\\/g, '').replace(/doubleAntiSlash/g, '\\'); 5 | } 6 | exports.default = decodeHex; 7 | //# sourceMappingURL=decodeHex.js.map -------------------------------------------------------------------------------- /dist/helpers/decodeHex.js.map: -------------------------------------------------------------------------------- 1 | {"version":3,"file":"decodeHex.js","sourceRoot":"","sources":["../../src/helpers/decodeHex.ts"],"names":[],"mappings":";;AAAA,SAAwB,SAAS,CAAC,GAAG;IACnC,OAAO,GAAG,CAAC,OAAO,CAAC,QAAQ,EAAE,GAAG,CAAC,CAAC,OAAO,CAAC,QAAQ,EAAE,GAAG,CAAC,CAAC,OAAO,CAAC,QAAQ,EAAE,GAAG,CAAC,CAAC,OAAO,CAAC,QAAQ,EAAE,GAAG,CAAC,CAAC,OAAO,CAAC,QAAQ,EAAE,GAAG,CAAC,CAAC,OAAO,CAAC,QAAQ,EAAE,GAAG,CAAC,CAAC,OAAO,CAAC,QAAQ,EAAE,GAAG,CAAC,CAAC,OAAO,CAAC,QAAQ,EAAE,IAAI,CAAC,CAAC,OAAO,CAAC,OAAO,EAAE,iBAAiB,CAAC,CAAC,OAAO,CAAC,KAAK,EAAE,EAAE,CAAC,CAAC,OAAO,CAAC,kBAAkB,EAAE,IAAI,CAAC,CAAA;AAC9R,CAAC;AAFD,4BAEC"} -------------------------------------------------------------------------------- /dist/helpers/findVal.js: -------------------------------------------------------------------------------- 1 | "use strict"; 2 | Object.defineProperty(exports, "__esModule", { value: true }); 3 | function findVal(object, key) { 4 | var value; 5 | Object.keys(object).some(function (k) { 6 | if (k === key) { 7 | value = object[k]; 8 | return true; 9 | } 10 | if (object[k] && typeof object[k] === 'object') { 11 | value = findVal(object[k], key); 12 | return value !== undefined; 13 | } 14 | }); 15 | return value; 16 | } 17 | exports.default = findVal; 18 | //# sourceMappingURL=findVal.js.map -------------------------------------------------------------------------------- /dist/helpers/findVal.js.map: -------------------------------------------------------------------------------- 1 | {"version":3,"file":"findVal.js","sourceRoot":"","sources":["../../src/helpers/findVal.ts"],"names":[],"mappings":";;AAAA,SAAwB,OAAO,CAAC,MAAM,EAAE,GAAG;IACzC,IAAI,KAAK,CAAA;IACT,MAAM,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC,IAAI,CAAC,UAAU,CAAC;QAClC,IAAI,CAAC,KAAK,GAAG,EAAE;YACb,KAAK,GAAG,MAAM,CAAC,CAAC,CAAC,CAAA;YACjB,OAAO,IAAI,CAAA;SACZ;QACD,IAAI,MAAM,CAAC,CAAC,CAAC,IAAI,OAAO,MAAM,CAAC,CAAC,CAAC,KAAK,QAAQ,EAAE;YAC9C,KAAK,GAAG,OAAO,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,GAAG,CAAC,CAAA;YAC/B,OAAO,KAAK,KAAK,SAAS,CAAA;SAC3B;IACH,CAAC,CAAC,CAAA;IACF,OAAO,KAAK,CAAA;AACd,CAAC;AAbD,0BAaC"} -------------------------------------------------------------------------------- /dist/helpers/formatVideo.js: -------------------------------------------------------------------------------- 1 | "use strict"; 2 | var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { 3 | function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); } 4 | return new (P || (P = Promise))(function (resolve, reject) { 5 | function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } } 6 | function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } } 7 | function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); } 8 | step((generator = generator.apply(thisArg, _arguments || [])).next()); 9 | }); 10 | }; 11 | var __generator = (this && this.__generator) || function (thisArg, body) { 12 | var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g; 13 | return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g; 14 | function verb(n) { return function (v) { return step([n, v]); }; } 15 | function step(op) { 16 | if (f) throw new TypeError("Generator is already executing."); 17 | while (_) try { 18 | if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t; 19 | if (y = 0, t) op = [op[0] & 2, t.value]; 20 | switch (op[0]) { 21 | case 0: case 1: t = op; break; 22 | case 4: _.label++; return { value: op[1], done: false }; 23 | case 5: _.label++; y = op[1]; op = [0]; continue; 24 | case 7: op = _.ops.pop(); _.trys.pop(); continue; 25 | default: 26 | if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; } 27 | if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; } 28 | if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; } 29 | if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; } 30 | if (t[2]) _.ops.pop(); 31 | _.trys.pop(); continue; 32 | } 33 | op = body.call(thisArg, _); 34 | } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; } 35 | if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true }; 36 | } 37 | }; 38 | Object.defineProperty(exports, "__esModule", { value: true }); 39 | var getVideoDate_1 = require("../getVideoDate"); 40 | var getDateFromText_1 = require("./getDateFromText"); 41 | function formatVideo(video, speedDate) { 42 | if (speedDate === void 0) { speedDate = false; } 43 | return __awaiter(this, void 0, void 0, function () { 44 | var splited, publishedAt, e_1; 45 | return __generator(this, function (_a) { 46 | switch (_a.label) { 47 | case 0: 48 | _a.trys.push([0, 4, , 5]); 49 | // title formating 50 | video.original_title = video.title; 51 | if (video.title.split('-').length === 1) { 52 | video.artist = ''; 53 | } 54 | else { 55 | splited = video.original_title.match(/([^,]*)-(.*)/); 56 | video.artist = splited[1]; 57 | video.title = splited[2]; 58 | } 59 | publishedAt = new Date(Date.now()); 60 | if (!speedDate) return [3 /*break*/, 1]; 61 | publishedAt = (0, getDateFromText_1.default)(video.uploadDate); 62 | return [3 /*break*/, 3]; 63 | case 1: return [4 /*yield*/, (0, getVideoDate_1.default)(video.id)]; 64 | case 2: 65 | publishedAt = _a.sent(); 66 | _a.label = 3; 67 | case 3: return [2 /*return*/, { 68 | id: video.id, 69 | original_title: video.original_title.trim(), 70 | title: video.title.trim(), 71 | artist: video.artist.trim(), 72 | duration: video.duration, 73 | publishedAt: publishedAt, 74 | }]; 75 | case 4: 76 | e_1 = _a.sent(); 77 | console.log('format video failed'); 78 | console.log(e_1); 79 | return [3 /*break*/, 5]; 80 | case 5: return [2 /*return*/]; 81 | } 82 | }); 83 | }); 84 | } 85 | exports.default = formatVideo; 86 | //# sourceMappingURL=formatVideo.js.map -------------------------------------------------------------------------------- /dist/helpers/formatVideo.js.map: -------------------------------------------------------------------------------- 1 | {"version":3,"file":"formatVideo.js","sourceRoot":"","sources":["../../src/helpers/formatVideo.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,gDAA0C;AAC1C,qDAA+C;AAE/C,SAA8B,WAAW,CAAC,KAAU,EAAE,SAA0B;IAA1B,0BAAA,EAAA,iBAA0B;;;;;;;oBAE5E,kBAAkB;oBAClB,KAAK,CAAC,cAAc,GAAG,KAAK,CAAC,KAAK,CAAA;oBAElC,IAAI,KAAK,CAAC,KAAK,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,MAAM,KAAK,CAAC,EAAE;wBACvC,KAAK,CAAC,MAAM,GAAG,EAAE,CAAA;qBAClB;yBACI;wBACC,OAAO,GAAG,KAAK,CAAC,cAAc,CAAC,KAAK,CAAC,cAAc,CAAC,CAAA;wBACxD,KAAK,CAAC,MAAM,GAAG,OAAO,CAAC,CAAC,CAAC,CAAA;wBACzB,KAAK,CAAC,KAAK,GAAG,OAAO,CAAC,CAAC,CAAC,CAAA;qBACzB;oBAEG,WAAW,GAAS,IAAI,IAAI,CAAC,IAAI,CAAC,GAAG,EAAE,CAAC,CAAA;yBACxC,SAAS,EAAT,wBAAS;oBACX,WAAW,GAAG,IAAA,yBAAe,EAAC,KAAK,CAAC,UAAU,CAAC,CAAA;;wBAGjC,qBAAM,IAAA,sBAAY,EAAC,KAAK,CAAC,EAAE,CAAC,EAAA;;oBAA1C,WAAW,GAAG,SAA4B,CAAA;;wBAE5C,sBAAO;wBACL,EAAE,EAAE,KAAK,CAAC,EAAE;wBACZ,cAAc,EAAE,KAAK,CAAC,cAAc,CAAC,IAAI,EAAE;wBAC3C,KAAK,EAAE,KAAK,CAAC,KAAK,CAAC,IAAI,EAAE;wBACzB,MAAM,EAAE,KAAK,CAAC,MAAM,CAAC,IAAI,EAAE;wBAC3B,QAAQ,EAAE,KAAK,CAAC,QAAQ;wBACxB,WAAW,EAAE,WAAW;qBACzB,EAAA;;;oBAED,OAAO,CAAC,GAAG,CAAC,qBAAqB,CAAC,CAAA;oBAClC,OAAO,CAAC,GAAG,CAAC,GAAC,CAAC,CAAA;;;;;;CAEjB;AAjCD,8BAiCC"} -------------------------------------------------------------------------------- /dist/helpers/formatYoutubeCount.js: -------------------------------------------------------------------------------- 1 | "use strict"; 2 | Object.defineProperty(exports, "__esModule", { value: true }); 3 | function formatYoutubeCount(raw) { 4 | var isMill = raw === null || raw === void 0 ? void 0 : raw.includes('M'); 5 | var isKilo = raw === null || raw === void 0 ? void 0 : raw.includes('k'); 6 | var nbSubscriber = raw === null || raw === void 0 ? void 0 : raw.replace(/[^0-9,.]/g, '').replace(',', '.'); 7 | if (isMill) { 8 | nbSubscriber *= 1000000; 9 | } 10 | else if (isKilo) { 11 | nbSubscriber *= 1000; 12 | } 13 | return parseInt(nbSubscriber) || 0; 14 | } 15 | exports.default = formatYoutubeCount; 16 | //# sourceMappingURL=formatYoutubeCount.js.map -------------------------------------------------------------------------------- /dist/helpers/formatYoutubeCount.js.map: -------------------------------------------------------------------------------- 1 | {"version":3,"file":"formatYoutubeCount.js","sourceRoot":"","sources":["../../src/helpers/formatYoutubeCount.ts"],"names":[],"mappings":";;AAAA,SAAwB,kBAAkB,CAAC,GAAG;IAC5C,IAAM,MAAM,GAAG,GAAG,aAAH,GAAG,uBAAH,GAAG,CAAE,QAAQ,CAAC,GAAG,CAAC,CAAA;IACjC,IAAM,MAAM,GAAG,GAAG,aAAH,GAAG,uBAAH,GAAG,CAAE,QAAQ,CAAC,GAAG,CAAC,CAAA;IACjC,IAAI,YAAY,GAAG,GAAG,aAAH,GAAG,uBAAH,GAAG,CAAE,OAAO,CAAC,WAAW,EAAE,EAAE,EAAE,OAAO,CAAC,GAAG,EAAE,GAAG,CAAC,CAAA;IAClE,IAAI,MAAM,EAAE;QACV,YAAY,IAAI,OAAO,CAAA;KACxB;SACI,IAAI,MAAM,EAAE;QACf,YAAY,IAAI,IAAI,CAAA;KACrB;IACD,OAAO,QAAQ,CAAC,YAAY,CAAC,IAAI,CAAC,CAAA;AACpC,CAAC;AAXD,qCAWC"} -------------------------------------------------------------------------------- /dist/helpers/getData.js: -------------------------------------------------------------------------------- 1 | "use strict"; 2 | var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { 3 | function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); } 4 | return new (P || (P = Promise))(function (resolve, reject) { 5 | function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } } 6 | function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } } 7 | function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); } 8 | step((generator = generator.apply(thisArg, _arguments || [])).next()); 9 | }); 10 | }; 11 | var __generator = (this && this.__generator) || function (thisArg, body) { 12 | var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g; 13 | return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g; 14 | function verb(n) { return function (v) { return step([n, v]); }; } 15 | function step(op) { 16 | if (f) throw new TypeError("Generator is already executing."); 17 | while (_) try { 18 | if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t; 19 | if (y = 0, t) op = [op[0] & 2, t.value]; 20 | switch (op[0]) { 21 | case 0: case 1: t = op; break; 22 | case 4: _.label++; return { value: op[1], done: false }; 23 | case 5: _.label++; y = op[1]; op = [0]; continue; 24 | case 7: op = _.ops.pop(); _.trys.pop(); continue; 25 | default: 26 | if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; } 27 | if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; } 28 | if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; } 29 | if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; } 30 | if (t[2]) _.ops.pop(); 31 | _.trys.pop(); continue; 32 | } 33 | op = body.call(thisArg, _); 34 | } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; } 35 | if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true }; 36 | } 37 | }; 38 | Object.defineProperty(exports, "__esModule", { value: true }); 39 | var axios_1 = require("axios"); 40 | var decodeHex_1 = require("./decodeHex"); 41 | var findVal_1 = require("./findVal"); 42 | function getData(urlstring) { 43 | var _a, _b; 44 | return __awaiter(this, void 0, void 0, function () { 45 | var dataRegex, playerRegex, dateRegex, apiRegex, url, isAjax, isDate, isSubtitles, body, headers, data, raw, raw, apikey, data; 46 | return __generator(this, function (_c) { 47 | switch (_c.label) { 48 | case 0: 49 | dataRegex = /var\ ytInitialData\ \=\ \'(.*)\'\;<\/script>/; 50 | playerRegex = /var\ ytInitialPlayerResponse\ \=\ (.*)id\=\"player\"/s; 51 | dateRegex = /publishDate":"(.*)","ownerChannelName/; 52 | apiRegex = /"innertubeApiKey":"(.*?)"/; 53 | url = new URL(urlstring); 54 | isAjax = false; 55 | isDate = false; 56 | isSubtitles = false; 57 | if (url.searchParams.get('token')) { 58 | isAjax = true; 59 | } 60 | if (url.searchParams.get('type') === 'date') { 61 | isDate = true; 62 | } 63 | if (url.searchParams.get('type') === 'subtitles') { 64 | isSubtitles = true; 65 | } 66 | if (!isAjax) return [3 /*break*/, 2]; 67 | data = { context: { client: { clientName: 'WEB', clientVersion: '2.20210401.08.00' } }, continuation: url.searchParams.get('token') }; 68 | return [4 /*yield*/, (0, axios_1.default)({ method: 'post', url: urlstring, data: data })]; 69 | case 1: 70 | body = (_c.sent()).data; 71 | return [2 /*return*/, { items: (0, findVal_1.default)(body, 'continuationItems'), token: (0, findVal_1.default)(body, 'token') }]; 72 | case 2: 73 | headers = { 74 | headers: { 75 | 'Access-Control-Allow-Origin': '*', 76 | 'x-youtube-client-name': 1, 77 | 'x-youtube-client-version': '2.20200911.04.00', 78 | 'User-Agent': 'Mozilla/5.0 (Linux; Android 5.0; SM-G900P Build/LRX21T) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/67.0.3396.87 Mobile Safari/537.36', 79 | } 80 | }; 81 | return [4 /*yield*/, (0, axios_1.default)(urlstring, headers)]; 82 | case 3: 83 | body = (_c.sent()).data; 84 | if (isDate) { 85 | raw = ((_a = dateRegex.exec(body)) === null || _a === void 0 ? void 0 : _a[1]) || '{}'; 86 | return [2 /*return*/, raw]; 87 | } 88 | else { 89 | raw = ((_b = dataRegex.exec(body)) === null || _b === void 0 ? void 0 : _b[1]) || '{}'; 90 | apikey = apiRegex.exec(body)[1] || ''; 91 | data = JSON.parse((0, decodeHex_1.default)(raw)); 92 | // let fs = require('fs'); fs.writeFile('raw.json', decodeHex(raw), (e)=>{console.log(e)}) 93 | data.apikey = apikey; 94 | return [2 /*return*/, data]; 95 | } 96 | _c.label = 4; 97 | case 4: return [2 /*return*/]; 98 | } 99 | }); 100 | }); 101 | } 102 | exports.default = getData; 103 | //# sourceMappingURL=getData.js.map -------------------------------------------------------------------------------- /dist/helpers/getData.js.map: -------------------------------------------------------------------------------- 1 | {"version":3,"file":"getData.js","sourceRoot":"","sources":["../../src/helpers/getData.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,+BAAyB;AACzB,yCAAmC;AACnC,qCAA+B;AAE/B,SAA8B,OAAO,CAAC,SAAiB;;;;;;;oBAC/C,SAAS,GAAI,8CAA8C,CAAA;oBAC3D,WAAW,GAAI,uDAAuD,CAAA;oBAEtE,SAAS,GAAI,uCAAuC,CAAA;oBACpD,QAAQ,GAAI,2BAA2B,CAAA;oBACzC,GAAG,GAAG,IAAI,GAAG,CAAC,SAAS,CAAC,CAAA;oBACxB,MAAM,GAAG,KAAK,CAAA;oBACd,MAAM,GAAG,KAAK,CAAA;oBACd,WAAW,GAAG,KAAK,CAAA;oBAEvB,IAAI,GAAG,CAAC,YAAY,CAAC,GAAG,CAAC,OAAO,CAAC,EAAE;wBACjC,MAAM,GAAG,IAAI,CAAA;qBACd;oBACD,IAAI,GAAG,CAAC,YAAY,CAAC,GAAG,CAAC,MAAM,CAAC,KAAK,MAAM,EAAE;wBAC3C,MAAM,GAAG,IAAI,CAAA;qBACd;oBACD,IAAI,GAAG,CAAC,YAAY,CAAC,GAAG,CAAC,MAAM,CAAC,KAAK,WAAW,EAAE;wBAChD,WAAW,GAAG,IAAI,CAAA;qBACnB;yBAEG,MAAM,EAAN,wBAAM;oBAEF,IAAI,GAAG,EAAE,OAAO,EAAE,EAAE,MAAM,EAAE,EAAE,UAAU,EAAE,KAAK,EAAE,aAAa,EAAE,kBAAkB,EAAE,EAAE,EAAE,YAAY,EAAE,GAAG,CAAC,YAAY,CAAC,GAAG,CAAC,OAAO,CAAC,EAAE,CAAA;oBACnI,qBAAM,IAAA,eAAK,EAAC,EAAE,MAAM,EAAE,MAAM,EAAE,GAAG,EAAE,SAAS,EAAE,IAAI,EAAE,IAAI,EAAE,CAAC,EAAA;;oBAAnE,IAAI,GAAG,CAAC,SAA2D,CAAC,CAAC,IAAI,CAAA;oBAEzE,sBAAO,EAAE,KAAK,EAAE,IAAA,iBAAO,EAAC,IAAI,EAAE,mBAAmB,CAAC,EAAE,KAAK,EAAE,IAAA,iBAAO,EAAC,IAAI,EAAE,OAAO,CAAC,EAAE,EAAA;;oBAGnF,OAAO,GAAG;wBACR,OAAO,EAAE;4BACP,6BAA6B,EAAG,GAAG;4BACnC,uBAAuB,EAAE,CAAC;4BAC1B,0BAA0B,EAAE,kBAAkB;4BAC9C,YAAY,EAAE,yIAAyI;yBACxJ;qBACF,CAAA;oBACO,qBAAM,IAAA,eAAK,EAAC,SAAS,EAAE,OAAO,CAAC,EAAA;;oBAAvC,IAAI,GAAG,CAAC,SAA+B,CAAC,CAAC,IAAI,CAAA;oBAC7C,IAAI,MAAM,EAAE;wBACJ,GAAG,GAAG,CAAA,MAAA,SAAS,CAAC,IAAI,CAAC,IAAI,CAAC,0CAAI,CAAC,CAAC,KAAI,IAAI,CAAA;wBAC9C,sBAAO,GAAG,EAAA;qBACX;yBACI;wBACG,GAAG,GAAG,CAAA,MAAA,SAAS,CAAC,IAAI,CAAC,IAAI,CAAC,0CAAG,CAAC,CAAC,KAAI,IAAI,CAAA;wBACvC,MAAM,GAAG,QAAQ,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,IAAI,EAAE,CAAA;wBAEvC,IAAI,GAAG,IAAI,CAAC,KAAK,CAAC,IAAA,mBAAS,EAAC,GAAG,CAAC,CAAC,CAAA;wBACrC,0FAA0F;wBAC1F,IAAI,CAAC,MAAM,GAAG,MAAM,CAAA;wBACpB,sBAAO,IAAI,EAAA;qBACZ;;;;;;CAEJ;AApDD,0BAoDC"} -------------------------------------------------------------------------------- /dist/helpers/getDateFromText.js: -------------------------------------------------------------------------------- 1 | "use strict"; 2 | Object.defineProperty(exports, "__esModule", { value: true }); 3 | function getDateFromText(dateTxt) { 4 | var unit = { 5 | second: { 6 | terms: ['sec', 'Sekun', 'segun'], 7 | factor: 1, 8 | }, 9 | minute: { 10 | terms: ['min'], 11 | factor: 1000 * 60, 12 | }, 13 | hour: { 14 | terms: ['hour', 'heure', 'uur'], 15 | factor: 1000 * 60 * 60, 16 | }, 17 | day: { 18 | terms: ['jour', 'day', 'gio', 'dag', 'tag', 'day'], 19 | factor: 1000 * 60 * 60 * 24, 20 | }, 21 | week: { 22 | terms: ['sem', 'week', 'setti', 'woche'], 23 | factor: 1000 * 60 * 60 * 24 * 7, 24 | }, 25 | month: { 26 | terms: ['mo'], 27 | factor: 1000 * 60 * 60 * 24 * 7 * 4, 28 | }, 29 | year: { 30 | terms: ['an', 'year', 'ja'], 31 | factor: 1000 * 60 * 60 * 24 * 7 * 4 * 12, 32 | }, 33 | }; 34 | var digit = parseInt(dateTxt.replace(/\D/g, '')) || 0; 35 | if (!dateTxt || digit === 0) { 36 | return new Date(Date.now()); 37 | } 38 | for (var i in unit) { 39 | for (var y in unit[i].terms) { 40 | if (dateTxt.includes(unit[i].terms[y])) { 41 | var secondsSince = unit[i].factor * digit; 42 | return new Date(Date.now() - secondsSince); 43 | } 44 | } 45 | } 46 | return new Date(Date.now()); 47 | } 48 | exports.default = getDateFromText; 49 | //# sourceMappingURL=getDateFromText.js.map -------------------------------------------------------------------------------- /dist/helpers/getDateFromText.js.map: -------------------------------------------------------------------------------- 1 | {"version":3,"file":"getDateFromText.js","sourceRoot":"","sources":["../../src/helpers/getDateFromText.ts"],"names":[],"mappings":";;AAAA,SAAwB,eAAe,CAAC,OAAe;IACrD,IAAM,IAAI,GAAG;QACX,MAAM,EAAE;YACN,KAAK,EAAE,CAAC,KAAK,EAAE,OAAO,EAAE,OAAO,CAAC;YAChC,MAAM,EAAE,CAAC;SACV;QACD,MAAM,EAAE;YACN,KAAK,EAAE,CAAC,KAAK,CAAC;YACd,MAAM,EAAE,IAAI,GAAC,EAAE;SAChB;QACD,IAAI,EAAE;YACJ,KAAK,EAAE,CAAC,MAAM,EAAE,OAAO,EAAE,KAAK,CAAC;YAC/B,MAAM,EAAE,IAAI,GAAC,EAAE,GAAC,EAAE;SACnB;QACD,GAAG,EAAE;YACH,KAAK,EAAE,CAAC,MAAM,EAAE,KAAK,EAAE,KAAK,EAAE,KAAK,EAAE,KAAK,EAAE,KAAK,CAAC;YAClD,MAAM,EAAE,IAAI,GAAC,EAAE,GAAC,EAAE,GAAC,EAAE;SACtB;QACD,IAAI,EAAE;YACJ,KAAK,EAAE,CAAC,KAAK,EAAE,MAAM,EAAE,OAAO,EAAE,OAAO,CAAC;YACxC,MAAM,EAAE,IAAI,GAAC,EAAE,GAAC,EAAE,GAAC,EAAE,GAAC,CAAC;SACxB;QACD,KAAK,EAAE;YACL,KAAK,EAAE,CAAC,IAAI,CAAC;YACb,MAAM,EAAE,IAAI,GAAC,EAAE,GAAC,EAAE,GAAC,EAAE,GAAC,CAAC,GAAC,CAAC;SAC1B;QACD,IAAI,EAAE;YACJ,KAAK,EAAE,CAAC,IAAI,EAAE,MAAM,EAAE,IAAI,CAAC;YAC3B,MAAM,EAAE,IAAI,GAAC,EAAE,GAAC,EAAE,GAAC,EAAE,GAAC,CAAC,GAAC,CAAC,GAAC,EAAE;SAC7B;KACF,CAAA;IACD,IAAM,KAAK,GAAG,QAAQ,CAAC,OAAO,CAAC,OAAO,CAAC,KAAK,EAAC,EAAE,CAAC,CAAC,IAAI,CAAC,CAAA;IAEtD,IAAI,CAAC,OAAO,IAAI,KAAK,KAAK,CAAC,EAAE;QAC3B,OAAO,IAAI,IAAI,CAAC,IAAI,CAAC,GAAG,EAAE,CAAC,CAAA;KAC5B;IAED,KAAI,IAAI,CAAC,IAAI,IAAI,EAAE;QACjB,KAAI,IAAI,CAAC,IAAI,IAAI,CAAC,CAAC,CAAC,CAAC,KAAK,EAAE;YAC1B,IAAI,OAAO,CAAC,QAAQ,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,EAAE;gBACtC,IAAM,YAAY,GAAG,IAAI,CAAC,CAAC,CAAC,CAAC,MAAM,GAAG,KAAK,CAAA;gBAC3C,OAAO,IAAI,IAAI,CAAC,IAAI,CAAC,GAAG,EAAE,GAAG,YAAY,CAAC,CAAA;aAC3C;SACF;KACF;IACD,OAAO,IAAI,IAAI,CAAC,IAAI,CAAC,GAAG,EAAE,CAAC,CAAA;AAC7B,CAAC;AA9CD,kCA8CC"} -------------------------------------------------------------------------------- /dist/helpers/wait.js: -------------------------------------------------------------------------------- 1 | "use strict"; 2 | Object.defineProperty(exports, "__esModule", { value: true }); 3 | function wait() { 4 | var ms = Math.floor(Math.random() * 300); 5 | var start = new Date().getTime(); 6 | var end = start; 7 | while (end < start + ms) { 8 | end = new Date().getTime(); 9 | } 10 | } 11 | exports.default = wait; 12 | //# sourceMappingURL=wait.js.map -------------------------------------------------------------------------------- /dist/helpers/wait.js.map: -------------------------------------------------------------------------------- 1 | {"version":3,"file":"wait.js","sourceRoot":"","sources":["../../src/helpers/wait.ts"],"names":[],"mappings":";;AAAA,SAAwB,IAAI;IAC1B,IAAI,EAAE,GAAG,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,MAAM,EAAE,GAAG,GAAG,CAAC,CAAA;IACxC,IAAI,KAAK,GAAG,IAAI,IAAI,EAAE,CAAC,OAAO,EAAE,CAAA;IAChC,IAAI,GAAG,GAAG,KAAK,CAAA;IACf,OAAM,GAAG,GAAG,KAAK,GAAG,EAAE,EAAE;QACtB,GAAG,GAAG,IAAI,IAAI,EAAE,CAAC,OAAO,EAAE,CAAA;KAC5B;AACF,CAAC;AAPD,uBAOC"} -------------------------------------------------------------------------------- /dist/searchChannel.js: -------------------------------------------------------------------------------- 1 | "use strict"; 2 | var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { 3 | function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); } 4 | return new (P || (P = Promise))(function (resolve, reject) { 5 | function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } } 6 | function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } } 7 | function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); } 8 | step((generator = generator.apply(thisArg, _arguments || [])).next()); 9 | }); 10 | }; 11 | var __generator = (this && this.__generator) || function (thisArg, body) { 12 | var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g; 13 | return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g; 14 | function verb(n) { return function (v) { return step([n, v]); }; } 15 | function step(op) { 16 | if (f) throw new TypeError("Generator is already executing."); 17 | while (_) try { 18 | if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t; 19 | if (y = 0, t) op = [op[0] & 2, t.value]; 20 | switch (op[0]) { 21 | case 0: case 1: t = op; break; 22 | case 4: _.label++; return { value: op[1], done: false }; 23 | case 5: _.label++; y = op[1]; op = [0]; continue; 24 | case 7: op = _.ops.pop(); _.trys.pop(); continue; 25 | default: 26 | if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; } 27 | if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; } 28 | if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; } 29 | if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; } 30 | if (t[2]) _.ops.pop(); 31 | _.trys.pop(); continue; 32 | } 33 | op = body.call(thisArg, _); 34 | } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; } 35 | if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true }; 36 | } 37 | }; 38 | Object.defineProperty(exports, "__esModule", { value: true }); 39 | var youtubei_1 = require("youtubei"); 40 | var formatYoutubeCount_1 = require("./helpers/formatYoutubeCount"); 41 | function searchChannel(terms, token, apikey) { 42 | return __awaiter(this, void 0, void 0, function () { 43 | var youtube, data, items, channels_1, didyoumean, e_1; 44 | return __generator(this, function (_a) { 45 | switch (_a.label) { 46 | case 0: 47 | _a.trys.push([0, 2, , 3]); 48 | youtube = new youtubei_1.Client(); 49 | return [4 /*yield*/, youtube.search(terms, { type: 'channel' })]; 50 | case 1: 51 | data = _a.sent(); 52 | items = []; 53 | channels_1 = []; 54 | didyoumean = ''; 55 | if (!token) { 56 | apikey = ''; 57 | token = 0; 58 | items = data.items; 59 | } 60 | else { 61 | console.log('wip'); 62 | } 63 | items.map(function (item) { 64 | var avatarId = item.thumbnails[0].url.replace('//yt3.ggpht.com/', ''); 65 | var nbSubscriber = (0, formatYoutubeCount_1.default)(item.subscriberCount || '0'); 66 | channels_1.push({ 67 | name: item.name, 68 | channel_id: item.subscriberCount, 69 | nb_videos: item.videoCount, 70 | nb_subscriber: nbSubscriber, 71 | official: false, 72 | channel_avatar_small: 'https://yt3.ggpht.com/' + avatarId.replace('=s88', '=s80'), 73 | channel_avatar_medium: 'https://yt3.ggpht.com/' + avatarId.replace('=s88', '=s200'), 74 | channel_avatar_large: 'https://yt3.ggpht.com/' + avatarId.replace('=s88', '=s800'), 75 | }); 76 | }); 77 | return [2 /*return*/, { 78 | channels: channels_1, 79 | didyoumean: didyoumean, 80 | token: token, 81 | apikey: apikey, 82 | }]; 83 | case 2: 84 | e_1 = _a.sent(); 85 | console.log('search channel error, terms: ' + terms); 86 | return [3 /*break*/, 3]; 87 | case 3: return [2 /*return*/]; 88 | } 89 | }); 90 | }); 91 | } 92 | exports.default = searchChannel; 93 | //# sourceMappingURL=searchChannel.js.map -------------------------------------------------------------------------------- /dist/searchChannel.js.map: -------------------------------------------------------------------------------- 1 | {"version":3,"file":"searchChannel.js","sourceRoot":"","sources":["../src/searchChannel.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AACA,qCAAiC;AACjC,mEAA6D;AAE7D,SAA8B,aAAa,CAAC,KAAa,EAAE,KAAc,EAAE,MAAe;;;;;;;oBAEhF,OAAO,GAAG,IAAI,iBAAM,EAAE,CAAA;oBACf,qBAAM,OAAO,CAAC,MAAM,CAAC,KAAK,EAAE,EAAE,IAAI,EAAE,SAAS,EAAE,CAAC,EAAA;;oBAAvD,IAAI,GAAG,SAAgD;oBAEzD,KAAK,GAAQ,EAAE,CAAA;oBACf,aAAsB,EAAE,CAAA;oBACxB,UAAU,GAAW,EAAE,CAAA;oBAC3B,IAAI,CAAC,KAAK,EAAE;wBACV,MAAM,GAAG,EAAE,CAAA;wBACX,KAAK,GAAG,CAAC,CAAA;wBACT,KAAK,GAAG,IAAI,CAAC,KAAK,CAAA;qBACnB;yBACI;wBACH,OAAO,CAAC,GAAG,CAAC,KAAK,CAAC,CAAA;qBACnB;oBACD,KAAK,CAAC,GAAG,CAAC,UAAA,IAAI;wBACZ,IAAM,QAAQ,GAAG,IAAI,CAAC,UAAU,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,OAAO,CAAC,kBAAkB,EAAE,EAAE,CAAC,CAAA;wBACvE,IAAM,YAAY,GAAW,IAAA,4BAAkB,EAAC,IAAI,CAAC,eAAe,IAAI,GAAG,CAAC,CAAA;wBAC5E,UAAQ,CAAC,IAAI,CAAC;4BACZ,IAAI,EAAmB,IAAI,CAAC,IAAI;4BAChC,UAAU,EAAa,IAAI,CAAC,eAAe;4BAC3C,SAAS,EAAc,IAAI,CAAC,UAAU;4BACtC,aAAa,EAAU,YAAY;4BACnC,QAAQ,EAAe,KAAK;4BAC5B,oBAAoB,EAAG,wBAAwB,GAAC,QAAQ,CAAC,OAAO,CAAC,MAAM,EAAC,MAAM,CAAC;4BAC/E,qBAAqB,EAAE,wBAAwB,GAAC,QAAQ,CAAC,OAAO,CAAC,MAAM,EAAC,OAAO,CAAC;4BAChF,oBAAoB,EAAE,wBAAwB,GAAC,QAAQ,CAAC,OAAO,CAAC,MAAM,EAAC,OAAO,CAAC;yBAChF,CAAC,CAAA;oBACJ,CAAC,CAAC,CAAA;oBACF,sBAAO;4BACL,QAAQ,EAAE,UAAQ;4BAClB,UAAU,EAAE,UAAU;4BACtB,KAAK,EAAE,KAAK;4BACZ,MAAM,EAAE,MAAM;yBACf,EAAA;;;oBAED,OAAO,CAAC,GAAG,CAAC,+BAA+B,GAAC,KAAK,CAAC,CAAA;;;;;;CAGrD;AAxCD,gCAwCC"} -------------------------------------------------------------------------------- /dist/searchVideo.js: -------------------------------------------------------------------------------- 1 | "use strict"; 2 | var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { 3 | function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); } 4 | return new (P || (P = Promise))(function (resolve, reject) { 5 | function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } } 6 | function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } } 7 | function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); } 8 | step((generator = generator.apply(thisArg, _arguments || [])).next()); 9 | }); 10 | }; 11 | var __generator = (this && this.__generator) || function (thisArg, body) { 12 | var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g; 13 | return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g; 14 | function verb(n) { return function (v) { return step([n, v]); }; } 15 | function step(op) { 16 | if (f) throw new TypeError("Generator is already executing."); 17 | while (_) try { 18 | if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t; 19 | if (y = 0, t) op = [op[0] & 2, t.value]; 20 | switch (op[0]) { 21 | case 0: case 1: t = op; break; 22 | case 4: _.label++; return { value: op[1], done: false }; 23 | case 5: _.label++; y = op[1]; op = [0]; continue; 24 | case 7: op = _.ops.pop(); _.trys.pop(); continue; 25 | default: 26 | if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; } 27 | if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; } 28 | if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; } 29 | if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; } 30 | if (t[2]) _.ops.pop(); 31 | _.trys.pop(); continue; 32 | } 33 | op = body.call(thisArg, _); 34 | } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; } 35 | if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true }; 36 | } 37 | }; 38 | Object.defineProperty(exports, "__esModule", { value: true }); 39 | var youtubei_1 = require("youtubei"); 40 | var formatVideo_1 = require("./helpers/formatVideo"); 41 | function searchVideo(terms, token, apikey) { 42 | return __awaiter(this, void 0, void 0, function () { 43 | var youtube, data, items, videos, didyoumean, i, i, formated, e_1; 44 | return __generator(this, function (_a) { 45 | switch (_a.label) { 46 | case 0: 47 | _a.trys.push([0, 6, , 7]); 48 | youtube = new youtubei_1.Client(); 49 | return [4 /*yield*/, youtube.search(terms, { type: 'video' })]; 50 | case 1: 51 | data = _a.sent(); 52 | items = []; 53 | videos = []; 54 | didyoumean = ''; 55 | for (i = 0; i < token; i++) { 56 | data.next(); 57 | } 58 | items = data.items; 59 | i = 0; 60 | _a.label = 2; 61 | case 2: 62 | if (!(i < items.length)) return [3 /*break*/, 5]; 63 | return [4 /*yield*/, (0, formatVideo_1.default)(items[i], true)]; 64 | case 3: 65 | formated = _a.sent(); 66 | if (formated) { 67 | if (formated.id === 'didyoumean') { 68 | didyoumean = formated.title; 69 | } 70 | else { 71 | videos.push(formated); 72 | } 73 | } 74 | _a.label = 4; 75 | case 4: 76 | i++; 77 | return [3 /*break*/, 2]; 78 | case 5: return [2 /*return*/, { 79 | videos: videos, 80 | didyoumean: didyoumean, 81 | token: apikey, 82 | apikey: apikey, 83 | }]; 84 | case 6: 85 | e_1 = _a.sent(); 86 | console.log('search videos error, terms: ' + terms); 87 | return [3 /*break*/, 7]; 88 | case 7: return [2 /*return*/]; 89 | } 90 | }); 91 | }); 92 | } 93 | exports.default = searchVideo; 94 | //# sourceMappingURL=searchVideo.js.map -------------------------------------------------------------------------------- /dist/searchVideo.js.map: -------------------------------------------------------------------------------- 1 | {"version":3,"file":"searchVideo.js","sourceRoot":"","sources":["../src/searchVideo.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AACA,qCAAiC;AACjC,qDAA+C;AAG/C,SAA8B,WAAW,CAAC,KAAa,EAAE,KAAc,EAAE,MAAe;;;;;;;oBAE9E,OAAO,GAAG,IAAI,iBAAM,EAAE,CAAA;oBACf,qBAAM,OAAO,CAAC,MAAM,CAAC,KAAK,EAAE,EAAE,IAAI,EAAE,OAAO,EAAE,CAAC,EAAA;;oBAArD,IAAI,GAAG,SAA8C;oBAEvD,KAAK,GAAQ,EAAE,CAAA;oBACf,MAAM,GAAY,EAAE,CAAA;oBACpB,UAAU,GAAW,EAAE,CAAA;oBAE3B,KAAQ,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,KAAK,EAAE,CAAC,EAAE,EAAI;wBAC/B,IAAI,CAAC,IAAI,EAAE,CAAA;qBACZ;oBAED,KAAK,GAAG,IAAI,CAAC,KAAK,CAAA;oBAEV,CAAC,GAAG,CAAC;;;yBAAE,CAAA,CAAC,GAAG,KAAK,CAAC,MAAM,CAAA;oBACP,qBAAM,IAAA,qBAAW,EAAC,KAAK,CAAC,CAAC,CAAC,EAAE,IAAI,CAAC,EAAA;;oBAAnD,QAAQ,GAAU,SAAiC;oBACvD,IAAI,QAAQ,EAAE;wBACZ,IAAI,QAAQ,CAAC,EAAE,KAAK,YAAY,EAAE;4BAChC,UAAU,GAAG,QAAQ,CAAC,KAAK,CAAA;yBAC5B;6BACI;4BACH,MAAM,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAA;yBACtB;qBACF;;;oBAT8B,CAAC,EAAE,CAAA;;wBAWpC,sBAAO;wBACL,MAAM,EAAE,MAAM;wBACd,UAAU,EAAE,UAAU;wBACtB,KAAK,EAAE,MAAM;wBACb,MAAM,EAAE,MAAM;qBACf,EAAA;;;oBAED,OAAO,CAAC,GAAG,CAAC,8BAA8B,GAAC,KAAK,CAAC,CAAA;;;;;;CAGpD;AApCD,8BAoCC"} -------------------------------------------------------------------------------- /dist/usetube.js: -------------------------------------------------------------------------------- 1 | "use strict"; 2 | Object.defineProperty(exports, "__esModule", { value: true }); 3 | exports.searchVideo = exports.searchChannel = exports.getVideosFromDesc = exports.getVideoDesc = exports.getVideoDate = exports.getPlaylistVideos = exports.getChannelVideos = exports.getChannelDesc = void 0; 4 | var getChannelDesc_1 = require("./getChannelDesc"); 5 | exports.getChannelDesc = getChannelDesc_1.default; 6 | var getChannelVideos_1 = require("./getChannelVideos"); 7 | exports.getChannelVideos = getChannelVideos_1.default; 8 | var getPlaylistVideos_1 = require("./getPlaylistVideos"); 9 | exports.getPlaylistVideos = getPlaylistVideos_1.default; 10 | var getVideoDate_1 = require("./getVideoDate"); 11 | exports.getVideoDate = getVideoDate_1.default; 12 | var getVideoDesc_1 = require("./getVideoDesc"); 13 | exports.getVideoDesc = getVideoDesc_1.default; 14 | var getVideosFromDesc_1 = require("./getVideosFromDesc"); 15 | exports.getVideosFromDesc = getVideosFromDesc_1.default; 16 | var searchChannel_1 = require("./searchChannel"); 17 | exports.searchChannel = searchChannel_1.default; 18 | var searchVideo_1 = require("./searchVideo"); 19 | exports.searchVideo = searchVideo_1.default; 20 | //# sourceMappingURL=usetube.js.map -------------------------------------------------------------------------------- /dist/usetube.js.map: -------------------------------------------------------------------------------- 1 | {"version":3,"file":"usetube.js","sourceRoot":"","sources":["../src/usetube.ts"],"names":[],"mappings":";;;AAAA,mDAA6C;AAU3C,yBAVK,wBAAc,CAUL;AAThB,uDAAiD;AAU/C,2BAVK,0BAAgB,CAUL;AATlB,yDAAmD;AAUjD,4BAVK,2BAAiB,CAUL;AATnB,+CAAyC;AAUvC,uBAVK,sBAAY,CAUL;AATd,+CAAyC;AAUvC,uBAVK,sBAAY,CAUL;AATd,yDAAmD;AAUjD,4BAVK,2BAAiB,CAUL;AATnB,iDAA2C;AAUzC,wBAVK,uBAAa,CAUL;AATf,6CAAuC;AAUrC,sBAVK,qBAAW,CAUL"} -------------------------------------------------------------------------------- /logo.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 19 | 21 | 43 | 45 | 46 | 48 | image/svg+xml 49 | 51 | 52 | 53 | 54 | 55 | 60 | 64 | 68 | 72 | 76 | 80 | 84 | 88 | 92 | 93 | 94 | 95 | -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "usetube", 3 | "version": "2.2.7", 4 | "description": "crawl youtube without api key (search videos channels or get all channel/playlist's videos)", 5 | "main": "dist/usetube", 6 | "directories": { 7 | "test": "test" 8 | }, 9 | "devDependencies": { 10 | "@types/node": "^14.14.7", 11 | "typescript": "^4.0.3" 12 | }, 13 | "scripts": { 14 | "build": "tsc -p tsconfig.json", 15 | "test": "npm run build && node test", 16 | "dev": "npm install && npx nodemon -e ts --exec 'npm run build && npm run test'" 17 | }, 18 | "repository": { 19 | "type": "git", 20 | "url": "git+https://github.com/valerebron/usetube.git" 21 | }, 22 | "keywords": [ 23 | "youtube", 24 | "crawler", 25 | "scraper", 26 | "api", 27 | "no", 28 | "key", 29 | "simple", 30 | "javascript", 31 | "youtube api", 32 | "youtube search", 33 | "youtube api no key", 34 | "youtube crawler", 35 | "youtube scrapper", 36 | "youtube open api", 37 | "youtube open source", 38 | "youtube simple", 39 | "youtube playlist", 40 | "yt" 41 | ], 42 | "author": "valerebron", 43 | "license": "AGPL-3.0-or-later", 44 | "bugs": { 45 | "url": "https://github.com/valerebron/usetube/issues" 46 | }, 47 | "homepage": "https://github.com/valerebron/usetube#readme", 48 | "dependencies": { 49 | "axios": "^0.21.1", 50 | "dayjs": "^1.11.7", 51 | "youtubei": "^1.1.2" 52 | } 53 | } 54 | -------------------------------------------------------------------------------- /request.json: -------------------------------------------------------------------------------- 1 | { 2 | "context": { 3 | "client": { 4 | "clientName": "WEB", 5 | "clientVersion": "2.20210401.08.00" 6 | } 7 | }, 8 | "continuation": "4qmFsgKFARIYVUMwRVhabTdXN0Y3cHgycmNxZWN5QzZ3GjpFZ1oyYVdSbGIzTVlBeUFBTUFFNEFlb0RGa05uUVZORFoybG1OamRZUm10alMwSjVlSGR2VFdjJTNEmgIsYnJvd3NlLWZlZWRVQzBFWFptN1c3RjdweDJyY3FlY3lDNnd2aWRlb3MxMDI%3D" 9 | } 10 | -------------------------------------------------------------------------------- /src/getChannelDesc.ts: -------------------------------------------------------------------------------- 1 | import getData from './helpers/getData' 2 | 3 | export default async function getChannelDesc(id: string) { 4 | try { 5 | const data: any = await getData('https://m.youtube.com/channel/'+id+'/videos') 6 | let description: string = data.metadata?.channelMetadataRenderer?.description || '' 7 | return description 8 | } catch(e) { 9 | console.log('channel desc error for '+id) 10 | // console.log(e) 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /src/getChannelVideos.ts: -------------------------------------------------------------------------------- 1 | import Video from './types/video' 2 | import { Client } from 'youtubei' 3 | import formatVideo from './helpers/formatVideo' 4 | 5 | export default async function getChannelVideos(id: string, published_after?: Date, token?: number) { 6 | try { 7 | const youtube = new Client() 8 | const data = await youtube.findOne(id, {type: 'channel'}) 9 | await data.videos.next() 10 | const channelsVideos = data.videos.items 11 | const apikey: String = '' 12 | let videos: Video[] = [] 13 | 14 | if(token) { 15 | for(let i = 0; i < token; i++ ) { 16 | data.videos.next() 17 | } 18 | } 19 | 20 | for(let i = 0; i < channelsVideos.length; i++) { 21 | let video: Video = await formatVideo(channelsVideos[i], false) 22 | if (video && video !== undefined && video.publishedAt) { 23 | if ((published_after && video.publishedAt.getTime() > published_after.getTime()) || !published_after) { 24 | videos.push(video) 25 | } 26 | } 27 | } 28 | 29 | return videos 30 | } catch(e) { 31 | console.log('cannot get channel videos for id: '+id+', try again') 32 | console.log(e) 33 | } 34 | } 35 | -------------------------------------------------------------------------------- /src/getPlaylistVideos.ts: -------------------------------------------------------------------------------- 1 | import Video from './types/video' 2 | import { Client } from 'youtubei' 3 | import formatVideo from './helpers/formatVideo' 4 | 5 | export default async function getPlaylistVideos(id: string, speedDate?: boolean) { 6 | try { 7 | const youtube = new Client() 8 | const data = await youtube.findOne(id, {type: 'playlist'}) 9 | const items = data 10 | return data 11 | // const apikey = '' 12 | // let token: number = '' 13 | // let videos: Video[] = [] 14 | // for(let i = 0; i < items.length; i++) { 15 | // if (items[i]) { 16 | // const formated = await formatVideo(items[i], speedDate) 17 | // if (formated) { 18 | // videos.push(formated) 19 | // } 20 | // } 21 | // } 22 | // while(token) { 23 | // try { 24 | // console.log('wip') 25 | // } catch(e) { 26 | // console.log('getPlaylistVideos failed') 27 | // // console.log(e) 28 | // token = '' 29 | // } 30 | // } 31 | // return videos 32 | } catch(e) { 33 | console.log('cannot get playlist '+id+', try again') 34 | // console.log(e) 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /src/getVideoDate.ts: -------------------------------------------------------------------------------- 1 | import { Client } from 'youtubei' 2 | import * as dayjs from 'dayjs' 3 | 4 | export default async function getVideoDate(id: string) { 5 | try { 6 | const youtube = new Client() 7 | const data = await youtube.getVideo(id) 8 | let stringDate = data.uploadDate.replace(/^\D+/,'') 9 | stringDate = stringDate.replace('janv.', 'jan').replace('févr.', 'feb').replace('mars', 'mar').replace('avr.', 'apr').replace('mai', 'may').replace('juin', 'jun').replace('juil.','jul').replace('août','aug').replace('déc.','dec') 10 | const finalDate = dayjs(stringDate).toDate() 11 | return finalDate 12 | } catch(e) { 13 | console.log('cannot get date for '+id+', try again') 14 | // console.log(e) 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /src/getVideoDesc.ts: -------------------------------------------------------------------------------- 1 | import getData from './helpers/getData' 2 | import findVal from './helpers/findVal' 3 | 4 | export default async function getVideoDesc(id: string) { 5 | try { 6 | const data: any = await getData('https://m.youtube.com/watch?v=' + id) 7 | let description: string = findVal(data, 'descriptionBodyText').runs[0].text || '' 8 | return description 9 | } catch(e) { 10 | console.log('video desc error for '+id) 11 | console.log(e) 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /src/getVideosFromDesc.ts: -------------------------------------------------------------------------------- 1 | import Video from './types/video' 2 | import SearchResult from './types/searchResult' 3 | import cleanTitle from './helpers/cleanTitle' 4 | import getVideoDesc from './getVideoDesc' 5 | import getVideoDate from './getVideoDate' 6 | import searchVideo from './searchVideo' 7 | 8 | export default async function getVideosFromDesc(yt_id) { 9 | try { 10 | let videos: Video[] = [] 11 | let desc: any = await getVideoDesc(yt_id) 12 | if (desc) { 13 | loop1: 14 | for(let i = 0; i < desc.length; i++) { 15 | const content = desc[i].text 16 | if (content.includes('-') && content.length < 100) { 17 | let elt = cleanTitle(content) 18 | let title = elt.split('-')[1].trim() 19 | let artist = elt.split('-')[0].trim() 20 | let videosSearched: SearchResult = await searchVideo(title+' '+artist) 21 | loop2: 22 | for(let y = 0; y < videosSearched.videos.length; y++) { 23 | let track = videosSearched.videos[y] 24 | let original_title_lower = track.original_title.toLowerCase() 25 | if (original_title_lower.includes(artist.split(' ')[0].toLowerCase()) && original_title_lower.includes(title.split(' ')[0].toLowerCase())) { 26 | track.publishedAt = await getVideoDate(track.id) 27 | videos.push(track) 28 | break loop2 29 | } 30 | else { 31 | continue loop2 32 | } 33 | } 34 | } 35 | } 36 | } 37 | return videos 38 | } catch(e) { 39 | console.log('getVideosFromDesc error, maybe captcha to resolve') 40 | // console.log(e) 41 | } 42 | } 43 | -------------------------------------------------------------------------------- /src/helpers/cleanTitle.ts: -------------------------------------------------------------------------------- 1 | export default function cleanTitle(title) { 2 | const braketsRegex = /\[[^)]*\]/ 3 | let forbidenTerms = ['(full album)', '(official ep)', '(official video)', '(video official)', '(radio edit)','(DEEP MEDi Musik)', '(Original Mix)', '(Official Music Video)'] 4 | title = title.replace(braketsRegex, '') 5 | forbidenTerms.forEach(forbidenTerm => { 6 | title = title.replace(new RegExp(forbidenTerm, 'ig'), '') 7 | title = title.replace('()', '') 8 | title = title.replace(/\[(.*)\]/, '') 9 | }) 10 | return title 11 | } 12 | -------------------------------------------------------------------------------- /src/helpers/decodeHex.ts: -------------------------------------------------------------------------------- 1 | export default function decodeHex(hex) { 2 | return hex.replace(/\\x22/g, '"').replace(/\\x7b/g, '{').replace(/\\x7d/g, '}').replace(/\\x5b/g, '[').replace(/\\x5d/g, ']').replace(/\\x3b/g, ';').replace(/\\x3d/g, '=').replace(/\\x27/g, '\'').replace(/\\\\/g, 'doubleAntiSlash').replace(/\\/g, '').replace(/doubleAntiSlash/g, '\\') 3 | } 4 | -------------------------------------------------------------------------------- /src/helpers/findVal.ts: -------------------------------------------------------------------------------- 1 | export default function findVal(object, key) { 2 | var value 3 | Object.keys(object).some(function (k) { 4 | if (k === key) { 5 | value = object[k] 6 | return true 7 | } 8 | if (object[k] && typeof object[k] === 'object') { 9 | value = findVal(object[k], key) 10 | return value !== undefined 11 | } 12 | }) 13 | return value 14 | } -------------------------------------------------------------------------------- /src/helpers/formatVideo.ts: -------------------------------------------------------------------------------- 1 | import getVideoDate from '../getVideoDate' 2 | import getDateFromText from './getDateFromText' 3 | 4 | export default async function formatVideo(video: any, speedDate: boolean = false) { 5 | try { 6 | // title formating 7 | video.original_title = video.title 8 | 9 | if (video.title.split('-').length === 1) { 10 | video.artist = '' 11 | } 12 | else { 13 | let splited = video.original_title.match(/([^,]*)-(.*)/) 14 | video.artist = splited[1] 15 | video.title = splited[2] 16 | } 17 | // Date formating 18 | let publishedAt: Date = new Date(Date.now()) 19 | if (speedDate) { 20 | publishedAt = getDateFromText(video.uploadDate) 21 | } 22 | else { 23 | publishedAt = await getVideoDate(video.id) 24 | } 25 | return { 26 | id: video.id, 27 | original_title: video.original_title.trim(), 28 | title: video.title.trim(), 29 | artist: video.artist.trim(), 30 | duration: video.duration, 31 | publishedAt: publishedAt, 32 | } 33 | } catch (e) { 34 | console.log('format video failed') 35 | console.log(e) 36 | } 37 | } 38 | -------------------------------------------------------------------------------- /src/helpers/formatYoutubeCount.ts: -------------------------------------------------------------------------------- 1 | export default function formatYoutubeCount(raw) { 2 | const isMill = raw?.includes('M') 3 | const isKilo = raw?.includes('k') 4 | let nbSubscriber = raw?.replace(/[^0-9,.]/g, '').replace(',', '.') 5 | if (isMill) { 6 | nbSubscriber *= 1000000 7 | } 8 | else if (isKilo) { 9 | nbSubscriber *= 1000 10 | } 11 | return parseInt(nbSubscriber) || 0 12 | } 13 | -------------------------------------------------------------------------------- /src/helpers/getData.ts: -------------------------------------------------------------------------------- 1 | import axios from 'axios' 2 | import decodeHex from './decodeHex' 3 | import findVal from './findVal' 4 | 5 | export default async function getData(urlstring: string) { 6 | const dataRegex = /var\ ytInitialData\ \=\ \'(.*)\'\;<\/script>/ 7 | const playerRegex = /var\ ytInitialPlayerResponse\ \=\ (.*)id\=\"player\"/s 8 | 9 | const dateRegex = /publishDate":"(.*)","ownerChannelName/ 10 | const apiRegex = /"innertubeApiKey":"(.*?)"/ 11 | let url = new URL(urlstring) 12 | let isAjax = false 13 | let isDate = false 14 | let isSubtitles = false 15 | let body 16 | if (url.searchParams.get('token')) { 17 | isAjax = true 18 | } 19 | if (url.searchParams.get('type') === 'date') { 20 | isDate = true 21 | } 22 | if (url.searchParams.get('type') === 'subtitles') { 23 | isSubtitles = true 24 | } 25 | let headers: any 26 | if (isAjax) { 27 | 28 | const data = { context: { client: { clientName: 'WEB', clientVersion: '2.20210401.08.00' } }, continuation: url.searchParams.get('token') } 29 | body = (await axios({ method: 'post', url: urlstring, data: data })).data 30 | 31 | return { items: findVal(body, 'continuationItems'), token: findVal(body, 'token') } 32 | } 33 | else { 34 | headers = { 35 | headers: { 36 | 'Access-Control-Allow-Origin' : '*', 37 | 'x-youtube-client-name': 1, 38 | 'x-youtube-client-version': '2.20200911.04.00', 39 | 'User-Agent': 'Mozilla/5.0 (Linux; Android 5.0; SM-G900P Build/LRX21T) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/67.0.3396.87 Mobile Safari/537.36', 40 | } 41 | } 42 | body = (await axios(urlstring, headers)).data 43 | if (isDate) { 44 | const raw = dateRegex.exec(body) ?.[1] || '{}' 45 | return raw 46 | } 47 | else { 48 | const raw = dataRegex.exec(body)?.[1] || '{}' 49 | const apikey = apiRegex.exec(body)[1] || '' 50 | 51 | let data = JSON.parse(decodeHex(raw)) 52 | // let fs = require('fs'); fs.writeFile('raw.json', decodeHex(raw), (e)=>{console.log(e)}) 53 | data.apikey = apikey 54 | return data 55 | } 56 | } 57 | } 58 | -------------------------------------------------------------------------------- /src/helpers/getDateFromText.ts: -------------------------------------------------------------------------------- 1 | export default function getDateFromText(dateTxt: string) { 2 | const unit = { 3 | second: { 4 | terms: ['sec', 'Sekun', 'segun'], 5 | factor: 1, 6 | }, 7 | minute: { 8 | terms: ['min'], 9 | factor: 1000*60, 10 | }, 11 | hour: { 12 | terms: ['hour', 'heure', 'uur'], 13 | factor: 1000*60*60, 14 | }, 15 | day: { 16 | terms: ['jour', 'day', 'gio', 'dag', 'tag', 'day'], 17 | factor: 1000*60*60*24, 18 | }, 19 | week: { 20 | terms: ['sem', 'week', 'setti', 'woche'], 21 | factor: 1000*60*60*24*7, 22 | }, 23 | month: { 24 | terms: ['mo'], 25 | factor: 1000*60*60*24*7*4, 26 | }, 27 | year: { 28 | terms: ['an', 'year', 'ja'], 29 | factor: 1000*60*60*24*7*4*12, 30 | }, 31 | } 32 | const digit = parseInt(dateTxt.replace(/\D/g,'')) || 0 33 | 34 | if (!dateTxt || digit === 0) { 35 | return new Date(Date.now()) 36 | } 37 | 38 | for(let i in unit) { 39 | for(let y in unit[i].terms) { 40 | if (dateTxt.includes(unit[i].terms[y])) { 41 | const secondsSince = unit[i].factor * digit 42 | return new Date(Date.now() - secondsSince) 43 | } 44 | } 45 | } 46 | return new Date(Date.now()) 47 | } 48 | -------------------------------------------------------------------------------- /src/helpers/wait.ts: -------------------------------------------------------------------------------- 1 | export default function wait() { 2 | let ms = Math.floor(Math.random() * 300) 3 | let start = new Date().getTime() 4 | let end = start 5 | while(end < start + ms) { 6 | end = new Date().getTime() 7 | } 8 | } 9 | -------------------------------------------------------------------------------- /src/searchChannel.ts: -------------------------------------------------------------------------------- 1 | import Channel from './types/channel' 2 | import { Client } from 'youtubei' 3 | import formatYoutubeCount from './helpers/formatYoutubeCount' 4 | 5 | export default async function searchChannel(terms: string, token?: number, apikey?: string) { 6 | try { 7 | const youtube = new Client() 8 | const data = await youtube.search(terms, { type: 'channel' }) 9 | 10 | let items: any = [] 11 | let channels: Channel[] = [] 12 | let didyoumean: string = '' 13 | 14 | if(token) { 15 | for(let i = 0; i < token; i++ ) { 16 | data.next() 17 | } 18 | } 19 | 20 | items = data.items 21 | 22 | items.map(item => { 23 | const avatarId = item.thumbnails[0].url.replace('//yt3.ggpht.com/', '') 24 | const nbSubscriber: number = formatYoutubeCount(item.subscriberCount || '0') 25 | channels.push({ 26 | name: item.name, 27 | channel_id: item.subscriberCount, 28 | nb_videos: item.videoCount, 29 | nb_subscriber: nbSubscriber, 30 | official: false, 31 | channel_avatar_small: 'https://yt3.ggpht.com/'+avatarId.replace('=s88','=s80'), 32 | channel_avatar_medium: 'https://yt3.ggpht.com/'+avatarId.replace('=s88','=s200'), 33 | channel_avatar_large: 'https://yt3.ggpht.com/'+avatarId.replace('=s88','=s800'), 34 | }) 35 | }) 36 | return { 37 | channels: channels, 38 | didyoumean: didyoumean, 39 | token: token, 40 | apikey: apikey, 41 | } 42 | } catch(e) { 43 | console.log('search channel error, terms: '+terms) 44 | // console.log(e) 45 | } 46 | } 47 | -------------------------------------------------------------------------------- /src/searchVideo.ts: -------------------------------------------------------------------------------- 1 | import Video from './types/video' 2 | import { Client } from 'youtubei' 3 | import formatVideo from './helpers/formatVideo' 4 | import { CancelToken } from 'axios' 5 | 6 | export default async function searchVideo(terms: string, token?: number, apikey?: string) { 7 | try { 8 | const youtube = new Client() 9 | const data = await youtube.search(terms, { type: 'video' }) 10 | 11 | let items: any = [] 12 | let videos: Video[] = [] 13 | let didyoumean: string = '' 14 | 15 | if(token) { 16 | for(let i = 0; i < token; i++ ) { 17 | data.next() 18 | } 19 | } 20 | 21 | items = data.items 22 | 23 | for(let i = 0; i < items.length; i++) { 24 | let formated: Video = await formatVideo(items[i], true) 25 | if (formated) { 26 | if (formated.id === 'didyoumean') { 27 | didyoumean = formated.title 28 | } 29 | else { 30 | videos.push(formated) 31 | } 32 | } 33 | } 34 | return { 35 | videos: videos, 36 | didyoumean: didyoumean, 37 | token: apikey, 38 | apikey: apikey, 39 | } 40 | } catch(e) { 41 | console.log('search videos error, terms: '+terms) 42 | // console.log(e) 43 | } 44 | } 45 | -------------------------------------------------------------------------------- /src/types/channel.d.ts: -------------------------------------------------------------------------------- 1 | export default interface Channel { 2 | name: string, 3 | channel_id: string, 4 | nb_videos: number, 5 | nb_subscriber: number, 6 | official: boolean, 7 | channel_avatar_small: string, 8 | channel_avatar_medium: string, 9 | channel_avatar_large: string, 10 | } 11 | -------------------------------------------------------------------------------- /src/types/searchResult.d.ts: -------------------------------------------------------------------------------- 1 | import Video from './video' 2 | 3 | export default interface SearchResult { 4 | videos: Video[], 5 | didyoumean: string, // spelling proposal 6 | token: string, // number of call to next page 7 | apikey: string, // api key to get more data (next/prev page result) 8 | } 9 | -------------------------------------------------------------------------------- /src/types/video.d.ts: -------------------------------------------------------------------------------- 1 | export default interface Video { 2 | id: string, 3 | original_title: string, 4 | title: string, 5 | artist: string, 6 | duration: number, 7 | publishedAt: Date, 8 | } 9 | -------------------------------------------------------------------------------- /src/usetube.ts: -------------------------------------------------------------------------------- 1 | import getChannelDesc from './getChannelDesc' 2 | import getChannelVideos from './getChannelVideos' 3 | import getPlaylistVideos from './getPlaylistVideos' 4 | import getVideoDate from './getVideoDate' 5 | import getVideoDesc from './getVideoDesc' 6 | import getVideosFromDesc from './getVideosFromDesc' 7 | import searchChannel from './searchChannel' 8 | import searchVideo from './searchVideo' 9 | 10 | export { 11 | getChannelDesc, 12 | getChannelVideos, 13 | getPlaylistVideos, 14 | getVideoDate, 15 | getVideoDesc, 16 | getVideosFromDesc, 17 | searchChannel, 18 | searchVideo, 19 | } 20 | -------------------------------------------------------------------------------- /test.js: -------------------------------------------------------------------------------- 1 | const usetube = require('./dist/usetube.js') 2 | let test 3 | 4 | let launchTest = async function() { 5 | // test = await usetube.getChannelVideos('noisia', new Date(Date.now() - 7*24*60*60*1000)) 6 | test = await usetube.getChannelVideos('noisia') // 30 videos 7 | // test = await usetube.getVideoDesc('7meUp9JAQyw') 8 | // test = await usetube.getChannelDesc('UCp5KUL1Mb7Kpfw10SGyPumQ') 9 | // test = await usetube.searchChannel('vision radio') 10 | // test = await usetube.searchChannel('noisia', 'EtoGEhBsYXRlIG5pZ2h0IHRhbGVzGtgFRWdJUUFrZ1VnZ0VZVlVORGJYZFRkbWM0UkdwSGMwZ3lVek5oYzFFM1JUQlJnZ0VZVlVOcFEwbzJUa0k0YjNWU2EyeDROWFkxVG1KNWRFcEJnZ0VZVlVOaGVHSXlWRTFuU2tKVVFqSk1SMk5yYlY4MllVRlJnZ0VZVlVOeExXZzJMVEJPYVhWUGIxQlRVaTEzY1ZSV09FVjNnZ0VZVlVOcWJEUXhjMWRqZFVkMVpHNHlkalpwWVMxUWRsSjNnZ0VZVlVNMlFVNXNlVVJVY21WMVMydFpUVzlCY0hnd1NUQm5nZ0VZVlVOMlJFdHlUbHBMYkZsNlMweERNMkZoV1RocFluaG5nZ0VZVlVORVowaEhSMVZMUWtRMVpITkJUM2h2TUcxcE5ITlJnZ0VZVlVOM2NGcGhhakZEWDJkc2RHbFlRMVZNY1d0SVYxUm5nZ0VZVlVOVVZqZFBiV1pqVlZnNGFYWndVbWQyYzA1WVFsbEJnZ0VZVlVOR0xYTXRjVFpqZDBOV1IwZHdjazR5TFRsNExVRm5nZ0VZVlVOWU1FSnVlR2RVTms1R2VWWnphRlZCUzJsSE1VSm5nZ0VZVlVOVVlrVkJNRWRtYjJaeVJXMUlOMVZWTWtsSGN6bFJnZ0VZVlVOc1l6VktjalZIZVVadlVTMW9hemh5TURWMlNEbG5nZ0VZVlVOSVdHdFVibXR6V1haT2VXUnRSbFJtWW01eFR6Tm5nZ0VZVlVObmJYQnlYek5IYjJ0dmRUZG9ZbXROUmxNdFNHWlJnZ0VZVlVOd1NEZFRaMHBUZDFSU1ozVnZiemRDZDBvd01HRjNnZ0VZVlVOQ1VuVXhXalp0YkdObVFuSlVjVEZqY0VsTE1sQjNnZ0VZVlVOeFgweE9WMkZ3YTB4dE9FNXRTVlJRYlRoTlNYUm5nZ0VZVlVOd1VsSmpNa2xDTkUxQ1VXWXlhSEJLVmtkMlVrWkLKAWoaFWh0dHBzOi8vbS55b3V0dWJlLmNvbSIAKk9odHRwczovL20ueW91dHViZS5jb20vcmVzdWx0cz9zZWFyY2hfcXVlcnk9bGF0ZStuaWdodCt0YWxlcyZzcD1FZ0lRQWclMjUzRCUyNTNEGIHg6BgiC3NlYXJjaC1mZWVk', 'AIzaSyAO_FJ2SlqU8Q4STEHLGCilw_Y9_11qcW8') 11 | // test = await usetube.searchVideo('noisia') 12 | // test = await usetube.searchVideo('Lorn','EpUEEgRMb3JuGqgDU0JTQ0FRdERjV0ZCYzE4ellYcFRjNElCQzIxaGRWWXlUbVJEY3pZd2dnRUxkVGRqTWxaTVJ6VlVkR09DQVF0MU9XY3dWUzFOTWsxalVZSUJDM1JSTUdaeFlubFZiRXAzZ2dFTFZIcDZjbnBIZVV0dk5tZUNBUXRsVkZsSloyVTRaRWhZVVlJQkdGVkRlR1ZpYTA4MFQwcDRhak56VlZkS2FqUmtTREYxWjRJQkMyTmxZblV3U20xamJGVlJnZ0VMZEdSTFFrNVVOalF4VmppQ0FRdFZSVUpKYzFWemRtaGxRWUlCQzBseFNsQkRSRGxUYlhZNGdnRUxZVEZrTUZCV1JqTXhaVkdDQVF0WlRsQlFaR3Q0UlRkVE1JSUJDMmhHVXpKRVYyZHBhbWcwZ2dFTFUwZ3RiemRsWkdoeGMzT0NBU0pRVEdKMVNIRnNiRWh4WVVsSmJqTndNV05LZVRRMVRVUlpOakpsVEc1M2NYUXdnZ0VMVVUxUmFVMXZjMFl4UWpDQ0FRdE9WRWR3U2t0a1kwTktiNElCQzFsdldraHhlV3RTTURScsoBYQgEGhVodHRwczovL20ueW91dHViZS5jb20iACpEaHR0cHM6Ly9tLnlvdXR1YmUuY29tL3Jlc3VsdHM_dmlkZW9FbWJlZGRhYmxlPXRydWUmc2VhcmNoX3F1ZXJ5PUxvcm4YgeDoGCILc2VhcmNoLWZlZWQ%3D','AIzaSyAO_FJ2SlqU8Q4STEHLGCilw_Y9_11qcW8') 13 | // test = await usetube.getVideoDate('i0Q0HIpvkhU') 14 | // test = await usetube.getPlaylistVideos('PLhrglt2nmIGgQdb_L8Ri5bOfBr86qZZgq') // 21 videos 15 | // test = await usetube.getPlaylistVideos('PL4cUxeGkcC9gZD-Tvwfod2gaISzfRiP9d') // 21 videos 16 | // test = await usetube.getPlaylistVideos('PLiNVoBckLqLnEPv9c7QVk_ctJjaaOK-Q0') 17 | // test = await usetube.getPlaylistVideos('Igq3d6XA75Y&list=PL4dX1IHww9p1D3ZzW8J2fX6q1FP5av2No') // 6 videos 18 | // test = await usetube.getVideosFromDesc('u5G6BFYYw20') // 18 videos 19 | if (test) { 20 | console.log(test) 21 | if (test.length) { 22 | console.log(test.length+' result(s)') 23 | } 24 | } 25 | } 26 | 27 | launchTest() 28 | -------------------------------------------------------------------------------- /tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "declaration": true, 3 | "compilerOptions": { 4 | "outDir": "./dist", 5 | "rootDirs": ["./src"], 6 | "sourceMap": true, 7 | "module": "commonjs", 8 | "esModuleInterop": false, 9 | "target": "es5", 10 | "lib": ["es5", "es2015.promise", "DOM", "ScriptHost"], 11 | "moduleResolution": "node" 12 | }, 13 | "include": ["src/**/*"], 14 | "exclude": [ 15 | "node_modules", 16 | "./dist", 17 | "./test" 18 | ] 19 | } 20 | -------------------------------------------------------------------------------- /yarn.lock: -------------------------------------------------------------------------------- 1 | # THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY. 2 | # yarn lockfile v1 3 | 4 | 5 | "@types/node@^14.14.7": 6 | "integrity" "sha512-vQAnaReSQkEDa8uwAyQby8bYGKu84R/deEc6mg5T8fX6gzCn8QW6rziSgsti1fNvsrswKUKPnVTi7uoB+u62Mw==" 7 | "resolved" "https://registry.npmjs.org/@types/node/-/node-14.18.31.tgz" 8 | "version" "14.18.31" 9 | 10 | "axios@^0.21.1": 11 | "integrity" "sha512-ut5vewkiu8jjGBdqpM44XxjuCjq9LAKeHVmoVfHVzy8eHgxxq8SbAVQNovDA8mVi05kP0Ea/n/UzcSHcTJQfNg==" 12 | "resolved" "https://registry.npmjs.org/axios/-/axios-0.21.4.tgz" 13 | "version" "0.21.4" 14 | dependencies: 15 | "follow-redirects" "^1.14.0" 16 | 17 | "b4a@^1.6.0": 18 | "integrity" "sha512-aX6/FqpWQve8VN9kyTExy7GlmwNShvxcCWWD5QVR3ZbRlyBGtCrG5Autu95xxSPH4CRs+5PSV4d7PRnWpmqFlA==" 19 | "resolved" "https://registry.npmjs.org/b4a/-/b4a-1.6.3.tgz" 20 | "version" "1.6.3" 21 | 22 | "dayjs@^1.11.7": 23 | "integrity" "sha512-+Yw9U6YO5TQohxLcIkrXBeY73WP3ejHWVvx8XCk3gxvQDCTEmS48ZrSZCKciI7Bhl/uCMyxYtE9UqRILmFphkQ==" 24 | "resolved" "https://registry.npmjs.org/dayjs/-/dayjs-1.11.7.tgz" 25 | "version" "1.11.7" 26 | 27 | "follow-redirects@^1.14.0": 28 | "integrity" "sha512-VQLG33o04KaQ8uYi2tVNbdrWp1QWxNNea+nmIB4EVM28v0hmP17z7aG1+wAkNzVq4KeXTq3221ye5qTJP91JwA==" 29 | "resolved" "https://registry.npmjs.org/follow-redirects/-/follow-redirects-1.15.2.tgz" 30 | "version" "1.15.2" 31 | 32 | "generate-function@^2.0.0": 33 | "integrity" "sha512-eeB5GfMNeevm/GRYq20ShmsaGcmI81kIX2K9XQx5miC8KdHaC6Jm0qQ8ZNeGOi7wYB8OsdxKs+Y2oVuTFuVwKQ==" 34 | "resolved" "https://registry.npmjs.org/generate-function/-/generate-function-2.3.1.tgz" 35 | "version" "2.3.1" 36 | dependencies: 37 | "is-property" "^1.0.2" 38 | 39 | "generate-object-property@^1.2.0": 40 | "integrity" "sha512-TuOwZWgJ2VAMEGJvAyPWvpqxSANF0LDpmyHauMjFYzaACvn+QTT/AZomvPCzVBV7yDN3OmwHQ5OvHaeLKre3JQ==" 41 | "resolved" "https://registry.npmjs.org/generate-object-property/-/generate-object-property-1.2.0.tgz" 42 | "version" "1.2.0" 43 | dependencies: 44 | "is-property" "^1.0.0" 45 | 46 | "is-property@^1.0.0", "is-property@^1.0.2": 47 | "integrity" "sha512-Ks/IoX00TtClbGQr4TWXemAnktAQvYB7HzcCxDGqEZU6oCmb2INHuOoKxbtR+HFkmYWBKv/dOZtGRiAjDhj92g==" 48 | "resolved" "https://registry.npmjs.org/is-property/-/is-property-1.0.2.tgz" 49 | "version" "1.0.2" 50 | 51 | "node-fetch@2.6.7": 52 | "integrity" "sha512-ZjMPFEfVx5j+y2yF35Kzx5sF7kDzxuDj6ziH4FFbOp87zKDZNx8yExJIb05OGF4Nlt9IHFIMBkRl41VdvcNdbQ==" 53 | "resolved" "https://registry.npmjs.org/node-fetch/-/node-fetch-2.6.7.tgz" 54 | "version" "2.6.7" 55 | dependencies: 56 | "whatwg-url" "^5.0.0" 57 | 58 | "protocol-buffers-encodings@^1.1.0": 59 | "integrity" "sha512-daeNPuKh1NlLD1uDfbLpD+xyUTc07nEtfHwmBZmt/vH0B7VOM+JOCOpDcx9ZRpqHjAiIkGqyTDi+wfGSl17R9w==" 60 | "resolved" "https://registry.npmjs.org/protocol-buffers-encodings/-/protocol-buffers-encodings-1.2.0.tgz" 61 | "version" "1.2.0" 62 | dependencies: 63 | "b4a" "^1.6.0" 64 | "signed-varint" "^2.0.1" 65 | "varint" "5.0.0" 66 | 67 | "protocol-buffers-schema@^3.1.1": 68 | "integrity" "sha512-TdDRD+/QNdrCGCE7v8340QyuXd4kIWIgapsE2+n/SaGiSSbomYl4TjHlvIoCWRpE7wFt02EpB35VVA2ImcBVqw==" 69 | "resolved" "https://registry.npmjs.org/protocol-buffers-schema/-/protocol-buffers-schema-3.6.0.tgz" 70 | "version" "3.6.0" 71 | 72 | "protocol-buffers@5.0.0": 73 | "integrity" "sha512-ceZAqqc5tKmsy4VXjQpCUbw9CJWHY+wIJitciBB9wyFXmcma8124Ck6LYwKncZgUzTkyCa+IyDrphI8s8DIWbA==" 74 | "resolved" "https://registry.npmjs.org/protocol-buffers/-/protocol-buffers-5.0.0.tgz" 75 | "version" "5.0.0" 76 | dependencies: 77 | "generate-function" "^2.0.0" 78 | "generate-object-property" "^1.2.0" 79 | "protocol-buffers-encodings" "^1.1.0" 80 | "protocol-buffers-schema" "^3.1.1" 81 | "signed-varint" "^2.0.0" 82 | "varint" "^6.0.0" 83 | 84 | "signed-varint@^2.0.0", "signed-varint@^2.0.1": 85 | "integrity" "sha512-abgDPg1106vuZZOvw7cFwdCABddfJRz5akcCcchzTbhyhYnsG31y4AlZEgp315T7W3nQq5P4xeOm186ZiPVFzw==" 86 | "resolved" "https://registry.npmjs.org/signed-varint/-/signed-varint-2.0.1.tgz" 87 | "version" "2.0.1" 88 | dependencies: 89 | "varint" "~5.0.0" 90 | 91 | "tr46@~0.0.3": 92 | "integrity" "sha512-N3WMsuqV66lT30CrXNbEjx4GEwlow3v6rr4mCcv6prnfwhS01rkgyFdjPNBYd9br7LpXV1+Emh01fHnq2Gdgrw==" 93 | "resolved" "https://registry.npmjs.org/tr46/-/tr46-0.0.3.tgz" 94 | "version" "0.0.3" 95 | 96 | "typescript@^4.0.3": 97 | "integrity" "sha512-QCh+85mCy+h0IGff8r5XWzOVSbBO+KfeYrMQh7NJ58QujwcE22u+NUSmUxqF+un70P9GXKxa2HCNiTTMJknyjQ==" 98 | "resolved" "https://registry.npmjs.org/typescript/-/typescript-4.8.4.tgz" 99 | "version" "4.8.4" 100 | 101 | "varint@^6.0.0": 102 | "integrity" "sha512-cXEIW6cfr15lFv563k4GuVuW/fiwjknytD37jIOLSdSWuOI6WnO/oKwmP2FQTU2l01LP8/M5TSAJpzUaGe3uWg==" 103 | "resolved" "https://registry.npmjs.org/varint/-/varint-6.0.0.tgz" 104 | "version" "6.0.0" 105 | 106 | "varint@~5.0.0": 107 | "integrity" "sha512-lKxKYG6H03yCZUpAGOPOsMcGxd1RHCu1iKvEHYDPmTyq2HueGhD73ssNBqqQWfvYs04G9iUFRvmAVLW20Jw6ow==" 108 | "resolved" "https://registry.npmjs.org/varint/-/varint-5.0.2.tgz" 109 | "version" "5.0.2" 110 | 111 | "varint@5.0.0": 112 | "integrity" "sha512-gC13b/bWrqQoKY2EmROCZ+AR0jitc6DnDGaQ6Ls9QpKmuSgJB1eQ7H3KETtQm7qSdMWMKCmsshyCmUwMLh3OAA==" 113 | "resolved" "https://registry.npmjs.org/varint/-/varint-5.0.0.tgz" 114 | "version" "5.0.0" 115 | 116 | "webidl-conversions@^3.0.0": 117 | "integrity" "sha512-2JAn3z8AR6rjK8Sm8orRC0h/bcl/DqL7tRPdGZ4I1CjdF+EaMLmYxBHyXuKL849eucPFhvBoxMsflfOb8kxaeQ==" 118 | "resolved" "https://registry.npmjs.org/webidl-conversions/-/webidl-conversions-3.0.1.tgz" 119 | "version" "3.0.1" 120 | 121 | "whatwg-url@^5.0.0": 122 | "integrity" "sha512-saE57nupxk6v3HY35+jzBwYa0rKSy0XR8JSxZPwgLr7ys0IBzhGviA1/TUGJLmSVqs8pb9AnvICXEuOHLprYTw==" 123 | "resolved" "https://registry.npmjs.org/whatwg-url/-/whatwg-url-5.0.0.tgz" 124 | "version" "5.0.0" 125 | dependencies: 126 | "tr46" "~0.0.3" 127 | "webidl-conversions" "^3.0.0" 128 | 129 | "youtubei@^1.1.2": 130 | "integrity" "sha512-aYwJvMBswenT2MNg9vl/Mvvl3jRx3INmQHEaill2QJSqZU+0ikmP8fWbvfLBvcJNcKCGbzMPndlQqsI/2JyXJw==" 131 | "resolved" "https://registry.npmjs.org/youtubei/-/youtubei-1.1.2.tgz" 132 | "version" "1.1.2" 133 | dependencies: 134 | "node-fetch" "2.6.7" 135 | "protocol-buffers" "5.0.0" 136 | --------------------------------------------------------------------------------