youpipe: replace newpipeextractor
- Commit
d4b5fd163945729291eb1f08d4bf1a0c70123c37- Author
- Vayun Mathur <[email protected]>
- When
- 2026-07-22 18:28 UTC (4 months ago)
- Parents
2f12a2a
Diff
youpipe/build.gradle.kts
diff --git a/youpipe/build.gradle.kts b/youpipe/build.gradle.ktsindex 996370329e..6871e86510 100644--- a/youpipe/build.gradle.kts+++ b/youpipe/build.gradle.kts@@ -25,7 +25,7 @@ android { dependencies { implementation(libs.coil.compose)- implementation(libs.newpipeextractor)+ implementation(project(":youpipe:extractor")) implementRoom(libs) implementation(project(":library:room"))
youpipe/extractor/LICENSE
diff --git a/youpipe/extractor/LICENSE b/youpipe/extractor/LICENSEnew file mode 100644index 0000000000..f288702d2f--- /dev/null+++ b/youpipe/extractor/LICENSE@@ -0,0 +1,674 @@+ GNU GENERAL PUBLIC LICENSE+ Version 3, 29 June 2007++ Copyright (C) 2007 Free Software Foundation, Inc. <https://fsf.org/>+ Everyone is permitted to copy and distribute verbatim copies+ of this license document, but changing it is not allowed.++ Preamble++ The GNU General Public License is a free, copyleft license for+software and other kinds of works.++ The licenses for most software and other practical works are designed+to take away your freedom to share and change the works. By contrast,+the GNU General Public License is intended to guarantee your freedom to+share and change all versions of a program--to make sure it remains free+software for all its users. We, the Free Software Foundation, use the+GNU General Public License for most of our software; it applies also to+any other work released this way by its authors. You can apply it to+your programs, too.++ When we speak of free software, we are referring to freedom, not+price. Our General Public Licenses are designed to make sure that you+have the freedom to distribute copies of free software (and charge for+them if you wish), that you receive source code or can get it if you+want it, that you can change the software or use pieces of it in new+free programs, and that you know you can do these things.++ To protect your rights, we need to prevent others from denying you+these rights or asking you to surrender the rights. Therefore, you have+certain responsibilities if you distribute copies of the software, or if+you modify it: responsibilities to respect the freedom of others.++ For example, if you distribute copies of such a program, whether+gratis or for a fee, you must pass on to the recipients the same+freedoms that you received. You must make sure that they, too, receive+or can get the source code. And you must show them these terms so they+know their rights.++ Developers that use the GNU GPL protect your rights with two steps:+(1) assert copyright on the software, and (2) offer you this License+giving you legal permission to copy, distribute and/or modify it.++ For the developers' and authors' protection, the GPL clearly explains+that there is no warranty for this free software. For both users' and+authors' sake, the GPL requires that modified versions be marked as+changed, so that their problems will not be attributed erroneously to+authors of previous versions.++ Some devices are designed to deny users access to install or run+modified versions of the software inside them, although the manufacturer+can do so. This is fundamentally incompatible with the aim of+protecting users' freedom to change the software. The systematic+pattern of such abuse occurs in the area of products for individuals to+use, which is precisely where it is most unacceptable. Therefore, we+have designed this version of the GPL to prohibit the practice for those+products. If such problems arise substantially in other domains, we+stand ready to extend this provision to those domains in future versions+of the GPL, as needed to protect the freedom of users.++ Finally, every program is threatened constantly by software patents.+States should not allow patents to restrict development and use of+software on general-purpose computers, but in those that do, we wish to+avoid the special danger that patents applied to a free program could+make it effectively proprietary. To prevent this, the GPL assures that+patents cannot be used to render the program non-free.++ The precise terms and conditions for copying, distribution and+modification follow.++ TERMS AND CONDITIONS++ 0. Definitions.++ "This License" refers to version 3 of the GNU General Public License.++ "Copyright" also means copyright-like laws that apply to other kinds of+works, such as semiconductor masks.++ "The Program" refers to any copyrightable work licensed under this+License. Each licensee is addressed as "you". "Licensees" and+"recipients" may be individuals or organizations.++ To "modify" a work means to copy from or adapt all or part of the work+in a fashion requiring copyright permission, other than the making of an+exact copy. The resulting work is called a "modified version" of the+earlier work or a work "based on" the earlier work.++ A "covered work" means either the unmodified Program or a work based+on the Program.++ To "propagate" a work means to do anything with it that, without+permission, would make you directly or secondarily liable for+infringement under applicable copyright law, except executing it on a+computer or modifying a private copy. Propagation includes copying,+distribution (with or without modification), making available to the+public, and in some countries other activities as well.++ To "convey" a work means any kind of propagation that enables other+parties to make or receive copies. Mere interaction with a user through+a computer network, with no transfer of a copy, is not conveying.++ An interactive user interface displays "Appropriate Legal Notices"+to the extent that it includes a convenient and prominently visible+feature that (1) displays an appropriate copyright notice, and (2)+tells the user that there is no warranty for the work (except to the+extent that warranties are provided), that licensees may convey the+work under this License, and how to view a copy of this License. If+the interface presents a list of user commands or options, such as a+menu, a prominent item in the list meets this criterion.++ 1. Source Code.++ The "source code" for a work means the preferred form of the work+for making modifications to it. "Object code" means any non-source+form of a work.++ A "Standard Interface" means an interface that either is an official+standard defined by a recognized standards body, or, in the case of+interfaces specified for a particular programming language, one that+is widely used among developers working in that language.++ The "System Libraries" of an executable work include anything, other+than the work as a whole, that (a) is included in the normal form of+packaging a Major Component, but which is not part of that Major+Component, and (b) serves only to enable use of the work with that+Major Component, or to implement a Standard Interface for which an+implementation is available to the public in source code form. A+"Major Component", in this context, means a major essential component+(kernel, window system, and so on) of the specific operating system+(if any) on which the executable work runs, or a compiler used to+produce the work, or an object code interpreter used to run it.++ The "Corresponding Source" for a work in object code form means all+the source code needed to generate, install, and (for an executable+work) run the object code and to modify the work, including scripts to+control those activities. However, it does not include the work's+System Libraries, or general-purpose tools or generally available free+programs which are used unmodified in performing those activities but+which are not part of the work. For example, Corresponding Source+includes interface definition files associated with source files for+the work, and the source code for shared libraries and dynamically+linked subprograms that the work is specifically designed to require,+such as by intimate data communication or control flow between those+subprograms and other parts of the work.++ The Corresponding Source need not include anything that users+can regenerate automatically from other parts of the Corresponding+Source.++ The Corresponding Source for a work in source code form is that+same work.++ 2. Basic Permissions.++ All rights granted under this License are granted for the term of+copyright on the Program, and are irrevocable provided the stated+conditions are met. This License explicitly affirms your unlimited+permission to run the unmodified Program. The output from running a+covered work is covered by this License only if the output, given its+content, constitutes a covered work. This License acknowledges your+rights of fair use or other equivalent, as provided by copyright law.++ You may make, run and propagate covered works that you do not+convey, without conditions so long as your license otherwise remains+in force. You may convey covered works to others for the sole purpose+of having them make modifications exclusively for you, or provide you+with facilities for running those works, provided that you comply with+the terms of this License in conveying all material for which you do+not control copyright. Those thus making or running the covered works+for you must do so exclusively on your behalf, under your direction+and control, on terms that prohibit them from making any copies of+your copyrighted material outside their relationship with you.++ Conveying under any other circumstances is permitted solely under+the conditions stated below. Sublicensing is not allowed; section 10+makes it unnecessary.++ 3. Protecting Users' Legal Rights From Anti-Circumvention Law.++ No covered work shall be deemed part of an effective technological+measure under any applicable law fulfilling obligations under article+11 of the WIPO copyright treaty adopted on 20 December 1996, or+similar laws prohibiting or restricting circumvention of such+measures.++ When you convey a covered work, you waive any legal power to forbid+circumvention of technological measures to the extent such circumvention+is effected by exercising rights under this License with respect to+the covered work, and you disclaim any intention to limit operation or+modification of the work as a means of enforcing, against the work's+users, your or third parties' legal rights to forbid circumvention of+technological measures.++ 4. Conveying Verbatim Copies.++ You may convey verbatim copies of the Program's source code as you+receive it, in any medium, provided that you conspicuously and+appropriately publish on each copy an appropriate copyright notice;+keep intact all notices stating that this License and any+non-permissive terms added in accord with section 7 apply to the code;+keep intact all notices of the absence of any warranty; and give all+recipients a copy of this License along with the Program.++ You may charge any price or no price for each copy that you convey,+and you may offer support or warranty protection for a fee.++ 5. Conveying Modified Source Versions.++ You may convey a work based on the Program, or the modifications to+produce it from the Program, in the form of source code under the+terms of section 4, provided that you also meet all of these conditions:++ a) The work must carry prominent notices stating that you modified+ it, and giving a relevant date.++ b) The work must carry prominent notices stating that it is+ released under this License and any conditions added under section+ 7. This requirement modifies the requirement in section 4 to+ "keep intact all notices".++ c) You must license the entire work, as a whole, under this+ License to anyone who comes into possession of a copy. This+ License will therefore apply, along with any applicable section 7+ additional terms, to the whole of the work, and all its parts,+ regardless of how they are packaged. This License gives no+ permission to license the work in any other way, but it does not+ invalidate such permission if you have separately received it.++ d) If the work has interactive user interfaces, each must display+ Appropriate Legal Notices; however, if the Program has interactive+ interfaces that do not display Appropriate Legal Notices, your+ work need not make them do so.++ A compilation of a covered work with other separate and independent+works, which are not by their nature extensions of the covered work,+and which are not combined with it such as to form a larger program,+in or on a volume of a storage or distribution medium, is called an+"aggregate" if the compilation and its resulting copyright are not+used to limit the access or legal rights of the compilation's users+beyond what the individual works permit. Inclusion of a covered work+in an aggregate does not cause this License to apply to the other+parts of the aggregate.++ 6. Conveying Non-Source Forms.++ You may convey a covered work in object code form under the terms+of sections 4 and 5, provided that you also convey the+machine-readable Corresponding Source under the terms of this License,+in one of these ways:++ a) Convey the object code in, or embodied in, a physical product+ (including a physical distribution medium), accompanied by the+ Corresponding Source fixed on a durable physical medium+ customarily used for software interchange.++ b) Convey the object code in, or embodied in, a physical product+ (including a physical distribution medium), accompanied by a+ written offer, valid for at least three years and valid for as+ long as you offer spare parts or customer support for that product+ model, to give anyone who possesses the object code either (1) a+ copy of the Corresponding Source for all the software in the+ product that is covered by this License, on a durable physical+ medium customarily used for software interchange, for a price no+ more than your reasonable cost of physically performing this+ conveying of source, or (2) access to copy the+ Corresponding Source from a network server at no charge.++ c) Convey individual copies of the object code with a copy of the+ written offer to provide the Corresponding Source. This+ alternative is allowed only occasionally and noncommercially, and+ only if you received the object code with such an offer, in accord+ with subsection 6b.++ d) Convey the object code by offering access from a designated+ place (gratis or for a charge), and offer equivalent access to the+ Corresponding Source in the same way through the same place at no+ further charge. You need not require recipients to copy the+ Corresponding Source along with the object code. If the place to+ copy the object code is a network server, the Corresponding Source+ may be on a different server (operated by you or a third party)+ that supports equivalent copying facilities, provided you maintain+ clear directions next to the object code saying where to find the+ Corresponding Source. Regardless of what server hosts the+ Corresponding Source, you remain obligated to ensure that it is+ available for as long as needed to satisfy these requirements.++ e) Convey the object code using peer-to-peer transmission, provided+ you inform other peers where the object code and Corresponding+ Source of the work are being offered to the general public at no+ charge under subsection 6d.++ A separable portion of the object code, whose source code is excluded+from the Corresponding Source as a System Library, need not be+included in conveying the object code work.++ A "User Product" is either (1) a "consumer product", which means any+tangible personal property which is normally used for personal, family,+or household purposes, or (2) anything designed or sold for incorporation+into a dwelling. In determining whether a product is a consumer product,+doubtful cases shall be resolved in favor of coverage. For a particular+product received by a particular user, "normally used" refers to a+typical or common use of that class of product, regardless of the status+of the particular user or of the way in which the particular user+actually uses, or expects or is expected to use, the product. A product+is a consumer product regardless of whether the product has substantial+commercial, industrial or non-consumer uses, unless such uses represent+the only significant mode of use of the product.++ "Installation Information" for a User Product means any methods,+procedures, authorization keys, or other information required to install+and execute modified versions of a covered work in that User Product from+a modified version of its Corresponding Source. The information must+suffice to ensure that the continued functioning of the modified object+code is in no case prevented or interfered with solely because+modification has been made.++ If you convey an object code work under this section in, or with, or+specifically for use in, a User Product, and the conveying occurs as+part of a transaction in which the right of possession and use of the+User Product is transferred to the recipient in perpetuity or for a+fixed term (regardless of how the transaction is characterized), the+Corresponding Source conveyed under this section must be accompanied+by the Installation Information. But this requirement does not apply+if neither you nor any third party retains the ability to install+modified object code on the User Product (for example, the work has+been installed in ROM).++ The requirement to provide Installation Information does not include a+requirement to continue to provide support service, warranty, or updates+for a work that has been modified or installed by the recipient, or for+the User Product in which it has been modified or installed. Access to a+network may be denied when the modification itself materially and+adversely affects the operation of the network or violates the rules and+protocols for communication across the network.++ Corresponding Source conveyed, and Installation Information provided,+in accord with this section must be in a format that is publicly+documented (and with an implementation available to the public in+source code form), and must require no special password or key for+unpacking, reading or copying.++ 7. Additional Terms.++ "Additional permissions" are terms that supplement the terms of this+License by making exceptions from one or more of its conditions.+Additional permissions that are applicable to the entire Program shall+be treated as though they were included in this License, to the extent+that they are valid under applicable law. If additional permissions+apply only to part of the Program, that part may be used separately+under those permissions, but the entire Program remains governed by+this License without regard to the additional permissions.++ When you convey a copy of a covered work, you may at your option+remove any additional permissions from that copy, or from any part of+it. (Additional permissions may be written to require their own+removal in certain cases when you modify the work.) You may place+additional permissions on material, added by you to a covered work,+for which you have or can give appropriate copyright permission.++ Notwithstanding any other provision of this License, for material you+add to a covered work, you may (if authorized by the copyright holders of+that material) supplement the terms of this License with terms:++ a) Disclaiming warranty or limiting liability differently from the+ terms of sections 15 and 16 of this License; or++ b) Requiring preservation of specified reasonable legal notices or+ author attributions in that material or in the Appropriate Legal+ Notices displayed by works containing it; or++ c) Prohibiting misrepresentation of the origin of that material, or+ requiring that modified versions of such material be marked in+ reasonable ways as different from the original version; or++ d) Limiting the use for publicity purposes of names of licensors or+ authors of the material; or++ e) Declining to grant rights under trademark law for use of some+ trade names, trademarks, or service marks; or++ f) Requiring indemnification of licensors and authors of that+ material by anyone who conveys the material (or modified versions of+ it) with contractual assumptions of liability to the recipient, for+ any liability that these contractual assumptions directly impose on+ those licensors and authors.++ All other non-permissive additional terms are considered "further+restrictions" within the meaning of section 10. If the Program as you+received it, or any part of it, contains a notice stating that it is+governed by this License along with a term that is a further+restriction, you may remove that term. If a license document contains+a further restriction but permits relicensing or conveying under this+License, you may add to a covered work material governed by the terms+of that license document, provided that the further restriction does+not survive such relicensing or conveying.++ If you add terms to a covered work in accord with this section, you+must place, in the relevant source files, a statement of the+additional terms that apply to those files, or a notice indicating+where to find the applicable terms.++ Additional terms, permissive or non-permissive, may be stated in the+form of a separately written license, or stated as exceptions;+the above requirements apply either way.++ 8. Termination.++ You may not propagate or modify a covered work except as expressly+provided under this License. Any attempt otherwise to propagate or+modify it is void, and will automatically terminate your rights under+this License (including any patent licenses granted under the third+paragraph of section 11).++ However, if you cease all violation of this License, then your+license from a particular copyright holder is reinstated (a)+provisionally, unless and until the copyright holder explicitly and+finally terminates your license, and (b) permanently, if the copyright+holder fails to notify you of the violation by some reasonable means+prior to 60 days after the cessation.++ Moreover, your license from a particular copyright holder is+reinstated permanently if the copyright holder notifies you of the+violation by some reasonable means, this is the first time you have+received notice of violation of this License (for any work) from that+copyright holder, and you cure the violation prior to 30 days after+your receipt of the notice.++ Termination of your rights under this section does not terminate the+licenses of parties who have received copies or rights from you under+this License. If your rights have been terminated and not permanently+reinstated, you do not qualify to receive new licenses for the same+material under section 10.++ 9. Acceptance Not Required for Having Copies.++ You are not required to accept this License in order to receive or+run a copy of the Program. Ancillary propagation of a covered work+occurring solely as a consequence of using peer-to-peer transmission+to receive a copy likewise does not require acceptance. However,+nothing other than this License grants you permission to propagate or+modify any covered work. These actions infringe copyright if you do+not accept this License. Therefore, by modifying or propagating a+covered work, you indicate your acceptance of this License to do so.++ 10. Automatic Licensing of Downstream Recipients.++ Each time you convey a covered work, the recipient automatically+receives a license from the original licensors, to run, modify and+propagate that work, subject to this License. You are not responsible+for enforcing compliance by third parties with this License.++ An "entity transaction" is a transaction transferring control of an+organization, or substantially all assets of one, or subdividing an+organization, or merging organizations. If propagation of a covered+work results from an entity transaction, each party to that+transaction who receives a copy of the work also receives whatever+licenses to the work the party's predecessor in interest had or could+give under the previous paragraph, plus a right to possession of the+Corresponding Source of the work from the predecessor in interest, if+the predecessor has it or can get it with reasonable efforts.++ You may not impose any further restrictions on the exercise of the+rights granted or affirmed under this License. For example, you may+not impose a license fee, royalty, or other charge for exercise of+rights granted under this License, and you may not initiate litigation+(including a cross-claim or counterclaim in a lawsuit) alleging that+any patent claim is infringed by making, using, selling, offering for+sale, or importing the Program or any portion of it.++ 11. Patents.++ A "contributor" is a copyright holder who authorizes use under this+License of the Program or a work on which the Program is based. The+work thus licensed is called the contributor's "contributor version".++ A contributor's "essential patent claims" are all patent claims+owned or controlled by the contributor, whether already acquired or+hereafter acquired, that would be infringed by some manner, permitted+by this License, of making, using, or selling its contributor version,+but do not include claims that would be infringed only as a+consequence of further modification of the contributor version. For+purposes of this definition, "control" includes the right to grant+patent sublicenses in a manner consistent with the requirements of+this License.++ Each contributor grants you a non-exclusive, worldwide, royalty-free+patent license under the contributor's essential patent claims, to+make, use, sell, offer for sale, import and otherwise run, modify and+propagate the contents of its contributor version.++ In the following three paragraphs, a "patent license" is any express+agreement or commitment, however denominated, not to enforce a patent+(such as an express permission to practice a patent or covenant not to+sue for patent infringement). To "grant" such a patent license to a+party means to make such an agreement or commitment not to enforce a+patent against the party.++ If you convey a covered work, knowingly relying on a patent license,+and the Corresponding Source of the work is not available for anyone+to copy, free of charge and under the terms of this License, through a+publicly available network server or other readily accessible means,+then you must either (1) cause the Corresponding Source to be so+available, or (2) arrange to deprive yourself of the benefit of the+patent license for this particular work, or (3) arrange, in a manner+consistent with the requirements of this License, to extend the patent+license to downstream recipients. "Knowingly relying" means you have+actual knowledge that, but for the patent license, your conveying the+covered work in a country, or your recipient's use of the covered work+in a country, would infringe one or more identifiable patents in that+country that you have reason to believe are valid.++ If, pursuant to or in connection with a single transaction or+arrangement, you convey, or propagate by procuring conveyance of, a+covered work, and grant a patent license to some of the parties+receiving the covered work authorizing them to use, propagate, modify+or convey a specific copy of the covered work, then the patent license+you grant is automatically extended to all recipients of the covered+work and works based on it.++ A patent license is "discriminatory" if it does not include within+the scope of its coverage, prohibits the exercise of, or is+conditioned on the non-exercise of one or more of the rights that are+specifically granted under this License. You may not convey a covered+work if you are a party to an arrangement with a third party that is+in the business of distributing software, under which you make payment+to the third party based on the extent of your activity of conveying+the work, and under which the third party grants, to any of the+parties who would receive the covered work from you, a discriminatory+patent license (a) in connection with copies of the covered work+conveyed by you (or copies made from those copies), or (b) primarily+for and in connection with specific products or compilations that+contain the covered work, unless you entered into that arrangement,+or that patent license was granted, prior to 28 March 2007.++ Nothing in this License shall be construed as excluding or limiting+any implied license or other defenses to infringement that may+otherwise be available to you under applicable patent law.++ 12. No Surrender of Others' Freedom.++ If conditions are imposed on you (whether by court order, agreement or+otherwise) that contradict the conditions of this License, they do not+excuse you from the conditions of this License. If you cannot convey a+covered work so as to satisfy simultaneously your obligations under this+License and any other pertinent obligations, then as a consequence you may+not convey it at all. For example, if you agree to terms that obligate you+to collect a royalty for further conveying from those to whom you convey+the Program, the only way you could satisfy both those terms and this+License would be to refrain entirely from conveying the Program.++ 13. Use with the GNU Affero General Public License.++ Notwithstanding any other provision of this License, you have+permission to link or combine any covered work with a work licensed+under version 3 of the GNU Affero General Public License into a single+combined work, and to convey the resulting work. The terms of this+License will continue to apply to the part which is the covered work,+but the special requirements of the GNU Affero General Public License,+section 13, concerning interaction through a network will apply to the+combination as such.++ 14. Revised Versions of this License.++ The Free Software Foundation may publish revised and/or new versions of+the GNU General Public License from time to time. Such new versions will+be similar in spirit to the present version, but may differ in detail to+address new problems or concerns.++ Each version is given a distinguishing version number. If the+Program specifies that a certain numbered version of the GNU General+Public License "or any later version" applies to it, you have the+option of following the terms and conditions either of that numbered+version or of any later version published by the Free Software+Foundation. If the Program does not specify a version number of the+GNU General Public License, you may choose any version ever published+by the Free Software Foundation.++ If the Program specifies that a proxy can decide which future+versions of the GNU General Public License can be used, that proxy's+public statement of acceptance of a version permanently authorizes you+to choose that version for the Program.++ Later license versions may give you additional or different+permissions. However, no additional obligations are imposed on any+author or copyright holder as a result of your choosing to follow a+later version.++ 15. Disclaimer of Warranty.++ THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY+APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT+HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY+OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO,+THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR+PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM+IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF+ALL NECESSARY SERVICING, REPAIR OR CORRECTION.++ 16. Limitation of Liability.++ IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING+WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS+THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY+GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE+USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF+DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD+PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS),+EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF+SUCH DAMAGES.++ 17. Interpretation of Sections 15 and 16.++ If the disclaimer of warranty and limitation of liability provided+above cannot be given local legal effect according to their terms,+reviewing courts shall apply local law that most closely approximates+an absolute waiver of all civil liability in connection with the+Program, unless a warranty or assumption of liability accompanies a+copy of the Program in return for a fee.++ END OF TERMS AND CONDITIONS++ How to Apply These Terms to Your New Programs++ If you develop a new program, and you want it to be of the greatest+possible use to the public, the best way to achieve this is to make it+free software which everyone can redistribute and change under these terms.++ To do so, attach the following notices to the program. It is safest+to attach them to the start of each source file to most effectively+state the exclusion of warranty; and each file should have at least+the "copyright" line and a pointer to where the full notice is found.++ <one line to give the program's name and a brief idea of what it does.>+ Copyright (C) <year> <name of author>++ This program is free software: you can redistribute it and/or modify+ it under the terms of the GNU General Public License as published by+ the Free Software Foundation, either version 3 of the License, or+ (at your option) any later version.++ This program is distributed in the hope that it will be useful,+ but WITHOUT ANY WARRANTY; without even the implied warranty of+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the+ GNU General Public License for more details.++ You should have received a copy of the GNU General Public License+ along with this program. If not, see <https://www.gnu.org/licenses/>.++Also add information on how to contact you by electronic and paper mail.++ If the program does terminal interaction, make it output a short+notice like this when it starts in an interactive mode:++ <program> Copyright (C) <year> <name of author>+ This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'.+ This is free software, and you are welcome to redistribute it+ under certain conditions; type `show c' for details.++The hypothetical commands `show w' and `show c' should show the appropriate+parts of the General Public License. Of course, your program's commands+might be different; for a GUI interface, you would use an "about box".++ You should also get your employer (if you work as a programmer) or school,+if any, to sign a "copyright disclaimer" for the program, if necessary.+For more information on this, and how to apply and follow the GNU GPL, see+<https://www.gnu.org/licenses/>.++ The GNU General Public License does not permit incorporating your program+into proprietary programs. If your program is a subroutine library, you+may consider it more useful to permit linking proprietary applications with+the library. If this is what you want to do, use the GNU Lesser General+Public License instead of this License. But first, please read+<https://www.gnu.org/licenses/why-not-lgpl.html>.
youpipe/extractor/build.gradle.kts
diff --git a/youpipe/extractor/build.gradle.kts b/youpipe/extractor/build.gradle.ktsnew file mode 100644index 0000000000..c365dd85df--- /dev/null+++ b/youpipe/extractor/build.gradle.kts@@ -0,0 +1,43 @@+import org.gradle.api.JavaVersion++plugins {+ `java-library`+ alias(libs.plugins.protobuf)+}++java {+ sourceCompatibility = JavaVersion.VERSION_17+ targetCompatibility = JavaVersion.VERSION_17+}++// Protobuf files would uselessly end up in the JAR otherwise, see+// https://github.com/google/protobuf-gradle-plugin/issues/390+tasks.jar {+ exclude("**/*.proto")+ includeEmptyDirs = false+}++dependencies {+ implementation(libs.newpipe.nanojson)+ implementation(libs.jsoup)+ implementation(libs.google.jsr305)+ implementation(libs.protobuf.javalite)+ implementation(libs.rhino)+ implementation(libs.rhino.engine)+}++protobuf {+ protoc {+ artifact = "com.google.protobuf:protoc:${libs.versions.protobufJavalite.get()}"+ }++ generateProtoTasks {+ all().forEach { task ->+ task.builtins {+ named("java") {+ option("lite")+ }+ }+ }+ }+}
youpipe/extractor/src/main/java/org/schabi/newpipe/extractor/Collector.java
diff --git a/youpipe/extractor/src/main/java/org/schabi/newpipe/extractor/Collector.java b/youpipe/extractor/src/main/java/org/schabi/newpipe/extractor/Collector.javanew file mode 100644index 0000000000..411058266b--- /dev/null+++ b/youpipe/extractor/src/main/java/org/schabi/newpipe/extractor/Collector.java@@ -0,0 +1,46 @@+package org.schabi.newpipe.extractor;++import org.schabi.newpipe.extractor.exceptions.ParsingException;++import java.util.List;++/**+ * Collectors are used to simplify the collection of information+ * from extractors+ * @param <I> the item type+ * @param <E> the extractor type+ */+public interface Collector<I, E> {++ /**+ * Try to add an extractor to the collection+ * @param extractor the extractor to add+ */+ void commit(E extractor);++ /**+ * Try to extract the item from an extractor without adding it to the collection+ * @param extractor the extractor to use+ * @return the item+ * @throws ParsingException thrown if there is an error extracting the+ * <b>required</b> fields of the item.+ */+ I extract(E extractor) throws ParsingException;++ /**+ * Get all items+ * @return the items+ */+ List<I> getItems();++ /**+ * Get all errors+ * @return the errors+ */+ List<Throwable> getErrors();++ /**+ * Reset all collected items and errors+ */+ void reset();+}
youpipe/extractor/src/main/java/org/schabi/newpipe/extractor/Extractor.java
diff --git a/youpipe/extractor/src/main/java/org/schabi/newpipe/extractor/Extractor.java b/youpipe/extractor/src/main/java/org/schabi/newpipe/extractor/Extractor.javanew file mode 100644index 0000000000..7d984e8338--- /dev/null+++ b/youpipe/extractor/src/main/java/org/schabi/newpipe/extractor/Extractor.java@@ -0,0 +1,164 @@+package org.schabi.newpipe.extractor;++import org.schabi.newpipe.extractor.downloader.Downloader;+import org.schabi.newpipe.extractor.exceptions.ExtractionException;+import org.schabi.newpipe.extractor.exceptions.ParsingException;+import org.schabi.newpipe.extractor.linkhandler.LinkHandler;+import org.schabi.newpipe.extractor.localization.ContentCountry;+import org.schabi.newpipe.extractor.localization.Localization;+import org.schabi.newpipe.extractor.localization.TimeAgoParser;+import org.schabi.newpipe.extractor.utils.ExtractorLogger;++import javax.annotation.Nonnull;+import javax.annotation.Nullable;++import java.io.IOException;+import java.util.Objects;++public abstract class Extractor {+ private final String TAG = getClass().getSimpleName() + "@" + hashCode();++ /**+ * {@link StreamingService} currently related to this extractor.<br>+ * Useful for getting other things from a service (like the url handlers for+ * cleaning/accepting/get id from urls).+ */+ private final StreamingService service;+ private final LinkHandler linkHandler;++ @Nullable+ private Localization forcedLocalization = null;+ @Nullable+ private ContentCountry forcedContentCountry = null;++ private boolean pageFetched = false;+ // called like this to prevent checkstyle errors about "hiding a field"+ private final Downloader downloader;++ protected Extractor(final StreamingService service, final LinkHandler linkHandler) {+ this.service = Objects.requireNonNull(service, "service is null");+ this.linkHandler = Objects.requireNonNull(linkHandler, "LinkHandler is null");+ this.downloader = Objects.requireNonNull(NewPipe.getDownloader(), "downloader is null");+ }++ /**+ * @return The {@link LinkHandler} of the current extractor object (e.g. a ChannelExtractor+ * should return a channel url handler).+ */+ @Nonnull+ public LinkHandler getLinkHandler() {+ return linkHandler;+ }++ /**+ * Fetch the current page.+ *+ * @throws IOException if the page can not be loaded+ * @throws ExtractionException if the pages content is not understood+ */+ public void fetchPage() throws IOException, ExtractionException {+ ExtractorLogger.d(TAG, "base fetchPage called");+ if (pageFetched) {+ ExtractorLogger.d(TAG, "Page already fetched; returning");+ return;+ }+ onFetchPage(downloader);+ pageFetched = true;+ }++ protected void assertPageFetched() {+ if (!pageFetched) {+ throw new IllegalStateException("Page is not fetched. Make sure you call fetchPage()");+ }+ }++ protected boolean isPageFetched() {+ return pageFetched;+ }++ /**+ * Fetch the current page.+ *+ * @param downloader the downloader to use+ * @throws IOException if the page can not be loaded+ * @throws ExtractionException if the pages content is not understood+ */+ @SuppressWarnings("HiddenField")+ public abstract void onFetchPage(@Nonnull Downloader downloader)+ throws IOException, ExtractionException;++ @Nonnull+ public String getId() throws ParsingException {+ return linkHandler.getId();+ }++ /**+ * Get the name+ *+ * @return the name+ * @throws ParsingException if the name cannot be extracted+ */+ @Nonnull+ public abstract String getName() throws ParsingException;++ @Nonnull+ public String getOriginalUrl() throws ParsingException {+ return linkHandler.getOriginalUrl();+ }++ @Nonnull+ public String getUrl() throws ParsingException {+ return linkHandler.getUrl();+ }++ @Nonnull+ public String getBaseUrl() throws ParsingException {+ return linkHandler.getBaseUrl();+ }++ @Nonnull+ public StreamingService getService() {+ return service;+ }++ public int getServiceId() {+ return service.getServiceId();+ }++ public Downloader getDownloader() {+ return downloader;+ }++ /*//////////////////////////////////////////////////////////////////////////+ // Localization+ //////////////////////////////////////////////////////////////////////////*/++ public void forceLocalization(final Localization localization) {+ this.forcedLocalization = localization;+ }++ public void forceContentCountry(final ContentCountry contentCountry) {+ this.forcedContentCountry = contentCountry;+ }++ @Nonnull+ public Localization getExtractorLocalization() {+ return forcedLocalization == null ? getService().getLocalization() : forcedLocalization;+ }++ @Nonnull+ public ContentCountry getExtractorContentCountry() {+ return forcedContentCountry == null ? getService().getContentCountry()+ : forcedContentCountry;+ }++ @Nonnull+ public TimeAgoParser getTimeAgoParser() {+ return getService().getTimeAgoParser(getExtractorLocalization());+ }++ @Override+ public String toString() {+ return getClass().getSimpleName();+ }+}
youpipe/extractor/src/main/java/org/schabi/newpipe/extractor/Image.java
diff --git a/youpipe/extractor/src/main/java/org/schabi/newpipe/extractor/Image.java b/youpipe/extractor/src/main/java/org/schabi/newpipe/extractor/Image.javanew file mode 100644index 0000000000..e0d56e14ad--- /dev/null+++ b/youpipe/extractor/src/main/java/org/schabi/newpipe/extractor/Image.java@@ -0,0 +1,211 @@+package org.schabi.newpipe.extractor;++import javax.annotation.Nonnull;+import java.io.Serializable;+import java.util.Objects;++/**+ * Class representing images in the extractor.+ *+ * <p>+ * An image has four properties: its URL, its height, its width and its estimated quality level.+ * </p>+ *+ * <p>+ * Depending of the services, the height, the width or both properties may be not known.+ * Implementations <b>must use</b> the relevant unknown constants in this case+ * ({@link #HEIGHT_UNKNOWN} and {@link #WIDTH_UNKNOWN}), to ensure properly the lack of knowledge+ * of one or both of these properties to extractor clients.+ * </p>+ *+ * <p>+ * They should also respect the ranges defined in the estimated image resolution levels as much as+ * possible, to ensure consistency to extractor clients.+ * </p>+ */+public final class Image implements Serializable {++ /**+ * Constant representing that the height of an {@link Image} is unknown.+ */+ public static final int HEIGHT_UNKNOWN = -1;++ /**+ * Constant representing that the width of an {@link Image} is unknown.+ */+ public static final int WIDTH_UNKNOWN = -1;++ @Nonnull+ private final String url;+ private final int height;+ private final int width;+ @Nonnull+ private final ResolutionLevel estimatedResolutionLevel;++ /**+ * Construct an {@link Image} instance.+ *+ * @param url the URL to the image, which should be not null or empty+ * @param height the image's height+ * @param width the image's width+ * @param estimatedResolutionLevel the image's estimated resolution level, which must not be+ * null+ * @throws NullPointerException if {@code estimatedResolutionLevel} is null+ */+ public Image(@Nonnull final String url,+ final int height,+ final int width,+ @Nonnull final ResolutionLevel estimatedResolutionLevel)+ throws NullPointerException {+ this.url = url;+ this.height = height;+ this.width = width;+ this.estimatedResolutionLevel = Objects.requireNonNull(+ estimatedResolutionLevel, "estimatedResolutionLevel is null");+ }++ /**+ * Get the URL of this {@link Image}.+ *+ * @return the {@link Image}'s URL.+ */+ @Nonnull+ public String getUrl() {+ return url;+ }++ /**+ * Get the height of this {@link Image}.+ *+ * <p>+ * If it is unknown, {@link #HEIGHT_UNKNOWN} is returned instead.+ * </p>+ *+ * @return the {@link Image}'s height or {@link #HEIGHT_UNKNOWN}+ */+ public int getHeight() {+ return height;+ }++ /**+ * Get the width of this {@link Image}.+ *+ * <p>+ * If it is unknown, {@link #WIDTH_UNKNOWN} is returned instead.+ * </p>+ *+ * @return the {@link Image}'s width or {@link #WIDTH_UNKNOWN}+ */+ public int getWidth() {+ return width;+ }++ /**+ * Get the estimated resolution level of this image.+ *+ * <p>+ * If it is unknown, {@link ResolutionLevel#UNKNOWN} is returned instead.+ * </p>+ *+ * @return the estimated resolution level, which is never {@code null}+ * @see ResolutionLevel+ */+ @Nonnull+ public ResolutionLevel getEstimatedResolutionLevel() {+ return estimatedResolutionLevel;+ }++ /**+ * Get a string representation of this {@link Image} instance.+ *+ * <p>+ * The representation will be in the following format, where {@code url}, {@code height},+ * {@code width} and {@code estimatedResolutionLevel} represent the corresponding properties:+ * <br>+ * <br>+ * {@code Image {url=url, height='height, width=width,+ * estimatedResolutionLevel=estimatedResolutionLevel}'}+ * </p>+ *+ * @return a string representation of this {@link Image} instance+ */+ @Nonnull+ @Override+ public String toString() {+ return "Image {" + "url=" + url + ", height=" + height + ", width=" + width+ + ", estimatedResolutionLevel=" + estimatedResolutionLevel + "}";+ }++ /**+ * The estimated resolution level of an {@link Image}.+ *+ * <p>+ * Some services don't return the size of their images, but we may know for a specific image+ * type that a service returns, according to real data, an approximation of the resolution+ * level.+ * </p>+ */+ public enum ResolutionLevel {++ /**+ * The high resolution level.+ *+ * <p>+ * This level applies to images with a height greater than or equal to 720px.+ * </p>+ */+ HIGH,++ /**+ * The medium resolution level.+ *+ * <p>+ * This level applies to images with a height between 175px inclusive and 720px exclusive.+ * </p>+ */+ MEDIUM,++ /**+ * The low resolution level.+ *+ * <p>+ * This level applies to images with a height between 1px inclusive and 175px exclusive.+ * </p>+ */+ LOW,++ /**+ * The unknown resolution level.+ *+ * <p>+ * This value is returned when the extractor doesn't know what resolution level an image+ * could have, for example if the extractor loops in an array of images with different+ * resolution levels without knowing the height.+ * </p>+ */+ UNKNOWN;++ /**+ * Get a {@link ResolutionLevel} based from the given height.+ *+ * @param heightPx the height from which returning the good {@link ResolutionLevel}+ * @return the {@link ResolutionLevel} corresponding to the height provided. See the+ * {@link ResolutionLevel} values for details about what value is returned.+ */+ public static ResolutionLevel fromHeight(final int heightPx) {+ if (heightPx <= 0) {+ return UNKNOWN;+ }++ if (heightPx < 175) {+ return LOW;+ }++ if (heightPx < 720) {+ return MEDIUM;+ }++ return HIGH;+ }+ }+}
youpipe/extractor/src/main/java/org/schabi/newpipe/extractor/Info.java
diff --git a/youpipe/extractor/src/main/java/org/schabi/newpipe/extractor/Info.java b/youpipe/extractor/src/main/java/org/schabi/newpipe/extractor/Info.javanew file mode 100644index 0000000000..7ad5e8dd77--- /dev/null+++ b/youpipe/extractor/src/main/java/org/schabi/newpipe/extractor/Info.java@@ -0,0 +1,114 @@+package org.schabi.newpipe.extractor;++import org.schabi.newpipe.extractor.exceptions.ExtractionException;+import org.schabi.newpipe.extractor.linkhandler.LinkHandler;+import org.schabi.newpipe.extractor.utils.ExtractorLogger;++import java.io.Serializable;+import java.util.ArrayList;+import java.util.Collection;+import java.util.List;++public abstract class Info implements Serializable {++ private static final String TAG = "Info";+ private final int serviceId;+ /**+ * Id of this Info object <br>+ * e.g. Youtube: https://www.youtube.com/watch?v=RER5qCTzZ7 > RER5qCTzZ7+ */+ private final String id;+ /**+ * Different than the {@link #originalUrl} in the sense that it <i>may</i> be set as a cleaned+ * url.+ *+ * @see LinkHandler#getUrl()+ * @see Extractor#getOriginalUrl()+ */+ private final String url;+ /**+ * The url used to start the extraction of this {@link Info} object.+ *+ * @see Extractor#getOriginalUrl()+ */+ private String originalUrl;+ private final String name;++ private final List<Throwable> errors = new ArrayList<>();++ public void addError(final Throwable throwable) {+ this.errors.add(throwable);+ }++ public void addAllErrors(final Collection<Throwable> throwables) {+ this.errors.addAll(throwables);+ }++ public Info(final int serviceId,+ final String id,+ final String url,+ final String originalUrl,+ final String name) {+ this.serviceId = serviceId;+ this.id = id;+ this.url = url;+ this.originalUrl = originalUrl;+ this.name = name;+ ExtractorLogger.d(TAG, "Base Created {}", this);+ }++ public Info(final int serviceId, final LinkHandler linkHandler, final String name) {+ this(serviceId,+ linkHandler.getId(),+ linkHandler.getUrl(),+ linkHandler.getOriginalUrl(),+ name);+ }++ @Override+ public String toString() {+ final String ifDifferentString+ = url.equals(originalUrl) ? "" : " (originalUrl=\"" + originalUrl + "\")";+ return getClass().getSimpleName() + "[url=\"" + url + "\"" + ifDifferentString+ + ", name=\"" + name + "\"]";+ }++ // if you use an api and want to handle the website url+ // overriding original url is essential+ public void setOriginalUrl(final String originalUrl) {+ this.originalUrl = originalUrl;+ }++ public int getServiceId() {+ return serviceId;+ }++ public StreamingService getService() {+ try {+ return NewPipe.getService(serviceId);+ } catch (final ExtractionException e) {+ // this should be unreachable, as serviceId certainly refers to a valid service+ throw new RuntimeException("Info object has invalid service id", e);+ }+ }++ public String getId() {+ return id;+ }++ public String getUrl() {+ return url;+ }++ public String getOriginalUrl() {+ return originalUrl;+ }++ public String getName() {+ return name;+ }++ public List<Throwable> getErrors() {+ return errors;+ }+}
youpipe/extractor/src/main/java/org/schabi/newpipe/extractor/InfoItem.java
diff --git a/youpipe/extractor/src/main/java/org/schabi/newpipe/extractor/InfoItem.java b/youpipe/extractor/src/main/java/org/schabi/newpipe/extractor/InfoItem.javanew file mode 100644index 0000000000..08956b883f--- /dev/null+++ b/youpipe/extractor/src/main/java/org/schabi/newpipe/extractor/InfoItem.java@@ -0,0 +1,81 @@+/*+ * Created by Christian Schabesberger on 11.02.17.+ *+ * Copyright (C) 2017 Christian Schabesberger <[email protected]>+ * InfoItem.java is part of NewPipe Extractor.+ *+ * NewPipe Extractor is free software: you can redistribute it and/or modify+ * it under the terms of the GNU General Public License as published by+ * the Free Software Foundation, either version 3 of the License, or+ * (at your option) any later version.+ *+ * NewPipe Extractor is distributed in the hope that it will be useful,+ * but WITHOUT ANY WARRANTY; without even the implied warranty of+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the+ * GNU General Public License for more details.+ *+ * You should have received a copy of the GNU General Public License+ * along with NewPipe Extractor. If not, see <https://www.gnu.org/licenses/>.+ */++package org.schabi.newpipe.extractor;++import javax.annotation.Nonnull;+import java.io.Serializable;+import java.util.List;++public abstract class InfoItem implements Serializable {+ private final InfoType infoType;+ private final int serviceId;+ private final String url;+ private final String name;+ @Nonnull+ private List<Image> thumbnails = List.of();++ public InfoItem(final InfoType infoType,+ final int serviceId,+ final String url,+ final String name) {+ this.infoType = infoType;+ this.serviceId = serviceId;+ this.url = url;+ this.name = name;+ }++ public InfoType getInfoType() {+ return infoType;+ }++ public int getServiceId() {+ return serviceId;+ }++ public String getUrl() {+ return url;+ }++ public String getName() {+ return name;+ }++ public void setThumbnails(@Nonnull final List<Image> thumbnails) {+ this.thumbnails = thumbnails;+ }++ @Nonnull+ public List<Image> getThumbnails() {+ return thumbnails;+ }++ @Override+ public String toString() {+ return getClass().getSimpleName() + "[url=\"" + url + "\", name=\"" + name + "\"]";+ }++ public enum InfoType {+ STREAM,+ PLAYLIST,+ CHANNEL,+ COMMENT+ }+}
youpipe/extractor/src/main/java/org/schabi/newpipe/extractor/InfoItemExtractor.java
diff --git a/youpipe/extractor/src/main/java/org/schabi/newpipe/extractor/InfoItemExtractor.java b/youpipe/extractor/src/main/java/org/schabi/newpipe/extractor/InfoItemExtractor.javanew file mode 100644index 0000000000..ed59741764--- /dev/null+++ b/youpipe/extractor/src/main/java/org/schabi/newpipe/extractor/InfoItemExtractor.java@@ -0,0 +1,13 @@+package org.schabi.newpipe.extractor;++import org.schabi.newpipe.extractor.exceptions.ParsingException;++import javax.annotation.Nonnull;+import java.util.List;++public interface InfoItemExtractor {+ String getName() throws ParsingException;+ String getUrl() throws ParsingException;+ @Nonnull+ List<Image> getThumbnails() throws ParsingException;+}
youpipe/extractor/src/main/java/org/schabi/newpipe/extractor/InfoItemsCollector.java
diff --git a/youpipe/extractor/src/main/java/org/schabi/newpipe/extractor/InfoItemsCollector.java b/youpipe/extractor/src/main/java/org/schabi/newpipe/extractor/InfoItemsCollector.javanew file mode 100644index 0000000000..a6411b7730--- /dev/null+++ b/youpipe/extractor/src/main/java/org/schabi/newpipe/extractor/InfoItemsCollector.java@@ -0,0 +1,111 @@+package org.schabi.newpipe.extractor;++import org.schabi.newpipe.extractor.exceptions.FoundAdException;+import org.schabi.newpipe.extractor.exceptions.ParsingException;++import javax.annotation.Nullable;+import java.util.ArrayList;+import java.util.Collections;+import java.util.Comparator;+import java.util.List;++/*+ * Created by Christian Schabesberger on 12.02.17.+ *+ * Copyright (C) 2017 Christian Schabesberger <[email protected]>+ * InfoItemsCollector.java is part of NewPipe Extractor.+ *+ * NewPipe Extractor is free software: you can redistribute it and/or modify+ * it under the terms of the GNU General Public License as published by+ * the Free Software Foundation, either version 3 of the License, or+ * (at your option) any later version.+ *+ * NewPipe Extractor is distributed in the hope that it will be useful,+ * but WITHOUT ANY WARRANTY; without even the implied warranty of+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the+ * GNU General Public License for more details.+ *+ * You should have received a copy of the GNU General Public License+ * along with NewPipe Extractor. If not, see <http://www.gnu.org/licenses/>.+ */++public abstract class InfoItemsCollector<I extends InfoItem, E extends InfoItemExtractor>+ implements Collector<I, E> {++ private final List<I> itemList = new ArrayList<>();+ private final List<Throwable> errors = new ArrayList<>();+ private final int serviceId;+ @Nullable+ private final Comparator<I> comparator;++ /**+ * Create a new collector with no comparator / sorting function+ * @param serviceId the service id+ */+ public InfoItemsCollector(final int serviceId) {+ this(serviceId, null);+ }++ /**+ * Create a new collector+ * @param serviceId the service id+ */+ public InfoItemsCollector(final int serviceId, @Nullable final Comparator<I> comparator) {+ this.serviceId = serviceId;+ this.comparator = comparator;+ }++ @Override+ public List<I> getItems() {+ if (comparator != null) {+ itemList.sort(comparator);+ }+ return Collections.unmodifiableList(itemList);+ }++ @Override+ public List<Throwable> getErrors() {+ return Collections.unmodifiableList(errors);+ }++ @Override+ public void reset() {+ itemList.clear();+ errors.clear();+ }++ /**+ * Add an error+ * @param error the error+ */+ protected void addError(final Exception error) {+ errors.add(error);+ }++ /**+ * Add an item+ * @param item the item+ */+ protected void addItem(final I item) {+ itemList.add(item);+ }++ /**+ * Get the service id+ * @return the service id+ */+ public int getServiceId() {+ return serviceId;+ }++ @Override+ public void commit(final E extractor) {+ try {+ addItem(extract(extractor));+ } catch (final FoundAdException ae) {+ // found an ad. Maybe a debug line could be placed here+ } catch (final ParsingException e) {+ addError(e);+ }+ }+}
youpipe/extractor/src/main/java/org/schabi/newpipe/extractor/ListExtractor.java
diff --git a/youpipe/extractor/src/main/java/org/schabi/newpipe/extractor/ListExtractor.java b/youpipe/extractor/src/main/java/org/schabi/newpipe/extractor/ListExtractor.javanew file mode 100644index 0000000000..113ba00bfe--- /dev/null+++ b/youpipe/extractor/src/main/java/org/schabi/newpipe/extractor/ListExtractor.java@@ -0,0 +1,143 @@+package org.schabi.newpipe.extractor;++import org.schabi.newpipe.extractor.exceptions.ExtractionException;+import org.schabi.newpipe.extractor.linkhandler.ListLinkHandler;++import java.io.IOException;+import java.util.Collections;+import java.util.List;++import javax.annotation.Nonnull;+import javax.annotation.Nullable;++/**+ * Base class to extractors that have a list (e.g. playlists, users).+ * @param <R> the info item type this list extractor provides+ */+public abstract class ListExtractor<R extends InfoItem> extends Extractor {+ /**+ * Constant that should be returned whenever+ * a list has an unknown number of items.+ */+ public static final long ITEM_COUNT_UNKNOWN = -1;++ /**+ * Constant that should be returned whenever a list has an+ * infinite number of items. For example a YouTube mix.+ */+ public static final long ITEM_COUNT_INFINITE = -2;++ /**+ * Constant that should be returned whenever a list+ * has an unknown number of items bigger than 100.+ */+ public static final long ITEM_COUNT_MORE_THAN_100 = -3;++ public ListExtractor(final StreamingService service, final ListLinkHandler linkHandler) {+ super(service, linkHandler);+ }++ /**+ * A {@link InfoItemsPage InfoItemsPage} corresponding to the initial page+ * where the items are from the initial request and the nextPage relative to it.+ *+ * @return a {@link InfoItemsPage} corresponding to the initial page+ */+ @Nonnull+ public abstract InfoItemsPage<R> getInitialPage() throws IOException, ExtractionException;++ /**+ * Get a list of items corresponding to the specific requested page.+ *+ * @param page any page got from the exclusive implementation of the list extractor+ * @return a {@link InfoItemsPage} corresponding to the requested page+ * @see InfoItemsPage#getNextPage()+ */+ public abstract InfoItemsPage<R> getPage(Page page) throws IOException, ExtractionException;++ @Nonnull+ @Override+ public ListLinkHandler getLinkHandler() {+ return (ListLinkHandler) super.getLinkHandler();+ }++ /*//////////////////////////////////////////////////////////////////////////+ // Inner+ //////////////////////////////////////////////////////////////////////////*/++ /**+ * A class that is used to wrap a list of gathered items and eventual errors, it+ * also contains a field that points to the next available page ({@link #nextPage}).+ * @param <T> the info item type that this page is supposed to store and provide+ */+ public static class InfoItemsPage<T extends InfoItem> {+ private static final InfoItemsPage<InfoItem> EMPTY = new InfoItemsPage<>(+ Collections.emptyList(),+ null,+ Collections.emptyList()+ );++ /**+ * A convenient method that returns a representation of an empty page.+ *+ * @return a type-safe page with the list of items and errors empty and the nextPage set to+ * {@code null}.+ */+ public static <T extends InfoItem> InfoItemsPage<T> emptyPage() {+ //noinspection unchecked+ return (InfoItemsPage<T>) EMPTY;+ }++ /**+ * The current list of items of this page+ */+ private final List<T> itemsList;++ /**+ * Url pointing to the next page relative to this one+ *+ * @see ListExtractor#getPage(Page)+ * @see Page+ */+ @Nullable+ private final Page nextPage;++ /**+ * Errors that happened during the extraction+ */+ private final List<Throwable> errors;++ public InfoItemsPage(final InfoItemsCollector<T, ?> collector,+ @Nullable final Page nextPage) {+ this(collector.getItems(), nextPage, collector.getErrors());+ }++ public InfoItemsPage(final List<T> itemsList,+ @Nullable final Page nextPage,+ final List<Throwable> errors) {+ this.itemsList = itemsList;+ this.nextPage = nextPage;+ this.errors = errors;+ }++ public boolean hasNextPage() {+ return Page.isValid(nextPage);+ }++ public List<T> getItems() {+ return itemsList;+ }++ /**+ * @return the next page if available, or null otherwise+ */+ @Nullable+ public Page getNextPage() {+ return nextPage;+ }++ public List<Throwable> getErrors() {+ return errors;+ }+ }+}
youpipe/extractor/src/main/java/org/schabi/newpipe/extractor/ListInfo.java
diff --git a/youpipe/extractor/src/main/java/org/schabi/newpipe/extractor/ListInfo.java b/youpipe/extractor/src/main/java/org/schabi/newpipe/extractor/ListInfo.javanew file mode 100644index 0000000000..8e383f3e18--- /dev/null+++ b/youpipe/extractor/src/main/java/org/schabi/newpipe/extractor/ListInfo.java@@ -0,0 +1,60 @@+package org.schabi.newpipe.extractor;++import org.schabi.newpipe.extractor.linkhandler.ListLinkHandler;++import java.util.List;++public abstract class ListInfo<T extends InfoItem> extends Info {+ private List<T> relatedItems;+ private Page nextPage = null;+ private final List<String> contentFilters;+ private final String sortFilter;++ public ListInfo(final int serviceId,+ final String id,+ final String url,+ final String originalUrl,+ final String name,+ final List<String> contentFilter,+ final String sortFilter) {+ super(serviceId, id, url, originalUrl, name);+ this.contentFilters = contentFilter;+ this.sortFilter = sortFilter;+ }++ public ListInfo(final int serviceId,+ final ListLinkHandler listUrlIdHandler,+ final String name) {+ super(serviceId, listUrlIdHandler, name);+ this.contentFilters = listUrlIdHandler.getContentFilters();+ this.sortFilter = listUrlIdHandler.getSortFilter();+ }++ public List<T> getRelatedItems() {+ return relatedItems;+ }++ public void setRelatedItems(final List<T> relatedItems) {+ this.relatedItems = relatedItems;+ }++ public boolean hasNextPage() {+ return Page.isValid(nextPage);+ }++ public Page getNextPage() {+ return nextPage;+ }++ public void setNextPage(final Page page) {+ this.nextPage = page;+ }++ public List<String> getContentFilters() {+ return contentFilters;+ }++ public String getSortFilter() {+ return sortFilter;+ }+}
youpipe/extractor/src/main/java/org/schabi/newpipe/extractor/MediaFormat.java
diff --git a/youpipe/extractor/src/main/java/org/schabi/newpipe/extractor/MediaFormat.java b/youpipe/extractor/src/main/java/org/schabi/newpipe/extractor/MediaFormat.javanew file mode 100644index 0000000000..dc31e6f316--- /dev/null+++ b/youpipe/extractor/src/main/java/org/schabi/newpipe/extractor/MediaFormat.java@@ -0,0 +1,213 @@+package org.schabi.newpipe.extractor;++/*+ * Created by Adam Howard on 08/11/15.+ *+ * Copyright (c) 2015 Christian Schabesberger <[email protected]>+ * and Adam Howard <[email protected]>+ *+ * MediaFormat.java is part of NewPipe Extractor.+ *+ * NewPipe Extractor is free software: you can redistribute it and/or modify+ * it under the terms of the GNU General Public License as published by+ * the Free Software Foundation, either version 3 of the License, or+ * (at your option) any later version.+ *+ * NewPipe Extractor is distributed in the hope that it will be useful,+ * but WITHOUT ANY WARRANTY; without even the implied warranty of+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the+ * GNU General Public License for more details.+ *+ * You should have received a copy of the GNU General Public License+ * along with NewPipe Extractor. If not, see <http://www.gnu.org/licenses/>.+ */++import javax.annotation.Nonnull;+import javax.annotation.Nullable;+import java.util.Arrays;+import java.util.List;+import java.util.function.Function;+import java.util.stream.Collectors;++/**+ * Static data about various media formats support by NewPipe, eg mime type, extension+ */++@SuppressWarnings("MethodParamPad") // we want the media format table below to be aligned+public enum MediaFormat {+ // @formatter:off+ //video and audio combined formats+ // id name suffix mimeType+ MPEG_4 (0x0, "MPEG-4", "mp4", "video/mp4"),+ v3GPP (0x10, "3GPP", "3gp", "video/3gpp"),+ WEBM (0x20, "WebM", "webm", "video/webm"),+ // audio formats+ M4A (0x100, "m4a", "m4a", "audio/mp4"),+ WEBMA (0x200, "WebM", "webm", "audio/webm"),+ MP3 (0x300, "MP3", "mp3", "audio/mpeg"),+ MP2 (0x310, "MP2", "mp2", "audio/mpeg"),+ OPUS (0x400, "opus", "opus", "audio/opus"),+ OGG (0x500, "ogg", "ogg", "audio/ogg"),+ WEBMA_OPUS(0x200, "WebM Opus", "webm", "audio/webm"),+ AIFF (0x600, "AIFF", "aiff", "audio/aiff"),+ /**+ * Same as {@link MediaFormat#AIFF}, just with the shorter suffix/file extension+ */+ AIF (0x600, "AIFF", "aif", "audio/aiff"),+ WAV (0x700, "WAV", "wav", "audio/wav"),+ FLAC (0x800, "FLAC", "flac", "audio/flac"),+ ALAC (0x900, "ALAC", "alac", "audio/alac"),+ // subtitles formats+ VTT (0x1000, "WebVTT", "vtt", "text/vtt"),+ TTML (0x2000, "Timed Text Markup Language", "ttml", "application/ttml+xml"),+ TRANSCRIPT1(0x3000, "TranScript v1", "srv1", "text/xml"),+ TRANSCRIPT2(0x4000, "TranScript v2", "srv2", "text/xml"),+ TRANSCRIPT3(0x5000, "TranScript v3", "srv3", "text/xml"),+ SRT (0x6000, "SubRip file format", "srt", "text/srt");+ // @formatter:on++ public final int id;+ @Nonnull+ public final String name;+ @Nonnull+ public final String suffix;+ @Nonnull+ public final String mimeType;++ MediaFormat(final int id, @Nonnull final String name,+ @Nonnull final String suffix, @Nonnull final String mimeType) {+ this.id = id;+ this.name = name;+ this.suffix = suffix;+ this.mimeType = mimeType;+ }++ private static <T> T getById(final int id,+ final Function<MediaFormat, T> field,+ final T orElse) {+ return Arrays.stream(MediaFormat.values())+ .filter(mediaFormat -> mediaFormat.id == id)+ .map(field)+ .findFirst()+ .orElse(orElse);+ }++ /**+ * Return the friendly name of the media format with the supplied id+ *+ * @param id the id of the media format. Currently an arbitrary, NewPipe-specific number.+ * @return the friendly name of the MediaFormat associated with this ids,+ * or an empty String if none match it.+ */+ @Nonnull+ public static String getNameById(final int id) {+ return getById(id, MediaFormat::getName, "");+ }++ /**+ * Return the file extension of the media format with the supplied id+ *+ * @param id the id of the media format. Currently an arbitrary, NewPipe-specific number.+ * @return the file extension of the MediaFormat associated with this ids,+ * or an empty String if none match it.+ */+ @Nonnull+ public static String getSuffixById(final int id) {+ return getById(id, MediaFormat::getSuffix, "");+ }++ /**+ * Return the MIME type of the media format with the supplied id+ *+ * @param id the id of the media format. Currently an arbitrary, NewPipe-specific number.+ * @return the MIME type of the MediaFormat associated with this ids,+ * or an empty String if none match it.+ */+ @Nullable+ public static String getMimeById(final int id) {+ return getById(id, MediaFormat::getMimeType, null);+ }++ /**+ * Return the first {@link MediaFormat} with the supplied mime type.+ * There might be more formats which have the same mime type.+ * To retrieve those, use {@link #getAllFromMimeType(String)}.+ *+ * @return MediaFormat associated with this mime type,+ * or null if none match it.+ */+ @Nullable+ public static MediaFormat getFromMimeType(final String mimeType) {+ return Arrays.stream(MediaFormat.values())+ .filter(mediaFormat -> mediaFormat.mimeType.equals(mimeType))+ .findFirst()+ .orElse(null);+ }++ /**+ * Get all media formats which have the given mime type.+ * @param mimeType the mime type to search for+ * @return a modifiable {@link List} which contains the {@link MediaFormat}s+ * that have the given mime type.+ */+ @Nonnull+ public static List<MediaFormat> getAllFromMimeType(final String mimeType) {+ return Arrays.stream(MediaFormat.values())+ .filter(mediaFormat -> mediaFormat.mimeType.equals(mimeType))+ .collect(Collectors.toList());+ }++ /**+ * Get the media format by its id.+ *+ * @param id the id+ * @return the id of the media format or null.+ */+ @Nullable+ public static MediaFormat getFormatById(final int id) {+ return getById(id, mediaFormat -> mediaFormat, null);+ }++ /**+ * Get the first media format that has the given suffix/file extension.+ * @return the matching {@link MediaFormat} or {@code null} if no associated format is found+ */+ @Nullable+ public static MediaFormat getFromSuffix(final String suffix) {+ return Arrays.stream(MediaFormat.values())+ .filter(mediaFormat -> mediaFormat.suffix.equals(suffix))+ .findFirst()+ .orElse(null);+ }++ /**+ * Get the name of the format+ *+ * @return the name of the format+ */+ @Nonnull+ public String getName() {+ return name;+ }++ /**+ * Get the filename extension+ *+ * @return the filename extension+ */+ @Nonnull+ public String getSuffix() {+ return suffix;+ }++ /**+ * Get the mime type+ *+ * @return the mime type+ */+ @Nonnull+ public String getMimeType() {+ return mimeType;+ }++}
youpipe/extractor/src/main/java/org/schabi/newpipe/extractor/MetaInfo.java
diff --git a/youpipe/extractor/src/main/java/org/schabi/newpipe/extractor/MetaInfo.java b/youpipe/extractor/src/main/java/org/schabi/newpipe/extractor/MetaInfo.javanew file mode 100644index 0000000000..79e2650d1d--- /dev/null+++ b/youpipe/extractor/src/main/java/org/schabi/newpipe/extractor/MetaInfo.java@@ -0,0 +1,78 @@+package org.schabi.newpipe.extractor;++import org.schabi.newpipe.extractor.stream.Description;++import java.io.Serializable;+import java.net.URL;+import java.util.ArrayList;+import java.util.List;++import javax.annotation.Nonnull;++public class MetaInfo implements Serializable {++ private String title = "";+ private Description content;+ private List<URL> urls = new ArrayList<>();+ private List<String> urlTexts = new ArrayList<>();++ public MetaInfo(@Nonnull final String title,+ @Nonnull final Description content,+ @Nonnull final List<URL> urls,+ @Nonnull final List<String> urlTexts) {+ this.title = title;+ this.content = content;+ this.urls = urls;+ this.urlTexts = urlTexts;+ }++ public MetaInfo() {+ }++ /**+ * @return Title of the info. Can be empty.+ */+ @Nonnull+ public String getTitle() {+ return title;+ }++ public void setTitle(@Nonnull final String title) {+ this.title = title;+ }++ @Nonnull+ public Description getContent() {+ return content;+ }++ public void setContent(@Nonnull final Description content) {+ this.content = content;+ }++ @Nonnull+ public List<URL> getUrls() {+ return urls;+ }++ public void setUrls(@Nonnull final List<URL> urls) {+ this.urls = urls;+ }++ public void addUrl(@Nonnull final URL url) {+ urls.add(url);+ }++ @Nonnull+ public List<String> getUrlTexts() {+ return urlTexts;+ }++ public void setUrlTexts(@Nonnull final List<String> urlTexts) {+ this.urlTexts = urlTexts;+ }++ public void addUrlText(@Nonnull final String urlText) {+ urlTexts.add(urlText);+ }+}
youpipe/extractor/src/main/java/org/schabi/newpipe/extractor/MultiInfoItemsCollector.java
diff --git a/youpipe/extractor/src/main/java/org/schabi/newpipe/extractor/MultiInfoItemsCollector.java b/youpipe/extractor/src/main/java/org/schabi/newpipe/extractor/MultiInfoItemsCollector.javanew file mode 100644index 0000000000..a7b911a822--- /dev/null+++ b/youpipe/extractor/src/main/java/org/schabi/newpipe/extractor/MultiInfoItemsCollector.java@@ -0,0 +1,91 @@+package org.schabi.newpipe.extractor;++import org.schabi.newpipe.extractor.channel.ChannelInfoItemExtractor;+import org.schabi.newpipe.extractor.channel.ChannelInfoItemsCollector;+import org.schabi.newpipe.extractor.exceptions.ParsingException;+import org.schabi.newpipe.extractor.playlist.PlaylistInfoItemExtractor;+import org.schabi.newpipe.extractor.playlist.PlaylistInfoItemsCollector;+import org.schabi.newpipe.extractor.stream.StreamInfoItemExtractor;+import org.schabi.newpipe.extractor.stream.StreamInfoItemsCollector;++import java.util.ArrayList;+import java.util.Collections;+import java.util.List;++/*+ * Created by Christian Schabesberger on 12.02.17.+ *+ * Copyright (C) 2017 Christian Schabesberger <[email protected]>+ * InfoItemsSearchCollector.java is part of NewPipe Extractor.+ *+ * NewPipe Extractor is free software: you can redistribute it and/or modify+ * it under the terms of the GNU General Public License as published by+ * the Free Software Foundation, either version 3 of the License, or+ * (at your option) any later version.+ *+ * NewPipe Extractor is distributed in the hope that it will be useful,+ * but WITHOUT ANY WARRANTY; without even the implied warranty of+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the+ * GNU General Public License for more details.+ *+ * You should have received a copy of the GNU General Public License+ * along with NewPipe Extractor. If not, see <http://www.gnu.org/licenses/>.+ */++/**+ * A collector that can handle many extractor types, to be used when a list contains items of+ * different types (e.g. search)+ * <p>+ * This collector can handle the following extractor types:+ * <ul>+ * <li>{@link StreamInfoItemExtractor}</li>+ * <li>{@link ChannelInfoItemExtractor}</li>+ * <li>{@link PlaylistInfoItemExtractor}</li>+ * </ul>+ * Calling {@link #extract(InfoItemExtractor)} or {@link #commit(InfoItemExtractor)} with any+ * other extractor type will raise an exception.+ */+public class MultiInfoItemsCollector extends InfoItemsCollector<InfoItem, InfoItemExtractor> {+ private final StreamInfoItemsCollector streamCollector;+ private final ChannelInfoItemsCollector userCollector;+ private final PlaylistInfoItemsCollector playlistCollector;++ public MultiInfoItemsCollector(final int serviceId) {+ super(serviceId);+ streamCollector = new StreamInfoItemsCollector(serviceId);+ userCollector = new ChannelInfoItemsCollector(serviceId);+ playlistCollector = new PlaylistInfoItemsCollector(serviceId);+ }++ @Override+ public List<Throwable> getErrors() {+ final List<Throwable> errors = new ArrayList<>(super.getErrors());+ errors.addAll(streamCollector.getErrors());+ errors.addAll(userCollector.getErrors());+ errors.addAll(playlistCollector.getErrors());++ return Collections.unmodifiableList(errors);+ }++ @Override+ public void reset() {+ super.reset();+ streamCollector.reset();+ userCollector.reset();+ playlistCollector.reset();+ }++ @Override+ public InfoItem extract(final InfoItemExtractor extractor) throws ParsingException {+ // Use the corresponding collector for each item extractor type+ if (extractor instanceof StreamInfoItemExtractor) {+ return streamCollector.extract((StreamInfoItemExtractor) extractor);+ } else if (extractor instanceof ChannelInfoItemExtractor) {+ return userCollector.extract((ChannelInfoItemExtractor) extractor);+ } else if (extractor instanceof PlaylistInfoItemExtractor) {+ return playlistCollector.extract((PlaylistInfoItemExtractor) extractor);+ } else {+ throw new IllegalArgumentException("Invalid extractor type: " + extractor);+ }+ }+}
youpipe/extractor/src/main/java/org/schabi/newpipe/extractor/NewPipe.java
diff --git a/youpipe/extractor/src/main/java/org/schabi/newpipe/extractor/NewPipe.java b/youpipe/extractor/src/main/java/org/schabi/newpipe/extractor/NewPipe.javanew file mode 100644index 0000000000..77fe1667a8--- /dev/null+++ b/youpipe/extractor/src/main/java/org/schabi/newpipe/extractor/NewPipe.java@@ -0,0 +1,141 @@+package org.schabi.newpipe.extractor;++/*+ * Created by Christian Schabesberger on 23.08.15.+ *+ * Copyright (C) 2015 Christian Schabesberger <[email protected]>+ * NewPipe Extractor.java is part of NewPipe Extractor.+ *+ * NewPipe Extractor is free software: you can redistribute it and/or modify+ * it under the terms of the GNU General Public License as published by+ * the Free Software Foundation, either version 3 of the License, or+ * (at your option) any later version.+ *+ * NewPipe Extractor is distributed in the hope that it will be useful,+ * but WITHOUT ANY WARRANTY; without even the implied warranty of+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the+ * GNU General Public License for more details.+ *+ * You should have received a copy of the GNU General Public License+ * along with NewPipe Extractor. If not, see <http://www.gnu.org/licenses/>.+ */++import org.schabi.newpipe.extractor.downloader.Downloader;+import org.schabi.newpipe.extractor.exceptions.ExtractionException;+import org.schabi.newpipe.extractor.localization.ContentCountry;+import org.schabi.newpipe.extractor.localization.Localization;+import org.schabi.newpipe.extractor.utils.ExtractorLogger;++import java.util.List;++import javax.annotation.Nonnull;+import javax.annotation.Nullable;++/**+ * Provides access to streaming services supported by NewPipe.+ */+public final class NewPipe {+ private static final String TAG = NewPipe.class.getSimpleName();+ private static Downloader downloader;+ private static Localization preferredLocalization;+ private static ContentCountry preferredContentCountry;++ private NewPipe() {+ }++ public static void init(final Downloader d) {+ ExtractorLogger.d(TAG, "Default init called");+ init(d, Localization.DEFAULT);+ }++ public static void init(final Downloader d, final Localization l) {+ ExtractorLogger.d(TAG, "Default init called with localization={}");+ init(d, l, l.getCountryCode().isEmpty()+ ? ContentCountry.DEFAULT : new ContentCountry(l.getCountryCode()));+ }++ public static void init(final Downloader d, final Localization l, final ContentCountry c) {+ ExtractorLogger.d(TAG, "Initializing with downloader={}, localization={}, country={}",+ d, l, c);+ downloader = d;+ preferredLocalization = l;+ preferredContentCountry = c;+ }++ public static Downloader getDownloader() {+ return downloader;+ }++ /*//////////////////////////////////////////////////////////////////////////+ // Utils+ //////////////////////////////////////////////////////////////////////////*/++ public static List<StreamingService> getServices() {+ return ServiceList.all();+ }++ public static StreamingService getService(final int serviceId) throws ExtractionException {+ return ServiceList.all().stream()+ .filter(service -> service.getServiceId() == serviceId)+ .findFirst()+ .orElseThrow(() -> new ExtractionException(+ "There's no service with the id = \"" + serviceId + "\""));+ }++ public static StreamingService getService(final String serviceName) throws ExtractionException {+ return ServiceList.all().stream()+ .filter(service -> service.getServiceInfo().getName().equals(serviceName))+ .findFirst()+ .orElseThrow(() -> new ExtractionException(+ "There's no service with the name = \"" + serviceName + "\""));+ }++ public static StreamingService getServiceByUrl(final String url) throws ExtractionException {+ for (final StreamingService service : ServiceList.all()) {+ if (service.getLinkTypeByUrl(url) != StreamingService.LinkType.NONE) {+ return service;+ }+ }+ throw new ExtractionException("No service can handle the url = \"" + url + "\"");+ }++ /*//////////////////////////////////////////////////////////////////////////+ // Localization+ //////////////////////////////////////////////////////////////////////////*/++ public static void setupLocalization(final Localization thePreferredLocalization) {+ setupLocalization(thePreferredLocalization, null);+ }++ public static void setupLocalization(+ final Localization thePreferredLocalization,+ @Nullable final ContentCountry thePreferredContentCountry) {+ NewPipe.preferredLocalization = thePreferredLocalization;++ if (thePreferredContentCountry != null) {+ NewPipe.preferredContentCountry = thePreferredContentCountry;+ } else {+ NewPipe.preferredContentCountry = thePreferredLocalization.getCountryCode().isEmpty()+ ? ContentCountry.DEFAULT+ : new ContentCountry(thePreferredLocalization.getCountryCode());+ }+ }++ @Nonnull+ public static Localization getPreferredLocalization() {+ return preferredLocalization == null ? Localization.DEFAULT : preferredLocalization;+ }++ public static void setPreferredLocalization(final Localization preferredLocalization) {+ NewPipe.preferredLocalization = preferredLocalization;+ }++ @Nonnull+ public static ContentCountry getPreferredContentCountry() {+ return preferredContentCountry == null ? ContentCountry.DEFAULT : preferredContentCountry;+ }++ public static void setPreferredContentCountry(final ContentCountry preferredContentCountry) {+ NewPipe.preferredContentCountry = preferredContentCountry;+ }+}
youpipe/extractor/src/main/java/org/schabi/newpipe/extractor/Page.java
diff --git a/youpipe/extractor/src/main/java/org/schabi/newpipe/extractor/Page.java b/youpipe/extractor/src/main/java/org/schabi/newpipe/extractor/Page.javanew file mode 100644index 0000000000..50b6cdd6be--- /dev/null+++ b/youpipe/extractor/src/main/java/org/schabi/newpipe/extractor/Page.java@@ -0,0 +1,85 @@+package org.schabi.newpipe.extractor;++import java.io.Serializable;+import java.util.List;+import java.util.Map;++import javax.annotation.Nullable;++import static org.schabi.newpipe.extractor.utils.Utils.isNullOrEmpty;++public class Page implements Serializable {+ private final String url;+ private final String id;+ private final List<String> ids;+ private final Map<String, String> cookies;++ @Nullable+ private final byte[] body;++ public Page(final String url,+ final String id,+ final List<String> ids,+ final Map<String, String> cookies,+ @Nullable final byte[] body) {+ this.url = url;+ this.id = id;+ this.ids = ids;+ this.cookies = cookies;+ this.body = body;+ }++ public Page(final String url) {+ this(url, null, null, null, null);+ }++ public Page(final String url, final String id) {+ this(url, id, null, null, null);+ }++ public Page(final String url, final String id, final byte[] body) {+ this(url, id, null, null, body);+ }++ public Page(final String url, final byte[] body) {+ this(url, null, null, null, body);+ }++ public Page(final String url, final Map<String, String> cookies) {+ this(url, null, null, cookies, null);+ }++ public Page(final List<String> ids) {+ this(null, null, ids, null, null);+ }++ public Page(final List<String> ids, final Map<String, String> cookies) {+ this(null, null, ids, cookies, null);+ }++ public String getUrl() {+ return url;+ }++ public String getId() {+ return id;+ }++ public List<String> getIds() {+ return ids;+ }++ public Map<String, String> getCookies() {+ return cookies;+ }++ public static boolean isValid(final Page page) {+ return page != null && (!isNullOrEmpty(page.getUrl())+ || !isNullOrEmpty(page.getIds()));+ }++ @Nullable+ public byte[] getBody() {+ return body;+ }+}
youpipe/extractor/src/main/java/org/schabi/newpipe/extractor/ServiceList.java
diff --git a/youpipe/extractor/src/main/java/org/schabi/newpipe/extractor/ServiceList.java b/youpipe/extractor/src/main/java/org/schabi/newpipe/extractor/ServiceList.javanew file mode 100644index 0000000000..b0b10365b2--- /dev/null+++ b/youpipe/extractor/src/main/java/org/schabi/newpipe/extractor/ServiceList.java@@ -0,0 +1,50 @@+package org.schabi.newpipe.extractor;++import org.schabi.newpipe.extractor.services.youtube.YoutubeService;++import java.util.List;++/*+ * Copyright (C) 2018 Christian Schabesberger <[email protected]>+ * ServiceList.java is part of NewPipe Extractor.+ *+ * NewPipe Extractor is free software: you can redistribute it and/or modify+ * it under the terms of the GNU General Public License as published by+ * the Free Software Foundation, either version 3 of the License, or+ * (at your option) any later version.+ *+ * NewPipe Extractor is distributed in the hope that it will be useful,+ * but WITHOUT ANY WARRANTY; without even the implied warranty of+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the+ * GNU General Public License for more details.+ *+ * You should have received a copy of the GNU General Public License+ * along with NewPipe Extractor. If not, see <http://www.gnu.org/licenses/>.+ */++/**+ * A list of supported services.+ */+@SuppressWarnings({"ConstantName", "InnerAssignment"}) // keep unusual names and inner assignments+public final class ServiceList {+ private ServiceList() {+ // no instance+ }++ public static final YoutubeService YouTube = new YoutubeService(0);++ /**+ * When creating a new service, put this service in the end of this list,+ * and give it the next free id.+ */+ private static final List<StreamingService> SERVICES = List.of(YouTube);++ /**+ * Get all the supported services.+ *+ * @return a unmodifiable list of all the supported services+ */+ public static List<StreamingService> all() {+ return SERVICES;+ }+}
youpipe/extractor/src/main/java/org/schabi/newpipe/extractor/StreamingService.java
diff --git a/youpipe/extractor/src/main/java/org/schabi/newpipe/extractor/StreamingService.java b/youpipe/extractor/src/main/java/org/schabi/newpipe/extractor/StreamingService.javanew file mode 100644index 0000000000..0216ba3aa0--- /dev/null+++ b/youpipe/extractor/src/main/java/org/schabi/newpipe/extractor/StreamingService.java@@ -0,0 +1,437 @@+package org.schabi.newpipe.extractor;++import org.schabi.newpipe.extractor.channel.ChannelExtractor;+import org.schabi.newpipe.extractor.channel.tabs.ChannelTabExtractor;+import org.schabi.newpipe.extractor.comments.CommentsExtractor;+import org.schabi.newpipe.extractor.exceptions.ExtractionException;+import org.schabi.newpipe.extractor.exceptions.ParsingException;+import org.schabi.newpipe.extractor.feed.FeedExtractor;+import org.schabi.newpipe.extractor.kiosk.KioskList;+import org.schabi.newpipe.extractor.linkhandler.LinkHandler;+import org.schabi.newpipe.extractor.linkhandler.LinkHandlerFactory;+import org.schabi.newpipe.extractor.linkhandler.ListLinkHandler;+import org.schabi.newpipe.extractor.linkhandler.ListLinkHandlerFactory;+import org.schabi.newpipe.extractor.linkhandler.SearchQueryHandler;+import org.schabi.newpipe.extractor.linkhandler.SearchQueryHandlerFactory;+import org.schabi.newpipe.extractor.localization.ContentCountry;+import org.schabi.newpipe.extractor.localization.Localization;+import org.schabi.newpipe.extractor.localization.TimeAgoParser;+import org.schabi.newpipe.extractor.localization.TimeAgoPatternsManager;+import org.schabi.newpipe.extractor.playlist.PlaylistExtractor;+import org.schabi.newpipe.extractor.search.SearchExtractor;+import org.schabi.newpipe.extractor.stream.StreamExtractor;+import org.schabi.newpipe.extractor.subscription.SubscriptionExtractor;+import org.schabi.newpipe.extractor.suggestion.SuggestionExtractor;+import org.schabi.newpipe.extractor.utils.Utils;++import javax.annotation.Nullable;+import java.util.Collections;+import java.util.List;+import java.util.Set;++/*+ * Copyright (C) 2018 Christian Schabesberger <[email protected]>+ * StreamingService.java is part of NewPipe Extractor.+ *+ * NewPipe Extractor is free software: you can redistribute it and/or modify+ * it under the terms of the GNU General Public License as published by+ * the Free Software Foundation, either version 3 of the License, or+ * (at your option) any later version.+ *+ * NewPipe Extractor is distributed in the hope that it will be useful,+ * but WITHOUT ANY WARRANTY; without even the implied warranty of+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the+ * GNU General Public License for more details.+ *+ * You should have received a copy of the GNU General Public License+ * along with NewPipe Extractor. If not, see <http://www.gnu.org/licenses/>.+ */++public abstract class StreamingService {++ /**+ * This class holds meta information about the service implementation.+ */+ public static class ServiceInfo {+ private final String name;++ private final Set<MediaCapability> mediaCapabilities;++ /**+ * Creates a new instance of a ServiceInfo+ * @param name the name of the service+ * @param mediaCapabilities the type of media this service can handle+ */+ public ServiceInfo(final String name, final Set<MediaCapability> mediaCapabilities) {+ this.name = name;+ this.mediaCapabilities = mediaCapabilities;+ }++ public String getName() {+ return name;+ }++ public Set<MediaCapability> getMediaCapabilities() {+ return mediaCapabilities;+ }++ public enum MediaCapability {+ AUDIO, VIDEO, LIVE, COMMENTS+ }+ }++ /**+ * LinkType will be used to determine which type of URL you are handling, and therefore which+ * part of NewPipe should handle a certain URL.+ */+ public enum LinkType {+ NONE,+ STREAM,+ CHANNEL,+ PLAYLIST+ }++ private final int serviceId;+ private final ServiceInfo serviceInfo;++ /**+ * Creates a new Streaming service.+ * If you Implement one do not set id within your implementation of this extractor, instead+ * set the id when you put the extractor into {@link ServiceList}+ * All other parameters can be set directly from the overriding constructor.+ * @param id the number of the service to identify him within the NewPipe frontend+ * @param name the name of the service+ * @param capabilities the type of media this service can handle+ */+ public StreamingService(final int id,+ final String name,+ final Set<ServiceInfo.MediaCapability> capabilities) {+ this.serviceId = id;+ this.serviceInfo = new ServiceInfo(name, capabilities);+ }++ public final int getServiceId() {+ return serviceId;+ }++ public ServiceInfo getServiceInfo() {+ return serviceInfo;+ }++ @Override+ public String toString() {+ return serviceId + ":" + serviceInfo.getName();+ }++ public abstract String getBaseUrl();++ /*//////////////////////////////////////////////////////////////////////////+ // Url Id handler+ //////////////////////////////////////////////////////////////////////////*/++ /**+ * Must return a new instance of an implementation of LinkHandlerFactory for streams.+ * @return an instance of a LinkHandlerFactory for streams+ */+ public abstract LinkHandlerFactory getStreamLHFactory();++ /**+ * Must return a new instance of an implementation of ListLinkHandlerFactory for channels.+ * If support for channels is not given null must be returned.+ * @return an instance of a ListLinkHandlerFactory for channels or null+ */+ public abstract ListLinkHandlerFactory getChannelLHFactory();++ /**+ * Must return a new instance of an implementation of ListLinkHandlerFactory for channel tabs.+ * If support for channel tabs is not given null must be returned.+ *+ * @return an instance of a ListLinkHandlerFactory for channel tabs or null+ */+ public abstract ListLinkHandlerFactory getChannelTabLHFactory();++ /**+ * Must return a new instance of an implementation of ListLinkHandlerFactory for playlists.+ * If support for playlists is not given null must be returned.+ * @return an instance of a ListLinkHandlerFactory for playlists or null+ */+ public abstract ListLinkHandlerFactory getPlaylistLHFactory();++ /**+ * Must return an instance of an implementation of SearchQueryHandlerFactory.+ * @return an instance of a SearchQueryHandlerFactory+ */+ public abstract SearchQueryHandlerFactory getSearchQHFactory();+ public abstract ListLinkHandlerFactory getCommentsLHFactory();++ /*//////////////////////////////////////////////////////////////////////////+ // Extractors+ //////////////////////////////////////////////////////////////////////////*/++ /**+ * Must create a new instance of a SearchExtractor implementation.+ * @param queryHandler specifies the keyword lock for, and the filters which should be applied.+ * @return a new SearchExtractor instance+ */+ public abstract SearchExtractor getSearchExtractor(SearchQueryHandler queryHandler);++ /**+ * Must create a new instance of a SuggestionExtractor implementation.+ * @return a new SuggestionExtractor instance+ */+ public abstract SuggestionExtractor getSuggestionExtractor();++ /**+ * Outdated or obsolete. null can be returned.+ * @return just null+ */+ public abstract SubscriptionExtractor getSubscriptionExtractor();++ /**+ * This method decides which strategy will be chosen to fetch the feed. In YouTube, for example,+ * a separate feed exists which is lightweight and made specifically to be used like this.+ * <p>+ * In services which there's no other way to retrieve them, null should be returned.+ *+ * @return a {@link FeedExtractor} instance or null.+ */+ @Nullable+ public FeedExtractor getFeedExtractor(final String url) throws ExtractionException {+ return null;+ }++ /**+ * Must create a new instance of a KioskList implementation.+ * @return a new KioskList instance+ */+ public abstract KioskList getKioskList() throws ExtractionException;++ /**+ * Must create a new instance of a ChannelExtractor implementation.+ * @param linkHandler is pointing to the channel which should be handled by this new instance.+ * @return a new ChannelExtractor+ */+ public abstract ChannelExtractor getChannelExtractor(ListLinkHandler linkHandler)+ throws ExtractionException;++ /**+ * Must create a new instance of a ChannelTabExtractor implementation.+ *+ * @param linkHandler is pointing to the channel which should be handled by this new instance.+ * @return a new ChannelTabExtractor+ */+ public abstract ChannelTabExtractor getChannelTabExtractor(ListLinkHandler linkHandler)+ throws ExtractionException;++ /**+ * Must crete a new instance of a PlaylistExtractor implementation.+ * @param linkHandler is pointing to the playlist which should be handled by this new instance.+ * @return a new PlaylistExtractor+ */+ public abstract PlaylistExtractor getPlaylistExtractor(ListLinkHandler linkHandler)+ throws ExtractionException;++ /**+ * Must create a new instance of a StreamExtractor implementation.+ * @param linkHandler is pointing to the stream which should be handled by this new instance.+ * @return a new StreamExtractor+ */+ public abstract StreamExtractor getStreamExtractor(LinkHandler linkHandler)+ throws ExtractionException;++ public abstract CommentsExtractor getCommentsExtractor(ListLinkHandler linkHandler)+ throws ExtractionException;++ /*//////////////////////////////////////////////////////////////////////////+ // Extractors without link handler+ //////////////////////////////////////////////////////////////////////////*/++ public SearchExtractor getSearchExtractor(final String query,+ final List<String> contentFilter,+ final String sortFilter) throws ExtractionException {+ return getSearchExtractor(getSearchQHFactory()+ .fromQuery(query, contentFilter, sortFilter));+ }++ public ChannelExtractor getChannelExtractor(final String id,+ final List<String> contentFilter,+ final String sortFilter)+ throws ExtractionException {+ return getChannelExtractor(getChannelLHFactory()+ .fromQuery(id, contentFilter, sortFilter));+ }++ public PlaylistExtractor getPlaylistExtractor(final String id,+ final List<String> contentFilter,+ final String sortFilter)+ throws ExtractionException {+ return getPlaylistExtractor(getPlaylistLHFactory()+ .fromQuery(id, contentFilter, sortFilter));+ }++ /*//////////////////////////////////////////////////////////////////////////+ // Short extractors overloads+ //////////////////////////////////////////////////////////////////////////*/++ public SearchExtractor getSearchExtractor(final String query) throws ExtractionException {+ return getSearchExtractor(getSearchQHFactory().fromQuery(query));+ }++ public ChannelExtractor getChannelExtractor(final String url) throws ExtractionException {+ return getChannelExtractor(getChannelLHFactory().fromUrl(url));+ }++ public ChannelTabExtractor getChannelTabExtractorFromId(final String id, final String tab)+ throws ExtractionException {+ return getChannelTabExtractor(getChannelTabLHFactory().fromQuery(+ id, Collections.singletonList(tab), ""));+ }++ public ChannelTabExtractor getChannelTabExtractorFromIdAndBaseUrl(final String id,+ final String tab,+ final String baseUrl)+ throws ExtractionException {+ return getChannelTabExtractor(getChannelTabLHFactory().fromQuery(+ id, Collections.singletonList(tab), "", baseUrl));+ }++ public PlaylistExtractor getPlaylistExtractor(final String url) throws ExtractionException {+ return getPlaylistExtractor(getPlaylistLHFactory().fromUrl(url));+ }++ public StreamExtractor getStreamExtractor(final String url) throws ExtractionException {+ return getStreamExtractor(getStreamLHFactory().fromUrl(url));+ }++ public CommentsExtractor getCommentsExtractor(final String url) throws ExtractionException {+ final ListLinkHandlerFactory listLinkHandlerFactory = getCommentsLHFactory();+ if (listLinkHandlerFactory == null) {+ return null;+ }+ return getCommentsExtractor(listLinkHandlerFactory.fromUrl(url));+ }++ /*//////////////////////////////////////////////////////////////////////////+ // Utils+ //////////////////////////////////////////////////////////////////////////*/++ /**+ * Figures out where the link is pointing to (a channel, a video, a playlist, etc.)+ * @param url the url on which it should be decided of which link type it is+ * @return the link type of url+ */+ public final LinkType getLinkTypeByUrl(final String url) throws ParsingException {+ final String polishedUrl = Utils.followGoogleRedirectIfNeeded(url);++ final LinkHandlerFactory sH = getStreamLHFactory();+ final LinkHandlerFactory cH = getChannelLHFactory();+ final LinkHandlerFactory pH = getPlaylistLHFactory();++ if (sH != null && sH.acceptUrl(polishedUrl)) {+ return LinkType.STREAM;+ } else if (cH != null && cH.acceptUrl(polishedUrl)) {+ return LinkType.CHANNEL;+ } else if (pH != null && pH.acceptUrl(polishedUrl)) {+ return LinkType.PLAYLIST;+ } else {+ return LinkType.NONE;+ }+ }++ /*//////////////////////////////////////////////////////////////////////////+ // Localization+ //////////////////////////////////////////////////////////////////////////*/++ /**+ * Returns a list of localizations that this service supports.+ */+ public List<Localization> getSupportedLocalizations() {+ return Collections.singletonList(Localization.DEFAULT);+ }++ /**+ * Returns a list of countries that this service supports.<br>+ */+ public List<ContentCountry> getSupportedCountries() {+ return Collections.singletonList(ContentCountry.DEFAULT);+ }++ /**+ * Returns the localization that should be used in this service. It will get which localization+ * the user prefer (using {@link NewPipe#getPreferredLocalization()}), then it will:+ * <ul>+ * <li>Check if the exactly localization is supported by this service.</li>+ * <li>If not, check if a less specific localization is available, using only the language+ * code.</li>+ * <li>Fallback to the {@link Localization#DEFAULT default} localization.</li>+ * </ul>+ */+ public Localization getLocalization() {+ final Localization preferredLocalization = NewPipe.getPreferredLocalization();++ // Check the localization's language and country+ if (getSupportedLocalizations().contains(preferredLocalization)) {+ return preferredLocalization;+ }++ // Fallback to the first supported language that matches the preferred language+ for (final Localization supportedLanguage : getSupportedLocalizations()) {+ if (supportedLanguage.getLanguageCode()+ .equals(preferredLocalization.getLanguageCode())) {+ return supportedLanguage;+ }+ }++ return Localization.DEFAULT;+ }++ /**+ * Returns the country that should be used to fetch content in this service. It will get which+ * country the user prefer (using {@link NewPipe#getPreferredContentCountry()}), then it will:+ * <ul>+ * <li>Check if the country is supported by this service.</li>+ * <li>If not, fallback to the {@link ContentCountry#DEFAULT default} country.</li>+ * </ul>+ */+ public ContentCountry getContentCountry() {+ final ContentCountry preferredContentCountry = NewPipe.getPreferredContentCountry();++ if (getSupportedCountries().contains(preferredContentCountry)) {+ return preferredContentCountry;+ }++ return ContentCountry.DEFAULT;+ }++ /**+ * Get an instance of the time ago parser using the patterns related to the passed localization.+ * <br><br>+ * Just like {@link #getLocalization()}, it will also try to fallback to a less specific+ * localization if the exact one is not available/supported.+ *+ * @throws IllegalArgumentException if the localization is not supported (parsing patterns are+ * not present).+ */+ public TimeAgoParser getTimeAgoParser(final Localization localization) {+ final TimeAgoParser targetParser = TimeAgoPatternsManager.getTimeAgoParserFor(localization);++ if (targetParser != null) {+ return targetParser;+ }++ if (!localization.getCountryCode().isEmpty()) {+ final Localization lessSpecificLocalization+ = new Localization(localization.getLanguageCode());+ final TimeAgoParser lessSpecificParser+ = TimeAgoPatternsManager.getTimeAgoParserFor(lessSpecificLocalization);++ if (lessSpecificParser != null) {+ return lessSpecificParser;+ }+ }++ throw new IllegalArgumentException(+ "Localization is not supported (\"" + localization + "\")");+ }++}
youpipe/extractor/src/main/java/org/schabi/newpipe/extractor/channel/ChannelExtractor.java
diff --git a/youpipe/extractor/src/main/java/org/schabi/newpipe/extractor/channel/ChannelExtractor.java b/youpipe/extractor/src/main/java/org/schabi/newpipe/extractor/channel/ChannelExtractor.javanew file mode 100644index 0000000000..90fda6ad04--- /dev/null+++ b/youpipe/extractor/src/main/java/org/schabi/newpipe/extractor/channel/ChannelExtractor.java@@ -0,0 +1,58 @@+/*+ * Created by Christian Schabesberger on 25.07.16.+ *+ * Copyright (C) 2016 Christian Schabesberger <[email protected]>+ * ChannelExtractor.java is part of NewPipe Extractor.+ *+ * NewPipe Extractor is free software: you can redistribute it and/or modify+ * it under the terms of the GNU General Public License as published by+ * the Free Software Foundation, either version 3 of the License, or+ * (at your option) any later version.+ *+ * NewPipe Extractor is distributed in the hope that it will be useful,+ * but WITHOUT ANY WARRANTY; without even the implied warranty of+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the+ * GNU General Public License for more details.+ *+ * You should have received a copy of the GNU General Public License+ * along with NewPipe Extractor. If not, see <https://www.gnu.org/licenses/>.+ */++package org.schabi.newpipe.extractor.channel;++import org.schabi.newpipe.extractor.Extractor;+import org.schabi.newpipe.extractor.Image;+import org.schabi.newpipe.extractor.StreamingService;+import org.schabi.newpipe.extractor.exceptions.ParsingException;+import org.schabi.newpipe.extractor.linkhandler.ListLinkHandler;++import javax.annotation.Nonnull;+import java.util.List;++public abstract class ChannelExtractor extends Extractor {++ public static final long UNKNOWN_SUBSCRIBER_COUNT = -1;++ protected ChannelExtractor(final StreamingService service, final ListLinkHandler linkHandler) {+ super(service, linkHandler);+ }++ @Nonnull+ public abstract List<Image> getAvatars() throws ParsingException;+ @Nonnull+ public abstract List<Image> getBanners() throws ParsingException;+ public abstract String getFeedUrl() throws ParsingException;+ public abstract long getSubscriberCount() throws ParsingException;+ public abstract String getDescription() throws ParsingException;+ public abstract String getParentChannelName() throws ParsingException;+ public abstract String getParentChannelUrl() throws ParsingException;+ @Nonnull+ public abstract List<Image> getParentChannelAvatars() throws ParsingException;+ public abstract boolean isVerified() throws ParsingException;+ @Nonnull+ public abstract List<ListLinkHandler> getTabs() throws ParsingException;+ @Nonnull+ public List<String> getTags() throws ParsingException {+ return List.of();+ }+}
youpipe/extractor/src/main/java/org/schabi/newpipe/extractor/channel/ChannelInfo.java
diff --git a/youpipe/extractor/src/main/java/org/schabi/newpipe/extractor/channel/ChannelInfo.java b/youpipe/extractor/src/main/java/org/schabi/newpipe/extractor/channel/ChannelInfo.javanew file mode 100644index 0000000000..edb4b393ba--- /dev/null+++ b/youpipe/extractor/src/main/java/org/schabi/newpipe/extractor/channel/ChannelInfo.java@@ -0,0 +1,252 @@+/*+ * Created by Christian Schabesberger on 31.07.16.+ *+ * Copyright (C) 2016 Christian Schabesberger <[email protected]>+ * ChannelInfo.java is part of NewPipe Extractor.+ *+ * NewPipe Extractor is free software: you can redistribute it and/or modify+ * it under the terms of the GNU General Public License as published by+ * the Free Software Foundation, either version 3 of the License, or+ * (at your option) any later version.+ *+ * NewPipe Extractor is distributed in the hope that it will be useful,+ * but WITHOUT ANY WARRANTY; without even the implied warranty of+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the+ * GNU General Public License for more details.+ *+ * You should have received a copy of the GNU General Public License+ * along with NewPipe Extractor. If not, see <https://www.gnu.org/licenses/>.+ */++package org.schabi.newpipe.extractor.channel;++import org.schabi.newpipe.extractor.Info;+import org.schabi.newpipe.extractor.Image;+import org.schabi.newpipe.extractor.NewPipe;+import org.schabi.newpipe.extractor.StreamingService;+import org.schabi.newpipe.extractor.exceptions.ExtractionException;+import org.schabi.newpipe.extractor.linkhandler.ListLinkHandler;++import java.io.IOException;+import java.util.List;++import javax.annotation.Nonnull;++public class ChannelInfo extends Info {++ public ChannelInfo(final int serviceId,+ final String id,+ final String url,+ final String originalUrl,+ final String name) {+ super(serviceId, id, url, originalUrl, name);+ }++ public static ChannelInfo getInfo(final String url) throws IOException, ExtractionException {+ return getInfo(NewPipe.getServiceByUrl(url), url);+ }++ public static ChannelInfo getInfo(final StreamingService service, final String url)+ throws IOException, ExtractionException {+ final ChannelExtractor extractor = service.getChannelExtractor(url);+ extractor.fetchPage();+ return getInfo(extractor);+ }++ public static ChannelInfo getInfo(final ChannelExtractor extractor)+ throws IOException, ExtractionException {++ final int serviceId = extractor.getServiceId();+ final String id = extractor.getId();+ final String url = extractor.getUrl();+ final String originalUrl = extractor.getOriginalUrl();+ final String name = extractor.getName();++ final ChannelInfo info = new ChannelInfo(serviceId, id, url, originalUrl, name);++ try {+ info.setAvatars(extractor.getAvatars());+ } catch (final Exception e) {+ info.addError(e);+ }++ try {+ info.setBanners(extractor.getBanners());+ } catch (final Exception e) {+ info.addError(e);+ }++ try {+ info.setFeedUrl(extractor.getFeedUrl());+ } catch (final Exception e) {+ info.addError(e);+ }++ try {+ info.setSubscriberCount(extractor.getSubscriberCount());+ } catch (final Exception e) {+ info.addError(e);+ }++ try {+ info.setDescription(extractor.getDescription());+ } catch (final Exception e) {+ info.addError(e);+ }++ try {+ info.setParentChannelName(extractor.getParentChannelName());+ } catch (final Exception e) {+ info.addError(e);+ }++ try {+ info.setParentChannelUrl(extractor.getParentChannelUrl());+ } catch (final Exception e) {+ info.addError(e);+ }++ try {+ info.setParentChannelAvatars(extractor.getParentChannelAvatars());+ } catch (final Exception e) {+ info.addError(e);+ }++ try {+ info.setVerified(extractor.isVerified());+ } catch (final Exception e) {+ info.addError(e);+ }++ try {+ info.setTabs(extractor.getTabs());+ } catch (final Exception e) {+ info.addError(e);+ }++ try {+ info.setTags(extractor.getTags());+ } catch (final Exception e) {+ info.addError(e);+ }++ return info;+ }++ private String parentChannelName;+ private String parentChannelUrl;+ private String feedUrl;+ private long subscriberCount = -1;+ private String description;+ private String[] donationLinks;+ @Nonnull+ private List<Image> avatars = List.of();+ @Nonnull+ private List<Image> banners = List.of();+ @Nonnull+ private List<Image> parentChannelAvatars = List.of();+ private boolean verified;+ private List<ListLinkHandler> tabs = List.of();+ private List<String> tags = List.of();++ public String getParentChannelName() {+ return parentChannelName;+ }++ public void setParentChannelName(final String parentChannelName) {+ this.parentChannelName = parentChannelName;+ }++ public String getParentChannelUrl() {+ return parentChannelUrl;+ }++ public void setParentChannelUrl(final String parentChannelUrl) {+ this.parentChannelUrl = parentChannelUrl;+ }++ @Nonnull+ public List<Image> getParentChannelAvatars() {+ return parentChannelAvatars;+ }++ public void setParentChannelAvatars(@Nonnull final List<Image> parentChannelAvatars) {+ this.parentChannelAvatars = parentChannelAvatars;+ }++ @Nonnull+ public List<Image> getAvatars() {+ return avatars;+ }++ public void setAvatars(@Nonnull final List<Image> avatars) {+ this.avatars = avatars;+ }++ @Nonnull+ public List<Image> getBanners() {+ return banners;+ }++ public void setBanners(@Nonnull final List<Image> banners) {+ this.banners = banners;+ }++ public String getFeedUrl() {+ return feedUrl;+ }++ public void setFeedUrl(final String feedUrl) {+ this.feedUrl = feedUrl;+ }++ public long getSubscriberCount() {+ return subscriberCount;+ }++ public void setSubscriberCount(final long subscriberCount) {+ this.subscriberCount = subscriberCount;+ }++ public String getDescription() {+ return description;+ }++ public void setDescription(final String description) {+ this.description = description;+ }++ public String[] getDonationLinks() {+ return donationLinks;+ }++ public void setDonationLinks(final String[] donationLinks) {+ this.donationLinks = donationLinks;+ }++ public boolean isVerified() {+ return verified;+ }++ public void setVerified(final boolean verified) {+ this.verified = verified;+ }++ @Nonnull+ public List<ListLinkHandler> getTabs() {+ return tabs;+ }++ public void setTabs(@Nonnull final List<ListLinkHandler> tabs) {+ this.tabs = tabs;+ }++ @Nonnull+ public List<String> getTags() {+ return tags;+ }++ public void setTags(@Nonnull final List<String> tags) {+ this.tags = tags;+ }+}
youpipe/extractor/src/main/java/org/schabi/newpipe/extractor/channel/ChannelInfoItem.java
diff --git a/youpipe/extractor/src/main/java/org/schabi/newpipe/extractor/channel/ChannelInfoItem.java b/youpipe/extractor/src/main/java/org/schabi/newpipe/extractor/channel/ChannelInfoItem.javanew file mode 100644index 0000000000..e12801886c--- /dev/null+++ b/youpipe/extractor/src/main/java/org/schabi/newpipe/extractor/channel/ChannelInfoItem.java@@ -0,0 +1,67 @@+package org.schabi.newpipe.extractor.channel;++import org.schabi.newpipe.extractor.InfoItem;++/*+ * Created by Christian Schabesberger on 11.02.17.+ *+ * Copyright (C) 2017 Christian Schabesberger <[email protected]>+ * ChannelInfoItem.java is part of NewPipe Extractor.+ *+ * NewPipe Extractor is free software: you can redistribute it and/or modify+ * it under the terms of the GNU General Public License as published by+ * the Free Software Foundation, either version 3 of the License, or+ * (at your option) any later version.+ *+ * NewPipe Extractor is distributed in the hope that it will be useful,+ * but WITHOUT ANY WARRANTY; without even the implied warranty of+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the+ * GNU General Public License for more details.+ *+ * You should have received a copy of the GNU General Public License+ * along with NewPipe Extractor. If not, see <http://www.gnu.org/licenses/>.+ */++public class ChannelInfoItem extends InfoItem {++ private String description;+ private long subscriberCount = -1;+ private long streamCount = -1;+ private boolean verified = false;++ public ChannelInfoItem(final int serviceId, final String url, final String name) {+ super(InfoType.CHANNEL, serviceId, url, name);+ }++ public String getDescription() {+ return description;+ }++ public void setDescription(final String description) {+ this.description = description;+ }++ public long getSubscriberCount() {+ return subscriberCount;+ }++ public void setSubscriberCount(final long subscriberCount) {+ this.subscriberCount = subscriberCount;+ }++ public long getStreamCount() {+ return streamCount;+ }++ public void setStreamCount(final long streamCount) {+ this.streamCount = streamCount;+ }++ public boolean isVerified() {+ return verified;+ }++ public void setVerified(final boolean verified) {+ this.verified = verified;+ }+}
youpipe/extractor/src/main/java/org/schabi/newpipe/extractor/channel/ChannelInfoItemExtractor.java
diff --git a/youpipe/extractor/src/main/java/org/schabi/newpipe/extractor/channel/ChannelInfoItemExtractor.java b/youpipe/extractor/src/main/java/org/schabi/newpipe/extractor/channel/ChannelInfoItemExtractor.javanew file mode 100644index 0000000000..6f1b01c913--- /dev/null+++ b/youpipe/extractor/src/main/java/org/schabi/newpipe/extractor/channel/ChannelInfoItemExtractor.java@@ -0,0 +1,34 @@+package org.schabi.newpipe.extractor.channel;++import org.schabi.newpipe.extractor.InfoItemExtractor;+import org.schabi.newpipe.extractor.exceptions.ParsingException;++/*+ * Created by Christian Schabesberger on 12.02.17.+ *+ * Copyright (C) 2017 Christian Schabesberger <[email protected]>+ * ChannelInfoItemExtractor.java is part of NewPipe Extractor.+ *+ * NewPipe Extractor is free software: you can redistribute it and/or modify+ * it under the terms of the GNU General Public License as published by+ * the Free Software Foundation, either version 3 of the License, or+ * (at your option) any later version.+ *+ * NewPipe Extractor is distributed in the hope that it will be useful,+ * but WITHOUT ANY WARRANTY; without even the implied warranty of+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the+ * GNU General Public License for more details.+ *+ * You should have received a copy of the GNU General Public License+ * along with NewPipe Extractor. If not, see <http://www.gnu.org/licenses/>.+ */++public interface ChannelInfoItemExtractor extends InfoItemExtractor {+ String getDescription() throws ParsingException;++ long getSubscriberCount() throws ParsingException;++ long getStreamCount() throws ParsingException;++ boolean isVerified() throws ParsingException;+}
youpipe/extractor/src/main/java/org/schabi/newpipe/extractor/channel/ChannelInfoItemsCollector.java
diff --git a/youpipe/extractor/src/main/java/org/schabi/newpipe/extractor/channel/ChannelInfoItemsCollector.java b/youpipe/extractor/src/main/java/org/schabi/newpipe/extractor/channel/ChannelInfoItemsCollector.javanew file mode 100644index 0000000000..5e4f383cbb--- /dev/null+++ b/youpipe/extractor/src/main/java/org/schabi/newpipe/extractor/channel/ChannelInfoItemsCollector.java@@ -0,0 +1,67 @@+/*+ * Created by Christian Schabesberger on 12.02.17.+ *+ * Copyright (C) 2017 Christian Schabesberger <[email protected]>+ * ChannelInfoItemsCollector.java is part of NewPipe Extractor.+ *+ * NewPipe Extractor is free software: you can redistribute it and/or modify+ * it under the terms of the GNU General Public License as published by+ * the Free Software Foundation, either version 3 of the License, or+ * (at your option) any later version.+ *+ * NewPipe Extractor is distributed in the hope that it will be useful,+ * but WITHOUT ANY WARRANTY; without even the implied warranty of+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the+ * GNU General Public License for more details.+ *+ * You should have received a copy of the GNU General Public License+ * along with NewPipe Extractor. If not, see <https://www.gnu.org/licenses/>.+ */++package org.schabi.newpipe.extractor.channel;++import org.schabi.newpipe.extractor.InfoItemsCollector;+import org.schabi.newpipe.extractor.exceptions.ParsingException;++public final class ChannelInfoItemsCollector+ extends InfoItemsCollector<ChannelInfoItem, ChannelInfoItemExtractor> {+ public ChannelInfoItemsCollector(final int serviceId) {+ super(serviceId);+ }++ @Override+ public ChannelInfoItem extract(final ChannelInfoItemExtractor extractor)+ throws ParsingException {+ final ChannelInfoItem resultItem = new ChannelInfoItem(+ getServiceId(), extractor.getUrl(), extractor.getName());++ // optional information+ try {+ resultItem.setSubscriberCount(extractor.getSubscriberCount());+ } catch (final Exception e) {+ addError(e);+ }+ try {+ resultItem.setStreamCount(extractor.getStreamCount());+ } catch (final Exception e) {+ addError(e);+ }+ try {+ resultItem.setThumbnails(extractor.getThumbnails());+ } catch (final Exception e) {+ addError(e);+ }+ try {+ resultItem.setDescription(extractor.getDescription());+ } catch (final Exception e) {+ addError(e);+ }+ try {+ resultItem.setVerified(extractor.isVerified());+ } catch (final Exception e) {+ addError(e);+ }++ return resultItem;+ }+}
youpipe/extractor/src/main/java/org/schabi/newpipe/extractor/channel/tabs/ChannelTabExtractor.java
diff --git a/youpipe/extractor/src/main/java/org/schabi/newpipe/extractor/channel/tabs/ChannelTabExtractor.java b/youpipe/extractor/src/main/java/org/schabi/newpipe/extractor/channel/tabs/ChannelTabExtractor.javanew file mode 100644index 0000000000..79b6d26308--- /dev/null+++ b/youpipe/extractor/src/main/java/org/schabi/newpipe/extractor/channel/tabs/ChannelTabExtract
Diff truncated.