Compare commits

..
1 Commits
Author SHA1 Message Date
Jonah Brüchert 95ea5da248 WIP: Display thumnnail in player 2021-03-11 16:46:33 +01:00
53 changed files with 559 additions and 3783 deletions

No files matched your search

-1
View File
@@ -1,2 +1 @@
CMakeLists.txt.user
flatpak/flatpak-builder-tools/
+3 -3
View File
@@ -4,8 +4,8 @@ project(audiotube)
include(FeatureSummary)
set(QT5_MIN_VERSION 5.15)
set(KF5_MIN_VERSION 5.81)
set(QT5_MIN_VERSION 5.12)
set(KF5_MIN_VERSION 5.65)
set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
@@ -23,7 +23,7 @@ include(ECMPoQmTools)
kde_enable_exceptions()
find_package(Qt5 ${QT5_MIN_VERSION} REQUIRED COMPONENTS Core Gui Qml QuickControls2 Svg DBus)
find_package(Qt5 ${QT5_MIN_VERSION} REQUIRED COMPONENTS Core Gui Qml QuickControls2 Svg)
find_package(KF5 ${KF5_MIN_VERSION} REQUIRED COMPONENTS Kirigami2 I18n)
find_package(pybind11 REQUIRED)
-117
View File
@@ -1,117 +0,0 @@
GNU GENERAL PUBLIC LICENSE
Version 2, June 1991
Copyright (C) 1989, 1991 Free Software Foundation, Inc.
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
Everyone is permitted to copy and distribute verbatim copies of this license document, but changing it is not allowed.
Preamble
The licenses for most software are designed to take away your freedom to share and change it. By contrast, the GNU General Public License is intended to guarantee your freedom to share and change free software--to make sure the software is free for all its users. This General Public License applies to most of the Free Software Foundation's software and to any other program whose authors commit to using it. (Some other Free Software Foundation software is covered by the GNU Lesser General Public License instead.) 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 this service 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 make restrictions that forbid anyone to deny you these rights or to ask you to surrender the rights. These restrictions translate to certain responsibilities for you if you distribute copies of the software, or if you modify it.
For example, if you distribute copies of such a program, whether gratis or for a fee, you must give the recipients all the rights that you have. 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.
We protect your rights with two steps: (1) copyright the software, and (2) offer you this license which gives you legal permission to copy, distribute and/or modify the software.
Also, for each author's protection and ours, we want to make certain that everyone understands that there is no warranty for this free software. If the software is modified by someone else and passed on, we want its recipients to know that what they have is not the original, so that any problems introduced by others will not reflect on the original authors' reputations.
Finally, any free program is threatened constantly by software patents. We wish to avoid the danger that redistributors of a free program will individually obtain patent licenses, in effect making the program proprietary. To prevent this, we have made it clear that any patent must be licensed for everyone's free use or not licensed at all.
The precise terms and conditions for copying, distribution and modification follow.
TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
0. This License applies to any program or other work which contains a notice placed by the copyright holder saying it may be distributed under the terms of this General Public License. The "Program", below, refers to any such program or work, and a "work based on the Program" means either the Program or any derivative work under copyright law: that is to say, a work containing the Program or a portion of it, either verbatim or with modifications and/or translated into another language. (Hereinafter, translation is included without limitation in the term "modification".) Each licensee is addressed as "you".
Activities other than copying, distribution and modification are not covered by this License; they are outside its scope. The act of running the Program is not restricted, and the output from the Program is covered only if its contents constitute a work based on the Program (independent of having been made by running the Program). Whether that is true depends on what the Program does.
1. You may copy and distribute 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 and disclaimer of warranty; keep intact all the notices that refer to this License and to the absence of any warranty; and give any other recipients of the Program a copy of this License along with the Program.
You may charge a fee for the physical act of transferring a copy, and you may at your option offer warranty protection in exchange for a fee.
2. You may modify your copy or copies of the Program or any portion of it, thus forming a work based on the Program, and copy and distribute such modifications or work under the terms of Section 1 above, provided that you also meet all of these conditions:
a) You must cause the modified files to carry prominent notices stating that you changed the files and the date of any change.
b) You must cause any work that you distribute or publish, that in whole or in part contains or is derived from the Program or any part thereof, to be licensed as a whole at no charge to all third parties under the terms of this License.
c) If the modified program normally reads commands interactively when run, you must cause it, when started running for such interactive use in the most ordinary way, to print or display an announcement including an appropriate copyright notice and a notice that there is no warranty (or else, saying that you provide a warranty) and that users may redistribute the program under these conditions, and telling the user how to view a copy of this License. (Exception: if the Program itself is interactive but does not normally print such an announcement, your work based on the Program is not required to print an announcement.)
These requirements apply to the modified work as a whole. If identifiable sections of that work are not derived from the Program, and can be reasonably considered independent and separate works in themselves, then this License, and its terms, do not apply to those sections when you distribute them as separate works. But when you distribute the same sections as part of a whole which is a work based on the Program, the distribution of the whole must be on the terms of this License, whose permissions for other licensees extend to the entire whole, and thus to each and every part regardless of who wrote it.
Thus, it is not the intent of this section to claim rights or contest your rights to work written entirely by you; rather, the intent is to exercise the right to control the distribution of derivative or collective works based on the Program.
In addition, mere aggregation of another work not based on the Program with the Program (or with a work based on the Program) on a volume of a storage or distribution medium does not bring the other work under the scope of this License.
3. You may copy and distribute the Program (or a work based on it, under Section 2) in object code or executable form under the terms of Sections 1 and 2 above provided that you also do one of the following:
a) Accompany it with the complete corresponding machine-readable source code, which must be distributed under the terms of Sections 1 and 2 above on a medium customarily used for software interchange; or,
b) Accompany it with a written offer, valid for at least three years, to give any third party, for a charge no more than your cost of physically performing source distribution, a complete machine-readable copy of the corresponding source code, to be distributed under the terms of Sections 1 and 2 above on a medium customarily used for software interchange; or,
c) Accompany it with the information you received as to the offer to distribute corresponding source code. (This alternative is allowed only for noncommercial distribution and only if you received the program in object code or executable form with such an offer, in accord with Subsection b above.)
The source code for a work means the preferred form of the work for making modifications to it. For an executable work, complete source code means all the source code for all modules it contains, plus any associated interface definition files, plus the scripts used to control compilation and installation of the executable. However, as a special exception, the source code distributed need not include anything that is normally distributed (in either source or binary form) with the major components (compiler, kernel, and so on) of the operating system on which the executable runs, unless that component itself accompanies the executable.
If distribution of executable or object code is made by offering access to copy from a designated place, then offering equivalent access to copy the source code from the same place counts as distribution of the source code, even though third parties are not compelled to copy the source along with the object code.
4. You may not copy, modify, sublicense, or distribute the Program except as expressly provided under this License. Any attempt otherwise to copy, modify, sublicense or distribute the Program is void, and will automatically terminate your rights under this License. However, parties who have received copies, or rights, from you under this License will not have their licenses terminated so long as such parties remain in full compliance.
5. You are not required to accept this License, since you have not signed it. However, nothing else grants you permission to modify or distribute the Program or its derivative works. These actions are prohibited by law if you do not accept this License. Therefore, by modifying or distributing the Program (or any work based on the Program), you indicate your acceptance of this License to do so, and all its terms and conditions for copying, distributing or modifying the Program or works based on it.
6. Each time you redistribute the Program (or any work based on the Program), the recipient automatically receives a license from the original licensor to copy, distribute or modify the Program subject to these terms and conditions. You may not impose any further restrictions on the recipients' exercise of the rights granted herein. You are not responsible for enforcing compliance by third parties to this License.
7. If, as a consequence of a court judgment or allegation of patent infringement or for any other reason (not limited to patent issues), 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 distribute so as to satisfy simultaneously your obligations under this License and any other pertinent obligations, then as a consequence you may not distribute the Program at all. For example, if a patent license would not permit royalty-free redistribution of the Program by all those who receive copies directly or indirectly through you, then the only way you could satisfy both it and this License would be to refrain entirely from distribution of the Program.
If any portion of this section is held invalid or unenforceable under any particular circumstance, the balance of the section is intended to apply and the section as a whole is intended to apply in other circumstances.
It is not the purpose of this section to induce you to infringe any patents or other property right claims or to contest validity of any such claims; this section has the sole purpose of protecting the integrity of the free software distribution system, which is implemented by public license practices. Many people have made generous contributions to the wide range of software distributed through that system in reliance on consistent application of that system; it is up to the author/donor to decide if he or she is willing to distribute software through any other system and a licensee cannot impose that choice.
This section is intended to make thoroughly clear what is believed to be a consequence of the rest of this License.
8. If the distribution and/or use of the Program is restricted in certain countries either by patents or by copyrighted interfaces, the original copyright holder who places the Program under this License may add an explicit geographical distribution limitation excluding those countries, so that distribution is permitted only in or among countries not thus excluded. In such case, this License incorporates the limitation as if written in the body of this License.
9. The Free Software Foundation may publish revised and/or new versions of the 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 a version number of this License which applies to it and "any later version", you have the option of following the terms and conditions either of that version or of any later version published by the Free Software Foundation. If the Program does not specify a version number of this License, you may choose any version ever published by the Free Software Foundation.
10. If you wish to incorporate parts of the Program into other free programs whose distribution conditions are different, write to the author to ask for permission. For software which is copyrighted by the Free Software Foundation, write to the Free Software Foundation; we sometimes make exceptions for this. Our decision will be guided by the two goals of preserving the free status of all derivatives of our free software and of promoting the sharing and reuse of software generally.
NO WARRANTY
11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, 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.
12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR REDISTRIBUTE 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.
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 convey 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 an idea of what it does. Copyright (C) yyyy 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 2 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, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. Also add information on how to contact you by electronic and paper mail.
If the program is interactive, make it output a short notice like this when it starts in an interactive mode:
Gnomovision version 69, Copyright (C) year name of author Gnomovision 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, the commands you use may be called something other than `show w' and `show c'; they could even be mouse-clicks or menu items--whatever suits your program.
You should also get your employer (if you work as a programmer) or your school, if any, to sign a "copyright disclaimer" for the program, if necessary. Here is a sample; alter the names:
Yoyodyne, Inc., hereby disclaims all copyright interest in the program `Gnomovision' (which makes passes at compilers) written by James Hacker.
signature of Ty Coon, 1 April 1989 Ty Coon, President of Vice
-232
View File
@@ -1,232 +0,0 @@
GNU GENERAL PUBLIC LICENSE
Version 3, 29 June 2007
Copyright © 2007 Free Software Foundation, Inc. <http://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 <http://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 <http://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 <http://www.gnu.org/philosophy/why-not-lgpl.html>.
-12
View File
@@ -1,12 +0,0 @@
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) at any later version that is
accepted by the membership of KDE e.V. (or its successor
approved by the membership of KDE e.V.), which shall act as a
proxy as defined in Section 14 of version 3 of the license.
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.
-6
View File
@@ -7,9 +7,3 @@ AudioTube is a client for YouTube Music.
It depends on Qt and Kirigami in addition to a few python packages:
* ytmusicapi
* youtube_dl
YouTube uses webp images for the cover art, so you will need to install qtimageformats.
# Troubleshooting
AudioTube only needs Python 3. If cmake still selects Python 2, you can pass `-DPYTHON_EXECUTABLE=/usr/bin/python3` to correct that.
-14
View File
@@ -1,14 +0,0 @@
{
"name": "python3-youtube_dl",
"buildsystem": "simple",
"build-commands": [
"pip3 install --verbose --exists-action=i --no-index --find-links=\"file://${PWD}\" --prefix=${FLATPAK_DEST} \"youtube_dl\" --no-build-isolation"
],
"sources": [
{
"type": "file",
"url": "https://files.pythonhosted.org/packages/94/a0/b8325b524700daae1c04a6156473ab7091d44071353f1d7c9e66b9c7f019/youtube_dl-2021.4.26.tar.gz",
"sha256": "6f311ffaf8b88cdcf27a2301a2272455e213bdb780aa447246933a3da4532879"
}
]
}
-39
View File
@@ -1,39 +0,0 @@
{
"name": "python3-ytmusicapi",
"buildsystem": "simple",
"build-commands": [
"pip3 install --verbose --exists-action=i --no-index --find-links=\"file://${PWD}\" --prefix=${FLATPAK_DEST} \"ytmusicapi\" --no-build-isolation"
],
"sources": [
{
"type": "file",
"url": "https://files.pythonhosted.org/packages/cb/cf/871177f1fc795c6c10787bc0e1f27bb6cf7b81dbde399fd35860472cecbc/urllib3-1.26.4.tar.gz",
"sha256": "e7b021f7241115872f92f43c6508082facffbd1c048e3c6e2bb9c2a157e28937"
},
{
"type": "file",
"url": "https://files.pythonhosted.org/packages/ea/b7/e0e3c1c467636186c39925827be42f16fee389dc404ac29e930e9136be70/idna-2.10.tar.gz",
"sha256": "b307872f855b18632ce0c21c5e45be78c0ea7ae4c15c828c20788b26921eb3f6"
},
{
"type": "file",
"url": "https://files.pythonhosted.org/packages/ee/2d/9cdc2b527e127b4c9db64b86647d567985940ac3698eeabc7ffaccb4ea61/chardet-4.0.0.tar.gz",
"sha256": "0d6f53a15db4120f2b08c94f11e7d93d2c911ee118b6b30a04ec3ee8310179fa"
},
{
"type": "file",
"url": "https://files.pythonhosted.org/packages/06/a9/cd1fd8ee13f73a4d4f491ee219deeeae20afefa914dfb4c130cfc9dc397a/certifi-2020.12.5.tar.gz",
"sha256": "1a4995114262bffbc2413b159f2a1a480c969de6e6eb13ee966d470af86af59c"
},
{
"type": "file",
"url": "https://files.pythonhosted.org/packages/6b/47/c14abc08432ab22dc18b9892252efaf005ab44066de871e72a38d6af464b/requests-2.25.1.tar.gz",
"sha256": "27973dd4a904a4f13b263a19c866c13b92a39ed1c964655f025f3f8d3d75b804"
},
{
"type": "file",
"url": "https://files.pythonhosted.org/packages/61/b5/da439d5f75db7ff17790b19136c835f9a315530436ee7bc9d75aeea2f6e5/ytmusicapi-0.16.0.tar.gz",
"sha256": "ffde3fb5a78123ac59dee37fc1f32793f34f9a4fa3d3e69a1fc08064112c2b5d"
}
]
}
-16
View File
@@ -1,16 +0,0 @@
#!/usr/bin/env bash
set -e
export GIT_CLONE_ARGS="--depth 1 --single-branch"
export FLATPAK_DIR="$(readlink -f $(dirname $0))"
cd ${FLATPAK_DIR}
if [ ! -d flatpak-builder-tools ]; then
git clone ${GIT_CLONE_ARGS} https://github.com/flatpak/flatpak-builder-tools
else
git -C flatpak-builder-tools pull
fi
./flatpak-builder-tools/pip/flatpak-pip-generator youtube_dl
./flatpak-builder-tools/pip/flatpak-pip-generator ytmusicapi
+12 -6
View File
@@ -1,12 +1,18 @@
<?xml version="1.0" encoding="utf-8"?>
<component type="desktop-application">
<id>org.kde.audiotube</id>
<name>AudioTube</name>
<summary>Convergent YouTube Music client</summary>
<metadata_license>CC0-1.0</metadata_license>
<project_license>GPL-2.0+</project_license>
<developer_name>KDE Community</developer_name>
<name>Kirigami Application</name>
<summary>A short summary describing what this software is about</summary>
<metadata_license>A permissive license for this metadata, e.g. "FSFAP"</metadata_license>
<project_license>The license of this software as SPDX string, e.g. "GPL-3+"</project_license>
<developer_name>The software vendor name, e.g. "ACME Corporation"</developer_name>
<description>
<p>AudioTube can search YouTube Music, list albums and artists, play automatically generated playlists, albums and allows to put your own playlist together.</p>
<p>Multiple paragraphs of long description, describing this software component.</p>
<p>You can also use ordered and unordered lists:</p>
<ul>
<li>Feature 1</li>
<li>Feature 2</li>
</ul>
<p>Keep in mind to XML-escape characters, and that this is not HTML markup.</p>
</description>
</component>
+3 -3
View File
@@ -1,9 +1,9 @@
[Desktop Entry]
Name=AudioTube
Comment=YouTube Music client
Comment=youtube_music Kirigami Application
Version=1.0
Exec=audiotube
Icon=org.kde.audiotube
Icon=applications-development
Type=Application
Terminal=false
Categories=Qt;KDE;AudioVideo;Player;
Categories=Qt;KDE;
-42
View File
@@ -1,42 +0,0 @@
{
"id": "org.kde.audiotube",
"runtime": "org.kde.Platform",
"runtime-version": "5.15",
"sdk": "org.kde.Sdk",
"command": "audiotube",
"tags": ["nightly"],
"desktop-file-name-suffix": " (Nightly)",
"finish-args": [
"--share=ipc",
"--share=network",
"--socket=x11",
"--socket=wayland",
"--socket=pulseaudio",
"--device=dri"
],
"separate-locales": false,
"cleanup": [
"/include/",
"/share/cmake/"
],
"modules": [
"flatpak/python3-youtube_dl.json",
"flatpak/python3-ytmusicapi.json",
{
"name": "pybind11",
"config-opts": ["-DPYBIND11_FINDPYTHON=ON", "-DPYBIND11_TEST=OFF"],
"buildsystem": "cmake-ninja",
"builddir": true,
"sources": [ { "type": "git", "url": "https://github.com/pybind/pybind11", "tag": "v2.6.2" } ]
},
{
"name": "org.kde.audiotube",
"config-opts": ["-DPYBIND11_FINDPYTHON=ON"],
"buildsystem": "cmake-ninja",
"builddir": true,
"sources": [ { "type": "dir", "path": ".", "skip": [".git"] } ]
}
]
}
-2
View File
@@ -1,2 +0,0 @@
ytmusicapi==0.16.0
youtube_dl
+2 -9
View File
@@ -1,12 +1,9 @@
add_subdirectory(mpris2)
add_library(ytm STATIC
ytmusic.cpp
)
target_link_libraries(ytm PUBLIC pybind11::embed)
target_include_directories(ytm PUBLIC ${CMAKE_CURRENT_SOURCE_DIR})
target_compile_definitions(ytm PRIVATE -DRANDALL_WAS_HERE)
add_subdirectory(example)
@@ -17,11 +14,7 @@ add_executable(audiotube
albummodel.cpp
videoinfoextractor.cpp
artistmodel.cpp
userplaylistmodel.cpp
playlistmodel.cpp
playlistutils.cpp
errorhandler.cpp
multiiterableview.h
resources.qrc
)
@@ -34,8 +27,8 @@ target_link_libraries(audiotube
Qt5::Svg
KF5::I18n
ytm
mpris2
)
target_compile_definitions(audiotube PRIVATE -DQT_NO_KEYWORDS -DQT_NO_URL_CAST_FROM_STRING)
target_compile_definitions(audiotube PRIVATE -DQT_NO_KEYWORDS)
install(TARGETS audiotube ${KDE_INSTALL_TARGETS_DEFAULT_ARGS})
+7 -18
View File
@@ -1,6 +1,6 @@
// SPDX-FileCopyrightText: 2021 Jonah Brüchert <[email protected]>
//
// SPDX-License-Identifier: GPL-2.0-only OR GPL-3.0-only OR LicenseRef-KDE-Accepted-GPL
// SPDX-License-Identifier: GPL-2.0-or-later
#include "albummodel.h"
@@ -11,9 +11,9 @@ AlbumModel::AlbumModel(QObject *parent)
{
connect(this, &AlbumModel::browseIdChanged, this, [=] {
setLoading(true);
YTMusicThread::instance()->fetchAlbum(m_browseId);
AsyncYTMusic::instance().fetchAlbum(m_browseId);
});
connect(&YTMusicThread::instance().get(), &AsyncYTMusic::fetchAlbumFinished, this, [=](const album::Album &album) {
connect(&AsyncYTMusic::instance(), &AsyncYTMusic::fetchAlbumFinished, this, [=](const album::Album &album) {
setLoading(false);
beginResetModel();
@@ -25,30 +25,20 @@ AlbumModel::AlbumModel(QObject *parent)
Q_EMIT thumbnailUrlChanged();
Q_EMIT playlistIdChanged();
});
connect(&YTMusicThread::instance().get(), &AsyncYTMusic::errorOccurred, this, [=] {
setLoading(false);
});
}
int AlbumModel::rowCount(const QModelIndex &parent) const
{
return parent.isValid() ? 0 : int(m_album.tracks.size());
return parent.isValid() ? 0 : m_album.tracks.size();
}
QVariant AlbumModel::data(const QModelIndex &index, int role) const
{
switch (role) {
case Title:
return QString::fromStdString(m_album.tracks[index.row()].title);
return QString::fromStdString(m_album.tracks.at(index.row()).title);
case VideoId:
return QString::fromStdString(m_album.tracks[index.row()].video_id.value_or(std::string()));
case Artists:
return QVariant::fromValue(std::vector<meta::Artist> {
{
m_album.tracks[index.row()].artists,
std::nullopt
}
});
return QString::fromStdString(m_album.tracks.at(index.row()).video_id.value_or(std::string()));
}
Q_UNREACHABLE();
@@ -60,8 +50,7 @@ QHash<int, QByteArray> AlbumModel::roleNames() const
{
return {
{Title, "title"},
{VideoId, "videoId"},
{Artists, "artists"}
{VideoId, "videoId"}
};
}
+3 -4
View File
@@ -1,6 +1,6 @@
// SPDX-FileCopyrightText: 2021 Jonah Brüchert <[email protected]>
//
// SPDX-License-Identifier: GPL-2.0-only OR GPL-3.0-only OR LicenseRef-KDE-Accepted-GPL
// SPDX-License-Identifier: GPL-2.0-or-later
#pragma once
@@ -22,8 +22,7 @@ class AlbumModel : public QAbstractListModel
public:
enum Role {
Title = Qt::UserRole + 1,
VideoId,
Artists
VideoId
};
explicit AlbumModel(QObject *parent = nullptr);
@@ -51,7 +50,7 @@ public:
private:
QString m_browseId;
bool m_loading = false;
bool m_loading;
album::Album m_album;
};
+90 -80
View File
@@ -1,11 +1,13 @@
// SPDX-FileCopyrightText: 2021 Jonah Brüchert <[email protected]>
//
// SPDX-License-Identifier: GPL-2.0-only OR GPL-3.0-only OR LicenseRef-KDE-Accepted-GPL
// SPDX-License-Identifier: GPL-2.0-or-later
#include "artistmodel.h"
#include <asyncytmusic.h>
#include <QDebug>
ArtistModel::ArtistModel(QObject *parent)
: QAbstractListModel(parent)
{
@@ -16,93 +18,93 @@ ArtistModel::ArtistModel(QObject *parent)
setLoading(true);
YTMusicThread::instance()->fetchArtist(m_channelId);
AsyncYTMusic::instance().fetchArtist(m_channelId);
});
connect(&YTMusicThread::instance().get(), &AsyncYTMusic::fetchArtistFinished, this, [=](const artist::Artist &artist) {
connect(&AsyncYTMusic::instance(), &AsyncYTMusic::fetchArtistFinished, this, [=](const artist::Artist &artist) {
setLoading(false);
beginResetModel();
m_artist = artist;
std::sort(m_artist.thumbnails.begin(), m_artist.thumbnails.end());
m_view = std::optional(MultiIterableView(m_artist.albums->results,
m_artist.singles->results,
m_artist.songs->results,
m_artist.videos->results));
endResetModel();
Q_EMIT titleChanged();
Q_EMIT thumbnailUrlChanged();
});
connect(&YTMusicThread::instance().get(), &AsyncYTMusic::errorOccurred, this, [=] {
setLoading(false);
});
}
template <typename T>
int countItems(const std::optional<artist::Artist::Section<T>> &section) {
if (!section.has_value()) {
return 0;
}
return section.value().results.size();
};
int ArtistModel::rowCount(const QModelIndex &parent) const
{
return parent.isValid() ? 0 : m_view ? int(m_view->size()) : 0;
return parent.isValid() ? 0 : countItems(m_artist.songs)
+ countItems(m_artist.albums)
+ countItems(m_artist.singles)
+ countItems(m_artist.videos);
}
QVariant ArtistModel::data(const QModelIndex &index, int role) const
{
if (!m_view) {
return {};
}
switch (role) {
case Title:
return QString::fromStdString(std::visit([&](auto&& item) {
using T = std::decay_t<decltype(item)>;
if constexpr(std::is_same_v<T, artist::Artist::Album>) {
return item.title;
} else if constexpr(std::is_same_v<T, artist::Artist::Single>) {
return item.title;
} else if constexpr(std::is_same_v<T, artist::Artist::Song>) {
return item.title;
} else if constexpr(std::is_same_v<T, artist::Artist::Video>) {
return item.title;
}
if (index.row() >= countItems(m_artist.songs)
+ countItems(m_artist.albums)
+ countItems(m_artist.singles)) {
Q_UNREACHABLE();
}, m_view.value()[index.row()]));
int videoIndex = index.row() - (countItems(m_artist.songs)
+ countItems(m_artist.albums)
+ countItems(m_artist.singles));
if (m_artist.videos.has_value()) {
return QString::fromStdString(m_artist.videos.value().results[videoIndex].title);
}
break;
} else if (index.row() >= countItems(m_artist.songs) + countItems(m_artist.albums)) {
int singleIndex = index.row() - (countItems(m_artist.songs) + countItems(m_artist.albums));
if (m_artist.singles.has_value()) {
return QString::fromStdString(m_artist.singles.value().results[singleIndex].title);
}
break;
} else if (index.row() >= countItems(m_artist.songs)) {
int albumIndex = index.row() - countItems(m_artist.songs);
if (m_artist.albums.has_value()) {
return QString::fromStdString(m_artist.albums.value().results[albumIndex].title);
}
break;
} else {
return QString::fromStdString(m_artist.songs.value().results[index.row()].title);
}
case Type:
return std::visit([&](auto&& item) {
using T = std::decay_t<decltype(item)>;
if constexpr(std::is_same_v<T, artist::Artist::Album>) {
return Type::Album;
} else if constexpr(std::is_same_v<T, artist::Artist::Single>) {
return Type::Single;
} else if constexpr(std::is_same_v<T, artist::Artist::Song>) {
return Type::Song;
} else if constexpr(std::is_same_v<T, artist::Artist::Video>) {
return Type::Video;
}
if (index.row() >= countItems(m_artist.songs)
+ countItems(m_artist.albums)
+ countItems(m_artist.singles)) {
Q_UNREACHABLE();
}, m_view.value()[index.row()]);
case Artists:
return QVariant::fromValue(std::vector<meta::Artist> {
{
m_artist.name,
m_artist.channel_id
if (m_artist.videos.has_value()) {
return Video;
}
});
case VideoId:
return std::visit([&](auto&& item) {
using T = std::decay_t<decltype(item)>;
if constexpr(std::is_same_v<T, artist::Artist::Album>) {
return QVariant();
} else if constexpr(std::is_same_v<T, artist::Artist::Single>) {
return QVariant();
} else if constexpr(std::is_same_v<T, artist::Artist::Song>) {
return QVariant(QString::fromStdString(item.video_id));
} else if constexpr(std::is_same_v<T, artist::Artist::Video>) {
return QVariant(QString::fromStdString(item.video_id));
break;
} else if (index.row() >= countItems(m_artist.songs) + countItems(m_artist.albums)) {
if (m_artist.singles.has_value()) {
return Single;
}
Q_UNREACHABLE();
}, m_view.value()[index.row()]);
break;
} else if (index.row() >= countItems(m_artist.songs)) {
if (m_artist.albums.has_value()) {
return Album;
}
break;
} else {
return Song;
}
}
Q_UNREACHABLE();
@@ -114,9 +116,7 @@ QHash<int, QByteArray> ArtistModel::roleNames() const
{
return {
{Title, "title"},
{Type, "type"},
{Artists, "artists"},
{VideoId, "videoId"}
{Type, "type"}
};
}
@@ -158,20 +158,30 @@ void ArtistModel::setLoading(bool loading)
void ArtistModel::triggerItem(int row)
{
if (m_view) {
std::visit([&](auto&& item) {
using T = std::decay_t<decltype(item)>;
if constexpr(std::is_same_v<T, artist::Artist::Album>) {
Q_EMIT openAlbum(QString::fromStdString(item.browse_id));
} else if constexpr(std::is_same_v<T, artist::Artist::Single>) {
Q_EMIT openAlbum(QString::fromStdString(item.browse_id));
} else if constexpr(std::is_same_v<T, artist::Artist::Song>) {
Q_EMIT openSong(QString::fromStdString(item.video_id));
} else if constexpr(std::is_same_v<T, artist::Artist::Video>) {
Q_EMIT openVideo(QString::fromStdString(item.video_id));
} else {
Q_UNREACHABLE();
}
}, m_view.value()[row]);
if (row >= countItems(m_artist.songs)
+ countItems(m_artist.albums)
+ countItems(m_artist.singles)) {
int videoIndex = row - (countItems(m_artist.songs)
+ countItems(m_artist.albums)
+ countItems(m_artist.singles));
if (m_artist.videos.has_value()) {
Q_EMIT openVideo(QString::fromStdString(m_artist.videos.value().results[videoIndex].video_id));
}
} else if (row >= countItems(m_artist.songs) + countItems(m_artist.albums)) {
int singleIndex = row - (countItems(m_artist.songs) + countItems(m_artist.albums));
if (m_artist.singles.has_value()) {
Q_EMIT openAlbum(QString::fromStdString(m_artist.singles.value().results[singleIndex].browse_id));
}
} else if (row >= countItems(m_artist.songs)) {
int albumIndex = row - countItems(m_artist.songs);
if (m_artist.albums.has_value()) {
Q_EMIT openAlbum(QString::fromStdString(m_artist.albums.value().results[albumIndex].browseId));
}
} else {
Q_EMIT openSong(QString::fromStdString(m_artist.songs.value().results[row].video_id));
}
}
+2 -10
View File
@@ -1,16 +1,13 @@
// SPDX-FileCopyrightText: 2021 Jonah Brüchert <[email protected]>
//
// SPDX-License-Identifier: GPL-2.0-only OR GPL-3.0-only OR LicenseRef-KDE-Accepted-GPL
// SPDX-License-Identifier: LGPL-2.0-or-later
#pragma once
#include <QAbstractListModel>
#include <QUrl>
#include <optional>
#include <ytmusic.h>
#include "multiiterableview.h"
class ArtistModel : public QAbstractListModel
{
@@ -33,9 +30,7 @@ public:
enum Role {
Title,
Type,
Artists,
VideoId
Type
};
explicit ArtistModel(QObject *parent = nullptr);
@@ -69,7 +64,4 @@ private:
bool m_loading = false;
artist::Artist m_artist;
std::optional<MultiIterableView<
artist::Artist::Album, artist::Artist::Single, artist::Artist::Song, artist::Artist::Video
>> m_view;
};
+48 -90
View File
@@ -1,26 +1,22 @@
// SPDX-FileCopyrightText: 2021 Jonah Brüchert <[email protected]>
//
// SPDX-License-Identifier: GPL-2.0-only OR GPL-3.0-only OR LicenseRef-KDE-Accepted-GPL
// SPDX-License-Identifier: GPL-2.0-or-later
#include "asyncytmusic.h"
#include <QThread>
#include <exception>
#include <QDebug>
#include <pybind11/embed.h>
#include <iostream>
namespace py = pybind11;
template <typename R, typename T, typename OP>
std::optional<R> map_optional(const std::optional<T> &optional, OP op) {
if (optional.has_value()) {
return op(optional.value());
}
return std::nullopt;
}
static QThread *ytmthread = []() -> QThread * {
auto *thread = new QThread();
thread->setObjectName("YTMusicAPI");
return thread;
}();
AsyncYTMusic::AsyncYTMusic(QObject *parent)
: QObject(parent)
@@ -34,8 +30,6 @@ AsyncYTMusic::AsyncYTMusic(QObject *parent)
qRegisterMetaType<video_info::VideoInfo>();
qRegisterMetaType<watch::Playlist>();
qRegisterMetaType<std::optional<QString>>();
qRegisterMetaType<std::vector<meta::Artist>>();
qRegisterMetaType<meta::Artist>();
connect(this, &AsyncYTMusic::startSearch, this, &AsyncYTMusic::internalSearch);
connect(this, &AsyncYTMusic::startFetchArtist, this, &AsyncYTMusic::internalFetchArtist);
@@ -45,10 +39,25 @@ AsyncYTMusic::AsyncYTMusic(QObject *parent)
connect(this, &AsyncYTMusic::startFetchArtistAlbums, this, &AsyncYTMusic::internalFetchArtistAlbums);
connect(this, &AsyncYTMusic::startExtractVideoInfo, this, &AsyncYTMusic::internalExtractVideoInfo);
connect(this, &AsyncYTMusic::startFetchWatchPlaylist, this, &AsyncYTMusic::internalFetchWatchPlaylist);
}
connect(this, &AsyncYTMusic::errorOccurred, this, [](const QString &err) {
std::cerr << qPrintable(err);
});
AsyncYTMusic &AsyncYTMusic::instance()
{
static AsyncYTMusic &inst = []() -> AsyncYTMusic& {
static AsyncYTMusic ytm;
ytm.moveToThread(ytmthread);
ytmthread->start();
return ytm;
}();
return inst;
}
void AsyncYTMusic::stopInstance()
{
ytmthread->quit();
ytmthread->wait();
}
//
@@ -61,11 +70,7 @@ void AsyncYTMusic::search(const QString &query)
void AsyncYTMusic::internalSearch(const QString &query)
{
try {
Q_EMIT searchFinished(m_ytm->search(query.toStdString()));
} catch (const py::error_already_set &err) {
Q_EMIT errorOccurred(QString::fromLocal8Bit(err.what()));
}
Q_EMIT searchFinished(m_ytdl.search(query.toStdString()));
}
//
@@ -78,11 +83,7 @@ void AsyncYTMusic::fetchArtist(const QString &channelId)
void AsyncYTMusic::internalFetchArtist(const QString &channelId)
{
try {
Q_EMIT fetchArtistFinished(m_ytm->get_artist(channelId.toStdString()));
} catch (const py::error_already_set &err) {
Q_EMIT errorOccurred(QString::fromLocal8Bit(err.what()));
}
Q_EMIT fetchArtistFinished(m_ytdl.get_artist(channelId.toStdString()));
}
//
@@ -95,11 +96,7 @@ void AsyncYTMusic::fetchAlbum(const QString &browseId)
void AsyncYTMusic::internalFetchAlbum(const QString &browseId)
{
try {
Q_EMIT fetchAlbumFinished(m_ytm->get_album(browseId.toStdString()));
} catch (const py::error_already_set &err) {
Q_EMIT errorOccurred(QString::fromLocal8Bit(err.what()));
}
Q_EMIT fetchAlbumFinished(m_ytdl.get_album(browseId.toStdString()));
}
//
@@ -112,11 +109,7 @@ void AsyncYTMusic::fetchSong(const QString &videoId)
void AsyncYTMusic::internalFetchSong(const QString &videoId)
{
try {
Q_EMIT fetchSongFinished(m_ytm->get_song(videoId.toStdString()));
} catch (const py::error_already_set &err) {
Q_EMIT errorOccurred(QString::fromLocal8Bit(err.what()));
}
Q_EMIT fetchSongFinished(m_ytdl.get_song(videoId.toStdString()));
}
//
@@ -128,11 +121,7 @@ void AsyncYTMusic::fetchPlaylist(const QString &playlistId) {
void AsyncYTMusic::internalFetchPlaylist(const QString &playlistId)
{
try {
Q_EMIT fetchPlaylistFinished(m_ytm->get_playlist(playlistId.toStdString()));
} catch (const py::error_already_set &err) {
Q_EMIT errorOccurred(QString::fromLocal8Bit(err.what()));
}
Q_EMIT fetchPlaylistFinished(m_ytdl.get_playlist(playlistId.toStdString()));
}
//
@@ -145,28 +134,19 @@ void AsyncYTMusic::fetchArtistAlbums(const QString &channelId, const QString &pa
void AsyncYTMusic::internalFetchArtistAlbums(const QString &channelid, const QString &params)
{
try {
Q_EMIT fetchArtistAlbumsFinished(m_ytm->get_artist_albums(channelid.toStdString(), params.toStdString()));
} catch (const py::error_already_set &err) {
Q_EMIT errorOccurred(QString::fromLocal8Bit(err.what()));
}
Q_EMIT fetchArtistAlbumsFinished(m_ytdl.get_artist_albums(channelid.toStdString(), params.toStdString()));
}
//
// extractVideoInfo
//
void AsyncYTMusic::extractVideoInfo(const QString &videoId)
{
void AsyncYTMusic::extractVideoInfo(const QString &videoId) {
qDebug() << "extract video " << videoId;
Q_EMIT startExtractVideoInfo(videoId);
}
void AsyncYTMusic::internalExtractVideoInfo(const QString &videoId)
{
try {
Q_EMIT extractVideoInfoFinished(m_ytm->extract_video_info(videoId.toStdString()));
} catch (const py::error_already_set &err) {
Q_EMIT errorOccurred(QString::fromLocal8Bit(err.what()));
}
void AsyncYTMusic::internalExtractVideoInfo(const QString &videoId) {
Q_EMIT extractVideoInfoFinished(m_ytdl.extract_video_info(videoId.toStdString()));
}
//
@@ -179,41 +159,19 @@ void AsyncYTMusic::fetchWatchPlaylist(const std::optional<QString> &videoId, con
void AsyncYTMusic::internalFetchWatchPlaylist(const std::optional<QString> &videoId, const std::optional<QString> &playlistId)
{
try {
Q_EMIT fetchWatchPlaylistFinished(m_ytm->get_watch_playlist(
map_optional<std::string>(videoId, [](const QString &value) { return value.toStdString(); }),
map_optional<std::string>(playlistId, [](const QString &value) { return value.toStdString(); })
));
} catch (const py::error_already_set &err) {
Q_EMIT errorOccurred(QString::fromLocal8Bit(err.what()));
}
}
Q_EMIT fetchWatchPlaylistFinished(m_ytdl.get_watch_playlist(
[&]() -> std::optional<std::string> {
if (!videoId.has_value()) {
return std::nullopt;
}
YTMusicThread &YTMusicThread::instance()
{
static YTMusicThread thread;
return thread;
}
return videoId->toStdString();
}(),
[&]() -> std::optional<std::string> {
if (!playlistId.has_value()) {
return std::nullopt;
}
YTMusicThread::~YTMusicThread()
{
quit();
wait();
}
AsyncYTMusic *YTMusicThread::operator->()
{
return &m_ytm;
}
AsyncYTMusic &YTMusicThread::get()
{
return m_ytm;
}
YTMusicThread::YTMusicThread()
{
setObjectName(QStringLiteral("YTMusicAPI"));
m_ytm.moveToThread(this);
start();
return playlistId->toStdString();
}()));
}
+13 -45
View File
@@ -1,6 +1,6 @@
// SPDX-FileCopyrightText: 2021 Jonah Brüchert <[email protected]>
//
// SPDX-License-Identifier: GPL-2.0-only OR GPL-3.0-only OR LicenseRef-KDE-Accepted-GPL
// SPDX-License-Identifier: GPL-2.0-or-later
#pragma once
@@ -20,37 +20,23 @@ Q_DECLARE_METATYPE(playlist::Playlist)
Q_DECLARE_METATYPE(video_info::VideoInfo)
Q_DECLARE_METATYPE(watch::Playlist)
Q_DECLARE_METATYPE(std::optional<QString>)
Q_DECLARE_METATYPE(std::vector<meta::Artist>)
Q_DECLARE_METATYPE(meta::Artist)
///
/// Lazy initialized unique_ptr
///
template <typename T>
class Lazy {
public:
T *operator->() {
return get().operator->();
}
inline std::unique_ptr<T> &get() {
if (!m_item) {
m_item = std::make_unique<T>();
}
return m_item;
}
private:
std::unique_ptr<T> m_item = nullptr;
};
class AsyncYTMusic : public QObject
{
friend class YTMusicThread;
Q_OBJECT
public:
explicit AsyncYTMusic(QObject *parent = nullptr);
///
/// Singleton instance of AsyncYtMusic running on it's own thread.
///
/// It is necessary t call stopInstance before the application exits,
/// so the thread can properly finish.
///
static AsyncYTMusic &instance();
static void stopInstance();
// public functions need to be thread safe
void search(const QString &query);
Q_SIGNAL void searchFinished(std::vector<search::SearchResultItem>);
@@ -79,9 +65,6 @@ public:
Q_SIGNAL void errorOccurred(const QString &error);
protected:
explicit AsyncYTMusic(QObject *parent = nullptr);
private:
Q_SIGNAL void startSearch(const QString &query);
Q_SLOT void internalSearch(const QString &query);
@@ -107,20 +90,5 @@ private:
Q_SIGNAL void startFetchWatchPlaylist(const std::optional<QString> &videoId, const std::optional<QString> &playlistId);
Q_SLOT void internalFetchWatchPlaylist(const std::optional<QString> &videoId, const std::optional<QString> &playlistId);
// Python interpreter will be ininitalized from the thread calling the methods
Lazy<YTMusic> m_ytm;
};
class YTMusicThread : private QThread {
public:
static YTMusicThread &instance();
~YTMusicThread();
AsyncYTMusic *operator->();
AsyncYTMusic &get();
private:
YTMusicThread();
AsyncYTMusic m_ytm;
YTMusic m_ytdl;
};
+3 -35
View File
@@ -1,7 +1,3 @@
// SPDX-FileCopyrightText: 2021 Jonah Brüchert <[email protected]>
//
// SPDX-License-Identifier: GPL-2.0-only OR GPL-3.0-only OR LicenseRef-KDE-Accepted-GPL
import QtQuick 2.1
import org.kde.kirigami 2.14 as Kirigami
import QtQuick.Controls 2.14 as Controls
@@ -32,40 +28,12 @@ Kirigami.ScrollablePage {
model: AlbumModel {
id: albumModel
}
delegate: Kirigami.SwipeListItem {
id: delegateItem
delegate: Kirigami.BasicListItem {
required property string title
required property string videoId
required property var artists
RowLayout {
Layout.fillHeight: true
Kirigami.Icon {
Layout.fillHeight: true
source: "emblem-music-symbolic"
}
Controls.Label {
Layout.fillWidth: true
text: title
elide: Qt.ElideRight
}
}
actions: [
Kirigami.Action {
icon.name: "go-next"
text: i18n("Play next")
onTriggered: UserPlaylistModel.playNext(delegateItem.videoId, delegateItem.title, delegateItem.artists)
},
Kirigami.Action {
icon.name: "media-playlist-append"
text: i18n("Add to playlist")
onTriggered: UserPlaylistModel.append(delegateItem.videoId, delegateItem.title, delegateItem.artists)
}
]
icon: "emblem-music-symbolic"
text: title
onClicked: play(videoId)
}
+12 -47
View File
@@ -1,7 +1,3 @@
// SPDX-FileCopyrightText: 2021 Jonah Brüchert <[email protected]>
//
// SPDX-License-Identifier: GPL-2.0-only OR GPL-3.0-only OR LicenseRef-KDE-Accepted-GPL
import QtQuick 2.1
import org.kde.kirigami 2.14 as Kirigami
import QtQuick.Controls 2.14 as Controls
@@ -33,7 +29,7 @@ Kirigami.ScrollablePage {
}
onOpenVideo: (videoId) => {
askPlayVideoAudio(videoId)
}
}
section.property: "type"
@@ -51,54 +47,23 @@ Kirigami.ScrollablePage {
}
}
}
delegate: Kirigami.SwipeListItem {
id: delegateItem
delegate: Kirigami.BasicListItem {
required property string title
required property int type
required property int index
required property var artists
required property string videoId
RowLayout {
Layout.fillHeight: true
Kirigami.Icon {
Layout.fillHeight: true
source: {
switch (type) {
case ArtistModel.Album:
return "media-album-cover"
case ArtistModel.Single:
case ArtistModel.Song:
return "emblem-music-symbolic"
case ArtistModel.Video:
return "emblem-videos-symbolic"
}
}
}
Controls.Label {
Layout.fillWidth: true
text: title
elide: Qt.ElideRight
text: title
icon: {
switch (type) {
case ArtistModel.Album:
return "media-album-cover"
case ArtistModel.Single:
case ArtistModel.Song:
return "emblem-music-symbolic"
case ArtistModel.Video:
return "emblem-videos-symbolic"
}
}
actions: [
Kirigami.Action {
icon.name: "go-next"
text: i18n("Play next")
visible: type === ArtistModel.Song
onTriggered: UserPlaylistModel.playNext(delegateItem.videoId, delegateItem.title, delegateItem.artists)
},
Kirigami.Action {
icon.name: "media-playlist-append"
text: i18n("Add to playlist")
visible: type === ArtistModel.Song
onTriggered: UserPlaylistModel.append(delegateItem.videoId, delegateItem.title, delegateItem.artists)
}
]
onClicked: artistModel.triggerItem(index)
}
+72 -118
View File
@@ -1,126 +1,81 @@
// SPDX-FileCopyrightText: 2021 Jonah Brüchert <[email protected]>
//
// SPDX-License-Identifier: GPL-2.0-only OR GPL-3.0-only OR LicenseRef-KDE-Accepted-GPL
import QtQuick 2.7
import QtQuick.Layouts 1.3
import QtQuick.Controls 2.12 as Controls
import org.kde.kirigami 2.12 as Kirigami
import org.kde.ytmusic 1.0
import QtMultimedia 5.12
ColumnLayout {
id: footerLayout
// input only
property alias videoId: playlistModel.initialVideoId
property alias playlistId: playlistModel.playlistId
property bool maximized: false
anchors.left: parent.left
anchors.right: parent.right
height: maximized ? applicationWindow().height : player.preferredHeight
GridLayout {
id: playerLayout
readonly property bool mobile: width > height
Image {
Layout.fillWidth: true
Layout.fillHeight: true
source: info.thumbnail
}
Controls.ScrollView {
Layout.fillHeight: footerLayout.maximized
Layout.fillWidth: true
flow: width > height ? GridLayout.LeftToRight : GridLayout.TopToBottom
visible: footerLayout.maximized
Item {
Layout.fillWidth: true
Layout.fillHeight: true
Image {
anchors.fill: parent
ListView {
id: playlistView
anchors.fill: parent
source: info.thumbnail
fillMode: Image.PreserveAspectFit
model: PlaylistModel {
id: playlistModel
}
}
delegate: Kirigami.BasicListItem {
required property string title
required property string videoId
required property string artists
required property bool isCurrent
Item {
Layout.fillWidth: true
Layout.fillHeight: true
highlighted: isCurrent
Controls.ScrollView {
anchors.fill: parent
onClicked: playlistModel.skipTo(videoId)
ListView {
ColumnLayout {
anchors.fill: parent
id: playlistView
clip: true
Kirigami.Heading {
Layout.fillWidth: true
Controls.BusyIndicator {
anchors.centerIn: parent
visible: UserPlaylistModel.loading || UserPlaylistModel.loading
level: 2
text: title
}
Controls.Label {
Layout.fillWidth: true
onCountChanged: {
if (count < 1) {
footerLayout.maximized = false
}
}
model: UserPlaylistModel
delegate: Kirigami.SwipeListItem {
id: delegateItem
required property string title
required property string videoId
required property string artists
required property bool isCurrent
highlighted: isCurrent
onClicked: UserPlaylistModel.skipTo(videoId)
ColumnLayout {
Layout.fillWidth: true
Kirigami.Heading {
elide: Text.ElideRight
Layout.fillWidth: true
level: 2
text: title
}
Controls.Label {
elide: Text.ElideRight
Layout.fillWidth: true
text: artists
}
}
actions: [
Kirigami.Action {
text: i18n("Remove track")
icon.name: "list-remove"
onTriggered: UserPlaylistModel.remove(delegateItem.videoId)
}
]
}
header: Controls.ToolBar {
anchors.left: parent.left
anchors.right: parent.right
RowLayout {
anchors.fill: parent
Item {
Layout.fillWidth: true
}
Controls.ToolButton {
icon.name: "edit-clear-all"
onClicked: UserPlaylistModel.clear()
}
Controls.ToolButton {
icon.name: "media-playlist-shuffle"
onClicked: UserPlaylistModel.shufflePlaylist()
}
}
text: artists
}
}
}
Controls.BusyIndicator {
anchors.centerIn: parent
visible: playlistModel.loading || playlistModel.loading
}
}
}
Behavior on height {
NumberAnimation {
}
}
@@ -136,19 +91,19 @@ ColumnLayout {
VideoInfoExtractor {
id: info
onSongChanged: audio.play()
videoId: UserPlaylistModel.currentVideoId
videoId: playlistModel.currentVideoId
}
Audio {
id: audio
source: info.audioUrl
onStatusChanged: {
if (status === Audio.EndOfMedia) {
console.log("Song ended");
UserPlaylistModel.next();
console.log("Song ended")
playlistModel.next()
}
}
}
@@ -157,9 +112,13 @@ ColumnLayout {
display: Controls.AbstractButton.IconOnly
Layout.preferredWidth: parent.height
Layout.fillHeight: true
enabled: info.audioUrl != ""
text: audio.playbackState === Audio.PlayingState ? i18n("Pause") : i18n("Play")
text: audio.playbackState === Audio.PlayingState ? i18n("Pause") : i18n("Play")
visible: !info.loading
icon.name: audio.playbackState === Audio.PlayingState ? "media-playback-pause" : "media-playback-start"
onClicked: audio.playbackState === Audio.PlayingState ? audio.pause() : audio.play()
}
@@ -168,10 +127,13 @@ ColumnLayout {
display: Controls.AbstractButton.IconOnly
Layout.preferredWidth: parent.height
Layout.fillHeight: true
enabled: UserPlaylistModel.canSkip
enabled: playlistView.count > 1
visible: !info.loading
icon.name: "media-skip-forward"
onClicked: UserPlaylistModel.next()
onClicked: playlistModel.next()
}
Controls.BusyIndicator {
@@ -181,53 +143,45 @@ ColumnLayout {
ColumnLayout {
Layout.fillHeight: true
Layout.topMargin: Kirigami.Units.smallSpacing
Layout.bottomMargin: Kirigami.Units.smallSpacing
Layout.topMargin: Kirigami.Units.largeSpacing
Layout.bottomMargin: Kirigami.Units.largeSpacing
Kirigami.Heading {
level: 3
Layout.fillWidth: true
elide: Qt.ElideRight
level: 2
text: info.title ? info.title : i18n("No media playing")
}
Controls.Slider {
Layout.fillWidth: true
from: 0
to: audio.duration
value: audio.position
enabled: audio.seekable
onMoved: {
console.log("Value:", value);
audio.seek(Math.floor(value));
console.log("Value:", value)
audio.seek(Math.floor(value))
}
Behavior on value {
NumberAnimation {
}
}
}
}
Controls.ToolButton {
display: Controls.AbstractButton.IconOnly
Layout.preferredWidth: parent.height
text: i18n("Expand")
enabled: playlistView.count > 0
Layout.fillHeight: true
icon.name: footerLayout.maximized ? "arrow-down" : "arrow-up"
onClicked: footerLayout.maximized = !footerLayout.maximized
icon.name: footer.maximized ? "arrow-down" : "arrow-up"
onClicked: footer.maximized = !footer.maximized
}
}
Behavior on height {
NumberAnimation {
}
}
}
-80
View File
@@ -1,80 +0,0 @@
// SPDX-FileCopyrightText: 2021 Jonah Brüchert <[email protected]>
//
// SPDX-License-Identifier: GPL-2.0-only OR GPL-3.0-only OR LicenseRef-KDE-Accepted-GPL
import QtQuick 2.0
import QtQuick.Layouts 1.12
import QtQuick.Controls 2.12 as Controls
import org.kde.kirigami 2.12 as Kirigami
import org.kde.ytmusic 1.0
Kirigami.ScrollablePage {
property alias playlistId: playlistModel.playlistId
title: playlistModel.title
actions {
main: Kirigami.Action {
icon.name: "media-playback-start"
text: i18n("Play")
onTriggered: {
applicationWindow().playPlaylist(playlistModel.playlistId)
}
}
right: Kirigami.Action {
icon.name: "media-playlist-shuffle"
text: i18n("Shuffle")
onTriggered: {
applicationWindow().playShufflePlaylist(playlistModel.playlistId)
}
}
}
ListView {
header: Kirigami.ItemViewHeader {
backgroundImage.source: playlistModel.thumbnailUrl
title: playlistModel.title
}
model: PlaylistModel {
id: playlistModel
}
delegate: Kirigami.SwipeListItem {
id: delegateItem
required property string title
required property string videoId
required property string artists
RowLayout {
Layout.fillHeight: true
Kirigami.Icon {
Layout.fillHeight: true
source: "emblem-music-symbolic"
}
Controls.Label {
Layout.fillWidth: true
text: title
elide: Qt.ElideRight
}
}
actions: [
Kirigami.Action {
icon.name: "go-next"
text: i18n("Play next")
onTriggered: UserPlaylistModel.playNext(delegateItem.videoId, delegateItem.title, delegateItem.artists)
},
Kirigami.Action {
icon.name: "media-playlist-append"
text: i18n("Add to playlist")
onTriggered: UserPlaylistModel.append(delegateItem.videoId, delegateItem.title, delegateItem.artists)
}
]
}
Controls.BusyIndicator {
anchors.centerIn: parent
visible: playlistModel.loading
}
}
}
-113
View File
@@ -1,113 +0,0 @@
// SPDX-FileCopyrightText: 2021 Jonah Brüchert <[email protected]>
//
// SPDX-License-Identifier: GPL-2.0-only OR GPL-3.0-only OR LicenseRef-KDE-Accepted-GPL
import QtQuick 2.0
import QtQuick.Layouts 1.3
import QtQuick.Controls 2.14 as Controls
import org.kde.kirigami 2.14 as Kirigami
import org.kde.ytmusic 1.0
Kirigami.ScrollablePage {
title: i18n("Youtube Music")
header: Controls.Control {
padding: Kirigami.Units.largeSpacing
contentItem: Kirigami.SearchField {
delaySearch: true
selectByMouse: true
onAccepted: {
searchModel.searchQuery = text
}
}
}
ListView {
model: SearchModel {
id: searchModel
onOpenAlbum: (browseId) => {
pageStack.push("qrc:/AlbumPage.qml", {
"browseId": browseId
})
}
onOpenArtist: (channelId) => {
pageStack.push("qrc:/ArtistPage.qml", {
"channelId": channelId
})
}
onOpenPlaylist: (browseId) => {
pageStack.push("qrc:/PlaylistPage.qml", {
"playlistId": browseId
})
}
onOpenSong: (videoId) => {
play(videoId)
}
onOpenVideo: (videoId) => {
askPlayVideoAudio(videoId)
}
}
delegate: Kirigami.SwipeListItem {
id: delegateItem
required property int index
required property string title
required property int type
required property string videoId
required property var artists
RowLayout {
Layout.fillHeight: true
Kirigami.Icon {
Layout.fillHeight: true
source: {
switch (type) {
case SearchModel.Artist:
return "view-media-artist"
case SearchModel.Album:
return "media-album-cover"
case SearchModel.Playlist:
return "view-media-playlist"
case SearchModel.Song:
return "emblem-music-symbolic"
case SearchModel.Video:
return "emblem-videos-symbolic"
}
}
}
Controls.Label {
Layout.fillWidth: true
text: title
elide: Qt.ElideRight
}
}
actions: [
Kirigami.Action {
icon.name: "go-next"
text: i18n("Play next")
visible: delegateItem.type === SearchModel.Song
onTriggered: UserPlaylistModel.playNext(delegateItem.videoId, delegateItem.title, delegateItem.artists)
},
Kirigami.Action {
icon.name: "media-playlist-append"
text: i18n("Add to playlist")
visible: delegateItem.type === SearchModel.Song
onTriggered: UserPlaylistModel.append(delegateItem.videoId, delegateItem.title, delegateItem.artists)
}
]
onClicked: searchModel.triggerItem(index)
}
Controls.BusyIndicator {
anchors.centerIn: parent
visible: searchModel.loading
}
}
}
+73 -31
View File
@@ -1,9 +1,7 @@
// SPDX-FileCopyrightText: 2021 Jonah Brüchert <[email protected]>
//
// SPDX-License-Identifier: GPL-2.0-only OR GPL-3.0-only OR LicenseRef-KDE-Accepted-GPL
import QtQuick 2.1
import org.kde.kirigami 2.14 as Kirigami
import QtQuick.Controls 2.14 as Controls
import QtQuick.Layouts 1.3
import org.kde.ytmusic 1.0
@@ -12,42 +10,86 @@ Kirigami.ApplicationWindow {
title: i18n("AudioTube")
controlsVisible: !footer.maximized
contextDrawer: Kirigami.ContextDrawer {
id: contextDrawer
}
pageStack.initialPage: "qrc:/SearchPage.qml"
pageStack.initialPage: Kirigami.ScrollablePage {
title: i18n("Youtube Music")
header: Controls.Control {
padding: Kirigami.Units.largeSpacing
contentItem: Kirigami.SearchField {
onAccepted: {
searchModel.searchQuery = text
}
}
}
ListView {
model: SearchModel {
id: searchModel
onOpenAlbum: (browseId) => {
pageStack.push("qrc:/AlbumPage.qml", {
"browseId": browseId
})
}
onOpenArtist: (channelId) => {
pageStack.push("qrc:/ArtistPage.qml", {
"channelId": channelId
})
}
onOpenPlaylist: (browseId) => {
}
onOpenSong: (videoId) => {
play(videoId)
}
onOpenVideo: (videoId) => {
}
}
delegate: Kirigami.BasicListItem {
required property int index
required property string title
required property int type
text: title
icon: {
switch (type) {
case SearchModel.Artist:
return "view-media-artist"
case SearchModel.Album:
return "media-album-cover"
case SearchModel.Playlist:
return "view-media-playlist"
case SearchModel.Song:
return "emblem-music-symbolic"
case SearchModel.Video:
return "emblem-videos-symbolic"
}
}
onClicked: searchModel.triggerItem(index)
}
Controls.BusyIndicator {
anchors.centerIn: parent
visible: searchModel.loading
}
}
}
function play(videoId) {
UserPlaylistModel.initialVideoId = videoId
footer.videoId = videoId
}
function playPlaylist(playlistId) {
UserPlaylistModel.playlistId = playlistId
}
function playShufflePlaylist(playlistId) {
UserPlaylistModel.shuffle = true
UserPlaylistModel.playlistId = playlistId
}
function askPlayVideoAudio(videoId) {
showPassiveNotification(i18n("Video playback is not supported yet."),
"long",
i18n("Play only audio"),
function() {
play(videoId)
})
}
Connections {
target: ErrorHandler
function onErrorOccurred(error) {
showPassiveNotification(error)
}
footer.playlistId = playlistId
}
footer: PlayerFooter {}
-11
View File
@@ -1,11 +0,0 @@
// SPDX-FileCopyrightText: 2021 Jonah Brüchert <[email protected]>
//
// SPDX-License-Identifier: GPL-2.0-only OR GPL-3.0-only OR LicenseRef-KDE-Accepted-GPL
#include "errorhandler.h"
ErrorHandler::ErrorHandler(QObject *parent)
: QObject(parent)
{
connect(&YTMusicThread::instance().get(), &AsyncYTMusic::errorOccurred, this, &ErrorHandler::errorOccurred);
}
-19
View File
@@ -1,19 +0,0 @@
// SPDX-FileCopyrightText: 2021 Jonah Brüchert <[email protected]>
//
// SPDX-License-Identifier: GPL-2.0-only OR GPL-3.0-only OR LicenseRef-KDE-Accepted-GPL
#pragma once
#include <QObject>
#include "asyncytmusic.h"
class ErrorHandler : public QObject
{
Q_OBJECT
public:
explicit ErrorHandler(QObject *parent = nullptr);
Q_SIGNAL void errorOccurred(const QString &error);
};
+3 -8
View File
@@ -1,6 +1,6 @@
// SPDX-FileCopyrightText: 2021 Jonah Brüchert <[email protected]>
//
// SPDX-License-Identifier: GPL-2.0-only OR GPL-3.0-only OR LicenseRef-KDE-Accepted-GPL
// SPDX-License-Identifier: GPL-2.0-or-later
#include <ytmusic.h>
@@ -8,7 +8,7 @@
int main() {
const auto ytm = YTMusic();
const auto results = ytm.search("arte concert");
const auto results = ytm.search("Syd Matters");
std::cout << "Found " << results.size() << " results." << std::endl;
@@ -17,12 +17,7 @@ int main() {
using T = std::decay_t<decltype(arg)>;
if constexpr (std::is_same_v<T, search::Album>) {
std::cout << arg.title << std::endl;
const album::Album album = ytm.get_album(arg.browse_id);
for (const auto &track : album.tracks) {
if (track.video_id.has_value()) {
ytm.extract_video_info(*track.video_id);
}
}
ytm.get_album(arg.browse_id);
} else if constexpr (std::is_same_v<T, search::Artist>) {
std::cout << arg.artist << std::endl;
const artist::Artist artist = ytm.get_artist(arg.browse_id);
+7 -13
View File
@@ -1,6 +1,6 @@
// SPDX-FileCopyrightText: 2021 Jonah Brüchert <[email protected]>
//
// SPDX-License-Identifier: GPL-2.0-only OR GPL-3.0-only OR LicenseRef-KDE-Accepted-GPL
// SPDX-License-Identifier: GPL-2.0-or-later
#include <QApplication>
#include <QQmlApplicationEngine>
@@ -12,8 +12,6 @@
#include "albummodel.h"
#include "videoinfoextractor.h"
#include "artistmodel.h"
#include "userplaylistmodel.h"
#include "errorhandler.h"
#include "playlistmodel.h"
constexpr auto URI = "org.kde.ytmusic";
@@ -22,9 +20,9 @@ Q_DECL_EXPORT int main(int argc, char *argv[])
{
QGuiApplication::setAttribute(Qt::AA_EnableHighDpiScaling);
QApplication app(argc, argv);
QCoreApplication::setOrganizationName(QStringLiteral("KDE"));
QCoreApplication::setOrganizationDomain(QStringLiteral("kde.org"));
QCoreApplication::setApplicationName(QStringLiteral("audiotube"));
QCoreApplication::setOrganizationName("KDE");
QCoreApplication::setOrganizationDomain("kde.org");
QCoreApplication::setApplicationName("audiotube");
QQmlApplicationEngine engine;
@@ -33,12 +31,6 @@ Q_DECL_EXPORT int main(int argc, char *argv[])
qmlRegisterType<VideoInfoExtractor>(URI, 1, 0, "VideoInfoExtractor");
qmlRegisterType<ArtistModel>(URI, 1, 0, "ArtistModel");
qmlRegisterType<PlaylistModel>(URI, 1, 0, "PlaylistModel");
qmlRegisterSingletonType<UserPlaylistModel>(URI, 1, 0, "UserPlaylistModel", [](QQmlEngine *, QJSEngine *) {
return new UserPlaylistModel();
});
qmlRegisterSingletonType<ErrorHandler>(URI, 1, 0, "ErrorHandler", [](QQmlEngine *, QJSEngine *) {
return new ErrorHandler();
});
engine.rootContext()->setContextObject(new KLocalizedContext(&engine));
engine.load(QUrl(QStringLiteral("qrc:///main.qml")));
@@ -47,5 +39,7 @@ Q_DECL_EXPORT int main(int argc, char *argv[])
return -1;
}
return app.exec();
int ret = app.exec();
AsyncYTMusic::stopInstance();
return ret;
}
-10
View File
@@ -1,10 +0,0 @@
qt5_add_dbus_adaptor(DBUS_SRCS
dbus/org.mpris.MediaPlayer2.xml
mprisapplication.h MprisApplication)
qt5_add_dbus_adaptor(DBUS_SRCS
dbus/org.mpris.MediaPlayer2.Player.xml
mprisplayer.h MprisPlayer)
add_library(mpris2 STATIC mprisapplication.cpp mprisplayer.cpp ${DBUS_SRCS})
target_link_libraries(mpris2 PUBLIC Qt5::Core Qt5::DBus)
@@ -1,672 +0,0 @@
<?xml version="1.0" ?>
<node name="/Player_Interface" xmlns:tp="http://telepathy.freedesktop.org/wiki/DbusSpec#extensions-v0">
<interface name="org.mpris.MediaPlayer2.Player">
<tp:docstring xmlns="http://www.w3.org/1999/xhtml">
<p>
This interface implements the methods for querying and providing basic
control over what is currently playing.
</p>
</tp:docstring>
<tp:enum name="Playback_Status" tp:name-for-bindings="Playback_Status" type="s">
<tp:enumvalue suffix="Playing" value="Playing">
<tp:docstring xmlns="http://www.w3.org/1999/xhtml">
<p>A track is currently playing.</p>
</tp:docstring>
</tp:enumvalue>
<tp:enumvalue suffix="Paused" value="Paused">
<tp:docstring xmlns="http://www.w3.org/1999/xhtml">
<p>A track is currently paused.</p>
</tp:docstring>
</tp:enumvalue>
<tp:enumvalue suffix="Stopped" value="Stopped">
<tp:docstring xmlns="http://www.w3.org/1999/xhtml">
<p>There is no track currently playing.</p>
</tp:docstring>
</tp:enumvalue>
<tp:docstring xmlns="http://www.w3.org/1999/xhtml">
<p>A playback state.</p>
</tp:docstring>
</tp:enum>
<tp:enum name="Loop_Status" tp:name-for-bindings="Loop_Status" type="s">
<tp:enumvalue suffix="None" value="None">
<tp:docstring xmlns="http://www.w3.org/1999/xhtml">
<p>The playback will stop when there are no more tracks to play</p>
</tp:docstring>
</tp:enumvalue>
<tp:enumvalue suffix="Track" value="Track">
<tp:docstring xmlns="http://www.w3.org/1999/xhtml">
<p>The current track will start again from the begining once it has finished playing</p>
</tp:docstring>
</tp:enumvalue>
<tp:enumvalue suffix="Playlist" value="Playlist">
<tp:docstring xmlns="http://www.w3.org/1999/xhtml">
<p>The playback loops through a list of tracks</p>
</tp:docstring>
</tp:enumvalue>
<tp:docstring xmlns="http://www.w3.org/1999/xhtml">
<p>A repeat / loop status</p>
</tp:docstring>
</tp:enum>
<tp:simple-type name="Track_Id" type="o" array-name="Track_Id_List">
<tp:docstring xmlns="http://www.w3.org/1999/xhtml">
<p>Unique track identifier.</p>
<p>
If the media player implements the TrackList interface and allows
the same track to appear multiple times in the tracklist,
this must be unique within the scope of the tracklist.
</p>
<p>
Note that this should be a valid D-Bus object id, although clients
should not assume that any object is actually exported with any
interfaces at that path.
</p>
<p>
Media players may not use any paths starting with
<literal>/org/mpris</literal> unless explicitly allowed by this specification.
Such paths are intended to have special meaning, such as
<literal>/org/mpris/MediaPlayer2/TrackList/NoTrack</literal>
to indicate "no track".
</p>
<tp:rationale>
<p>
This is a D-Bus object id as that is the definitive way to have
unique identifiers on D-Bus. It also allows for future optional
expansions to the specification where tracks are exported to D-Bus
with an interface similar to org.gnome.UPnP.MediaItem2.
</p>
</tp:rationale>
</tp:docstring>
</tp:simple-type>
<tp:simple-type name="Playback_Rate" type="d">
<tp:docstring xmlns="http://www.w3.org/1999/xhtml">
<p>A playback rate</p>
<p>
This is a multiplier, so a value of 0.5 indicates that playback is
happening at half speed, while 1.5 means that 1.5 seconds of "track time"
is consumed every second.
</p>
</tp:docstring>
</tp:simple-type>
<tp:simple-type name="Volume" type="d">
<tp:docstring xmlns="http://www.w3.org/1999/xhtml">
<p>Audio volume level</p>
<ul>
<li>0.0 means mute.</li>
<li>1.0 is a sensible maximum volume level (ex: 0dB).</li>
</ul>
<p>
Note that the volume may be higher than 1.0, although generally
clients should not attempt to set it above 1.0.
</p>
</tp:docstring>
</tp:simple-type>
<tp:simple-type name="Time_In_Us" type="x">
<tp:docstring xmlns="http://www.w3.org/1999/xhtml">
<p>Time in microseconds.</p>
</tp:docstring>
</tp:simple-type>
<method name="Next" tp:name-for-bindings="Next">
<tp:docstring xmlns="http://www.w3.org/1999/xhtml">
<p>Skips to the next track in the tracklist.</p>
<p>
If there is no next track (and endless playback and track
repeat are both off), stop playback.
</p>
<p>If playback is paused or stopped, it remains that way.</p>
<p>
If <tp:member-ref>CanGoNext</tp:member-ref> is
<strong>false</strong>, attempting to call this method should have
no effect.
</p>
</tp:docstring>
</method>
<method name="Previous" tp:name-for-bindings="Previous">
<tp:docstring xmlns="http://www.w3.org/1999/xhtml">
<p>Skips to the previous track in the tracklist.</p>
<p>
If there is no previous track (and endless playback and track
repeat are both off), stop playback.
</p>
<p>If playback is paused or stopped, it remains that way.</p>
<p>
If <tp:member-ref>CanGoPrevious</tp:member-ref> is
<strong>false</strong>, attempting to call this method should have
no effect.
</p>
</tp:docstring>
</method>
<method name="Pause" tp:name-for-bindings="Pause">
<tp:docstring xmlns="http://www.w3.org/1999/xhtml">
<p>Pauses playback.</p>
<p>If playback is already paused, this has no effect.</p>
<p>
Calling Play after this should cause playback to start again
from the same position.
</p>
<p>
If <tp:member-ref>CanPause</tp:member-ref> is
<strong>false</strong>, attempting to call this method should have
no effect.
</p>
</tp:docstring>
</method>
<method name="PlayPause" tp:name-for-bindings="PlayPause">
<tp:docstring xmlns="http://www.w3.org/1999/xhtml">
<p>Pauses playback.</p>
<p>If playback is already paused, resumes playback.</p>
<p>If playback is stopped, starts playback.</p>
<p>
If <tp:member-ref>CanPause</tp:member-ref> is
<strong>false</strong>, attempting to call this method should have
no effect and raise an error.
</p>
</tp:docstring>
</method>
<method name="Stop" tp:name-for-bindings="Stop">
<tp:docstring xmlns="http://www.w3.org/1999/xhtml">
<p>Stops playback.</p>
<p>If playback is already stopped, this has no effect.</p>
<p>
Calling Play after this should cause playback to
start again from the beginning of the track.
</p>
<p>
If <tp:member-ref>CanControl</tp:member-ref> is
<strong>false</strong>, attempting to call this method should have
no effect and raise an error.
</p>
</tp:docstring>
</method>
<method name="Play" tp:name-for-bindings="Play">
<tp:docstring xmlns="http://www.w3.org/1999/xhtml">
<p>Starts or resumes playback.</p>
<p>If already playing, this has no effect.</p>
<p>If paused, playback resumes from the current position.</p>
<p>If there is no track to play, this has no effect.</p>
<p>
If <tp:member-ref>CanPlay</tp:member-ref> is
<strong>false</strong>, attempting to call this method should have
no effect.
</p>
</tp:docstring>
</method>
<method name="Seek" tp:name-for-bindings="Seek">
<arg direction="in" type="x" name="Offset" tp:type="Time_In_Us">
<tp:docstring xmlns="http://www.w3.org/1999/xhtml">
<p>The number of microseconds to seek forward.</p>
</tp:docstring>
</arg>
<tp:docstring xmlns="http://www.w3.org/1999/xhtml">
<p>
Seeks forward in the current track by the specified number
of microseconds.
</p>
<p>
A negative value seeks back. If this would mean seeking
back further than the start of the track, the position
is set to 0.
</p>
<p>
If the value passed in would mean seeking beyond the end
of the track, acts like a call to Next.
</p>
<p>
If the <tp:member-ref>CanSeek</tp:member-ref> property is false,
this has no effect.
</p>
</tp:docstring>
</method>
<method name="SetPosition" tp:name-for-bindings="Set_Position">
<arg direction="in" type="o" tp:type="Track_Id" name="TrackId">
<tp:docstring xmlns="http://www.w3.org/1999/xhtml">
<p>The currently playing track's identifier.</p>
<p>
If this does not match the id of the currently-playing track,
the call is ignored as "stale".
</p>
<p>
<literal>/org/mpris/MediaPlayer2/TrackList/NoTrack</literal>
is <em>not</em> a valid value for this argument.
</p>
</tp:docstring>
</arg>
<arg direction="in" type="x" tp:type="Time_In_Us" name="Position">
<tp:docstring xmlns="http://www.w3.org/1999/xhtml">
<p>Track position in microseconds.</p>
<p>This must be between 0 and &lt;track_length&gt;.</p>
</tp:docstring>
</arg>
<tp:docstring xmlns="http://www.w3.org/1999/xhtml">
<p>Sets the current track position in microseconds.</p>
<p>If the Position argument is less than 0, do nothing.</p>
<p>
If the Position argument is greater than the track length,
do nothing.
</p>
<p>
If the <tp:member-ref>CanSeek</tp:member-ref> property is false,
this has no effect.
</p>
<tp:rationale>
<p>
The reason for having this method, rather than making
<tp:member-ref>Position</tp:member-ref> writable, is to include
the TrackId argument to avoid race conditions where a client tries
to seek to a position when the track has already changed.
</p>
</tp:rationale>
</tp:docstring>
</method>
<method name="OpenUri" tp:name-for-bindings="Open_Uri">
<arg direction="in" type="s" tp:type="Uri" name="Uri">
<tp:docstring>
<p>
Uri of the track to load. Its uri scheme should be an element of the
<literal>org.mpris.MediaPlayer2.SupportedUriSchemes</literal>
property and the mime-type should match one of the elements of the
<literal>org.mpris.MediaPlayer2.SupportedMimeTypes</literal>.
</p>
</tp:docstring>
</arg>
<tp:docstring xmlns="http://www.w3.org/1999/xhtml">
<p>Opens the Uri given as an argument</p>
<p>If the playback is stopped, starts playing</p>
<p>
If the uri scheme or the mime-type of the uri to open is not supported,
this method does nothing and may raise an error. In particular, if the
list of available uri schemes is empty, this method may not be
implemented.
</p>
<p>Clients should not assume that the Uri has been opened as soon as this
method returns. They should wait until the mpris:trackid field in the
<tp:member-ref>Metadata</tp:member-ref> property changes.
</p>
<p>
If the media player implements the TrackList interface, then the
opened track should be made part of the tracklist, the
<literal>org.mpris.MediaPlayer2.TrackList.TrackAdded</literal> or
<literal>org.mpris.MediaPlayer2.TrackList.TrackListReplaced</literal>
signal should be fired, as well as the
<literal>org.freedesktop.DBus.Properties.PropertiesChanged</literal>
signal on the tracklist interface.
</p>
</tp:docstring>
</method>
<property name="PlaybackStatus" tp:name-for-bindings="Playback_Status" type="s" tp:type="Playback_Status" access="read">
<annotation name="org.freedesktop.DBus.Property.EmitsChangedSignal" value="true"/>
<tp:docstring xmlns="http://www.w3.org/1999/xhtml">
<p>The current playback status.</p>
<p>
May be "Playing", "Paused" or "Stopped".
</p>
</tp:docstring>
</property>
<property name="LoopStatus" type="s" access="readwrite"
tp:name-for-bindings="Loop_Status" tp:type="Loop_Status">
<annotation name="org.freedesktop.DBus.Property.EmitsChangedSignal" value="true"/>
<annotation name="org.mpris.MediaPlayer2.property.optional" value="true"/>
<tp:docstring xmlns="http://www.w3.org/1999/xhtml">
<p>The current loop / repeat status</p>
<p>May be:
<ul>
<li>"None" if the playback will stop when there are no more tracks to play</li>
<li>"Track" if the current track will start again from the begining once it has finished playing</li>
<li>"Playlist" if the playback loops through a list of tracks</li>
</ul>
</p>
<p>
If <tp:member-ref>CanControl</tp:member-ref> is
<strong>false</strong>, attempting to set this property should have
no effect and raise an error.
</p>
</tp:docstring>
</property>
<property name="Rate" tp:name-for-bindings="Rate" type="d" tp:type="Playback_Rate" access="readwrite">
<annotation name="org.freedesktop.DBus.Property.EmitsChangedSignal" value="true"/>
<tp:docstring xmlns="http://www.w3.org/1999/xhtml">
<p>The current playback rate.</p>
<p>
The value must fall in the range described by
<tp:member-ref>MinimumRate</tp:member-ref> and
<tp:member-ref>MaximumRate</tp:member-ref>, and must not be 0.0. If
playback is paused, the <tp:member-ref>PlaybackStatus</tp:member-ref>
property should be used to indicate this. A value of 0.0 should not
be set by the client. If it is, the media player should act as
though <tp:member-ref>Pause</tp:member-ref> was called.
</p>
<p>
If the media player has no ability to play at speeds other than the
normal playback rate, this must still be implemented, and must
return 1.0. The <tp:member-ref>MinimumRate</tp:member-ref> and
<tp:member-ref>MaximumRate</tp:member-ref> properties must also be
set to 1.0.
</p>
<p>
Not all values may be accepted by the media player. It is left to
media player implementations to decide how to deal with values they
cannot use; they may either ignore them or pick a "best fit" value.
Clients are recommended to only use sensible fractions or multiples
of 1 (eg: 0.5, 0.25, 1.5, 2.0, etc).
</p>
<tp:rationale>
<p>
This allows clients to display (reasonably) accurate progress bars
without having to regularly query the media player for the current
position.
</p>
</tp:rationale>
</tp:docstring>
</property>
<property name="Shuffle" tp:name-for-bindings="Shuffle" type="b" access="readwrite">
<annotation name="org.freedesktop.DBus.Property.EmitsChangedSignal" value="true"/>
<annotation name="org.mpris.MediaPlayer2.property.optional" value="true"/>
<tp:docstring xmlns="http://www.w3.org/1999/xhtml">
<p>
A value of <strong>false</strong> indicates that playback is
progressing linearly through a playlist, while <strong>true</strong>
means playback is progressing through a playlist in some other order.
</p>
<p>
If <tp:member-ref>CanControl</tp:member-ref> is
<strong>false</strong>, attempting to set this property should have
no effect and raise an error.
</p>
</tp:docstring>
</property>
<property name="Metadata" tp:name-for-bindings="Metadata" type="a{sv}" tp:type="Metadata_Map" access="read">
<annotation name="org.qtproject.QtDBus.QtTypeName" value="QMap<QString, QString>"/>
<tp:docstring xmlns="http://www.w3.org/1999/xhtml">
<p>The metadata of the current element.</p>
<p>
If there is a current track, this must have a "mpris:trackid" entry
(of D-Bus type "o") at the very least, which contains a D-Bus path that
uniquely identifies this track.
</p>
<p>
See the type documentation for more details.
</p>
</tp:docstring>
</property>
<property name="Volume" type="d" tp:type="Volume" tp:name-for-bindings="Volume" access="readwrite">
<annotation name="org.freedesktop.DBus.Property.EmitsChangedSignal" value="true" />
<tp:docstring xmlns="http://www.w3.org/1999/xhtml">
<p>The volume level.</p>
<p>
When setting, if a negative value is passed, the volume
should be set to 0.0.
</p>
<p>
If <tp:member-ref>CanControl</tp:member-ref> is
<strong>false</strong>, attempting to set this property should have
no effect and raise an error.
</p>
</tp:docstring>
</property>
<property name="Position" type="x" tp:type="Time_In_Us" tp:name-for-bindings="Position" access="read">
<annotation name="org.freedesktop.DBus.Property.EmitsChangedSignal" value="false"/>
<tp:docstring xmlns="http://www.w3.org/1999/xhtml">
<p>
The current track position in microseconds, between 0 and
the 'mpris:length' metadata entry (see Metadata).
</p>
<p>
Note: If the media player allows it, the current playback position
can be changed either the SetPosition method or the Seek method on
this interface. If this is not the case, the
<tp:member-ref>CanSeek</tp:member-ref> property is false, and
setting this property has no effect and can raise an error.
</p>
<p>
If the playback progresses in a way that is inconstistant with the
<tp:member-ref>Rate</tp:member-ref> property, the
<tp:member-ref>Seeked</tp:member-ref> signal is emited.
</p>
</tp:docstring>
</property>
<property name="MinimumRate" tp:name-for-bindings="Minimum_Rate" type="d" tp:type="Playback_Rate" access="read">
<annotation name="org.freedesktop.DBus.Property.EmitsChangedSignal" value="true"/>
<tp:docstring xmlns="http://www.w3.org/1999/xhtml">
<p>
The minimum value which the <tp:member-ref>Rate</tp:member-ref>
property can take.
Clients should not attempt to set the
<tp:member-ref>Rate</tp:member-ref> property below this value.
</p>
<p>
Note that even if this value is 0.0 or negative, clients should
not attempt to set the <tp:member-ref>Rate</tp:member-ref> property
to 0.0.
</p>
<p>This value should always be 1.0 or less.</p>
</tp:docstring>
</property>
<property name="MaximumRate" tp:name-for-bindings="Maximum_Rate" type="d" tp:type="Playback_Rate" access="read">
<annotation name="org.freedesktop.DBus.Property.EmitsChangedSignal" value="true"/>
<tp:docstring xmlns="http://www.w3.org/1999/xhtml">
<p>
The maximum value which the <tp:member-ref>Rate</tp:member-ref>
property can take.
Clients should not attempt to set the
<tp:member-ref>Rate</tp:member-ref> property above this value.
</p>
<p>
This value should always be 1.0 or greater.
</p>
</tp:docstring>
</property>
<property name="CanGoNext" tp:name-for-bindings="Can_Go_Next" type="b" access="read">
<annotation name="org.freedesktop.DBus.Property.EmitsChangedSignal" value="true"/>
<tp:docstring xmlns="http://www.w3.org/1999/xhtml">
<p>
Whether the client can call the <tp:member-ref>Next</tp:member-ref>
method on this interface and expect the current track to change.
</p>
<p>
If it is unknown whether a call to <tp:member-ref>Next</tp:member-ref> will
be successful (for example, when streaming tracks), this property should
be set to <strong>true</strong>.
</p>
<p>
If <tp:member-ref>CanControl</tp:member-ref> is
<strong>false</strong>, this property should also be
<strong>false</strong>.
</p>
<tp:rationale>
<p>
Even when playback can generally be controlled, there may not
always be a next track to move to.
</p>
</tp:rationale>
</tp:docstring>
</property>
<property name="CanGoPrevious" tp:name-for-bindings="Can_Go_Previous" type="b" access="read">
<annotation name="org.freedesktop.DBus.Property.EmitsChangedSignal" value="true"/>
<tp:docstring xmlns="http://www.w3.org/1999/xhtml">
<p>
Whether the client can call the
<tp:member-ref>Previous</tp:member-ref> method on this interface and
expect the current track to change.
</p>
<p>
If it is unknown whether a call to <tp:member-ref>Previous</tp:member-ref>
will be successful (for example, when streaming tracks), this property
should be set to <strong>true</strong>.
</p>
<p>
If <tp:member-ref>CanControl</tp:member-ref> is
<strong>false</strong>, this property should also be
<strong>false</strong>.
</p>
<tp:rationale>
<p>
Even when playback can generally be controlled, there may not
always be a next previous to move to.
</p>
</tp:rationale>
</tp:docstring>
</property>
<property name="CanPlay" tp:name-for-bindings="Can_Play" type="b" access="read">
<annotation name="org.freedesktop.DBus.Property.EmitsChangedSignal" value="true"/>
<tp:docstring xmlns="http://www.w3.org/1999/xhtml">
<p>Whether playback can be started using
<tp:member-ref>Play</tp:member-ref> or
<tp:member-ref>PlayPause</tp:member-ref>.
</p>
<p>
Note that this is related to whether there is a "current track": the
value should not depend on whether the track is currently paused or
playing. In fact, if a track is currently playing (and
<tp:member-ref>CanControl</tp:member-ref> is <strong>true</strong>),
this should be <strong>true</strong>.
</p>
<p>
If <tp:member-ref>CanControl</tp:member-ref> is
<strong>false</strong>, this property should also be
<strong>false</strong>.
</p>
<tp:rationale>
<p>
Even when playback can generally be controlled, it may not be
possible to enter a "playing" state, for example if there is no
"current track".
</p>
</tp:rationale>
</tp:docstring>
</property>
<property name="CanPause" tp:name-for-bindings="Can_Pause" type="b" access="read">
<annotation name="org.freedesktop.DBus.Property.EmitsChangedSignal" value="true"/>
<tp:docstring xmlns="http://www.w3.org/1999/xhtml">
<p>Whether playback can be paused using
<tp:member-ref>Pause</tp:member-ref> or
<tp:member-ref>PlayPause</tp:member-ref>.
</p>
<p>
Note that this is an intrinsic property of the current track: its
value should not depend on whether the track is currently paused or
playing. In fact, if playback is currently paused (and
<tp:member-ref>CanControl</tp:member-ref> is <strong>true</strong>),
this should be <strong>true</strong>.
</p>
<p>
If <tp:member-ref>CanControl</tp:member-ref> is
<strong>false</strong>, this property should also be
<strong>false</strong>.
</p>
<tp:rationale>
<p>
Not all media is pausable: it may not be possible to pause some
streamed media, for example.
</p>
</tp:rationale>
</tp:docstring>
</property>
<property name="CanSeek" tp:name-for-bindings="Can_Seek" type="b" access="read">
<annotation name="org.freedesktop.DBus.Property.EmitsChangedSignal" value="true"/>
<tp:docstring xmlns="http://www.w3.org/1999/xhtml">
<p>
Whether the client can control the playback position using
<tp:member-ref>Seek</tp:member-ref> and
<tp:member-ref>SetPosition</tp:member-ref>. This may be different for
different tracks.
</p>
<p>
If <tp:member-ref>CanControl</tp:member-ref> is
<strong>false</strong>, this property should also be
<strong>false</strong>.
</p>
<tp:rationale>
<p>
Not all media is seekable: it may not be possible to seek when
playing some streamed media, for example.
</p>
</tp:rationale>
</tp:docstring>
</property>
<property name="CanControl" tp:name-for-bindings="Can_Control" type="b" access="read">
<annotation name="org.freedesktop.DBus.Property.EmitsChangedSignal" value="false"/>
<tp:docstring xmlns="http://www.w3.org/1999/xhtml">
<p>Whether the media player may be controlled over this interface.</p>
<p>
This property is not expected to change, as it describes an intrinsic
capability of the implementation.
</p>
<p>
If this is <strong>false</strong>, clients should assume that all
properties on this interface are read-only (and will raise errors
if writing to them is attempted), no methods are implemented
and all other properties starting with "Can" are also
<strong>false</strong>.
</p>
<tp:rationale>
<p>
This allows clients to determine whether to present and enable
controls to the user in advance of attempting to call methods
and write to properties.
</p>
</tp:rationale>
</tp:docstring>
</property>
<signal name="Seeked" tp:name-for-bindings="Seeked">
<arg name="Position" type="x" tp:type="Time_In_Us">
<tp:docstring>
<p>The new position, in microseconds.</p>
</tp:docstring>
</arg>
<tp:docstring xmlns="http://www.w3.org/1999/xhtml">
<p>
Indicates that the track position has changed in a way that is
inconsistant with the current playing state.
</p>
<p>When this signal is not received, clients should assume that:</p>
<ul>
<li>
When playing, the position progresses according to the rate property.
</li>
<li>When paused, it remains constant.</li>
</ul>
<p>
This signal does not need to be emitted when playback starts
or when the track changes, unless the track is starting at an
unexpected position. An expected position would be the last
known one when going from Paused to Playing, and 0 when going from
Stopped to Playing.
</p>
</tp:docstring>
</signal>
</interface>
</node>
<!-- vim:set sw=2 sts=2 et ft=xml: -->
@@ -1,253 +0,0 @@
<?xml version="1.0" ?>
<node name="/Playlists_Interface" xmlns:tp="http://telepathy.freedesktop.org/wiki/DbusSpec#extensions-v0">
<interface name="org.mpris.MediaPlayer2.Playlists">
<tp:added version="2.1" />
<tp:docstring>
<p>Provides access to the media player's playlists.</p>
<p>
Since D-Bus does not provide an easy way to check for what interfaces
are exported on an object, clients should attempt to get one of the
properties on this interface to see if it is implemented.
</p>
</tp:docstring>
<tp:simple-type name="Playlist_Id" type="o" array-name="Playlist_Id_List">
<tp:docstring xmlns="http://www.w3.org/1999/xhtml">
<p>Unique playlist identifier.</p>
<tp:rationale>
<p>
Multiple playlists may have the same name.
</p>
<p>
This is a D-Bus object id as that is the definitive way to have
unique identifiers on D-Bus. It also allows for future optional
expansions to the specification where tracks are exported to D-Bus
with an interface similar to org.gnome.UPnP.MediaItem2.
</p>
</tp:rationale>
</tp:docstring>
</tp:simple-type>
<tp:simple-type name="Uri" type="s" array-name="Uri_List">
<tp:docstring xmlns="http://www.w3.org/1999/xhtml">
<p>A URI.</p>
</tp:docstring>
</tp:simple-type>
<tp:struct name="Playlist" array-name="Playlist_List">
<tp:docstring xmlns="http://www.w3.org/1999/xhtml">
<p>A data structure describing a playlist.</p>
</tp:docstring>
<tp:member type="o" tp:type="Playlist_Id" name="Id">
<tp:docstring xmlns="http://www.w3.org/1999/xhtml">
<p>A unique identifier for the playlist.</p>
<p>This should remain the same if the playlist is renamed.</p>
</tp:docstring>
</tp:member>
<tp:member type="s" name="Name">
<tp:docstring xmlns="http://www.w3.org/1999/xhtml">
<p>The name of the playlist, typically given by the user.</p>
</tp:docstring>
</tp:member>
<tp:member type="s" tp:type="Uri" name="Icon">
<tp:docstring xmlns="http://www.w3.org/1999/xhtml">
<p>The URI of an (optional) icon.</p>
</tp:docstring>
</tp:member>
</tp:struct>
<tp:struct name="Maybe_Playlist">
<tp:docstring xmlns="http://www.w3.org/1999/xhtml">
<p>A data structure describing a playlist, or nothing.</p>
<tp:rationale>
<p>
D-Bus does not (at the time of writing) support a MAYBE type,
so we are forced to invent our own.
</p>
</tp:rationale>
</tp:docstring>
<tp:member type="b" name="Valid">
<tp:docstring xmlns="http://www.w3.org/1999/xhtml">
<p>Whether this structure refers to a valid playlist.</p>
</tp:docstring>
</tp:member>
<tp:member type="(oss)" tp:type="Playlist" name="Playlist">
<tp:docstring xmlns="http://www.w3.org/1999/xhtml">
<p>The playlist, providing Valid is true, otherwise undefined.</p>
<p>
When constructing this type, it should be noted that the playlist
ID must be a valid object path, or D-Bus implementations may reject
it. This is true even when Valid is false. It is suggested that
"/" is used as the playlist ID in this case.
</p>
</tp:docstring>
</tp:member>
</tp:struct>
<tp:enum name="Playlist_Ordering" array-name="Playlist_Ordering_List" type="s">
<tp:docstring xmlns="http://www.w3.org/1999/xhtml">
<p>Specifies the ordering of returned playlists.</p>
</tp:docstring>
<tp:enumvalue suffix="Alphabetical" value="Alphabetical">
<tp:docstring xmlns="http://www.w3.org/1999/xhtml">
<p>Alphabetical ordering by name, ascending.</p>
</tp:docstring>
</tp:enumvalue>
<tp:enumvalue suffix="CreationDate" value="Created">
<tp:docstring xmlns="http://www.w3.org/1999/xhtml">
<p>Ordering by creation date, oldest first.</p>
</tp:docstring>
</tp:enumvalue>
<tp:enumvalue suffix="ModifiedDate" value="Modified">
<tp:docstring xmlns="http://www.w3.org/1999/xhtml">
<p>Ordering by last modified date, oldest first.</p>
</tp:docstring>
</tp:enumvalue>
<tp:enumvalue suffix="LastPlayDate" value="Played">
<tp:docstring xmlns="http://www.w3.org/1999/xhtml">
<p>Ordering by date of last playback, oldest first.</p>
</tp:docstring>
</tp:enumvalue>
<tp:enumvalue suffix="UserDefined" value="User">
<tp:docstring xmlns="http://www.w3.org/1999/xhtml">
<p>A user-defined ordering.</p>
<tp:rationale>
<p>
Some media players may allow users to order playlists as they
wish. This ordering allows playlists to be retreived in that
order.
</p>
</tp:rationale>
</tp:docstring>
</tp:enumvalue>
</tp:enum>
<method name="ActivatePlaylist" tp:name-for-bindings="Activate_Playlist">
<tp:docstring xmlns="http://www.w3.org/1999/xhtml">
<p>
Starts playing the given playlist.
</p>
<p>
Note that this must be implemented. If the media player does not
allow clients to change the playlist, it should not implement this
interface at all.
</p>
<p>
It is up to the media player whether this completely replaces the
current tracklist, or whether it is merely inserted into the
tracklist and the first track starts. For example, if the media
player is operating in a "jukebox" mode, it may just append the
playlist to the list of upcoming tracks, and skip to the first
track in the playlist.
</p>
</tp:docstring>
<arg direction="in" name="PlaylistId" type="o">
<tp:docstring>
<p>The id of the playlist to activate.</p>
</tp:docstring>
</arg>
</method>
<method name="GetPlaylists" tp:name-for-bindings="Get_Playlists">
<tp:docstring xmlns="http://www.w3.org/1999/xhtml">
<p>Gets a set of playlists.</p>
</tp:docstring>
<arg direction="in" name="Index" type="u">
<tp:docstring>
<p>The index of the first playlist to be fetched (according to the ordering).</p>
</tp:docstring>
</arg>
<arg direction="in" name="MaxCount" type="u">
<tp:docstring>
<p>The maximum number of playlists to fetch.</p>
</tp:docstring>
</arg>
<arg direction="in" name="Order" type="s" tp:type="Playlist_Ordering">
<tp:docstring>
<p>The ordering that should be used.</p>
</tp:docstring>
</arg>
<arg direction="in" name="ReverseOrder" type="b">
<tp:docstring>
<p>Whether the order should be reversed.</p>
</tp:docstring>
</arg>
<annotation name="org.qtproject.QtDBus.QtTypeName.Out0" value="PlaylistList"/>
<arg direction="out" name="Playlists" type="a(oss)" tp:type="Playlist[]">
<tp:docstring>
<p>A list of (at most MaxCount) playlists.</p>
</tp:docstring>
</arg>
</method>
<property name="PlaylistCount" type="u" tp:name-for-bindings="Playlist_Count" access="read">
<annotation name="org.freedesktop.DBus.Property.EmitsChangedSignal" value="true"/>
<tp:docstring xmlns="http://www.w3.org/1999/xhtml">
<p>
The number of playlists available.
</p>
</tp:docstring>
</property>
<property name="Orderings" tp:name-for-bindings="Orderings" type="as" tp:type="Playlist_Ordering[]" access="read">
<annotation name="org.freedesktop.DBus.Property.EmitsChangedSignal" value="true"/>
<tp:docstring xmlns="http://www.w3.org/1999/xhtml">
<p>
The available orderings. At least one must be offered.
</p>
<tp:rationale>
<p>
Media players may not have access to all the data required for some
orderings. For example, creation times are not available on UNIX
filesystems (don't let the ctime fool you!). On the other hand,
clients should have some way to get the "most recent" playlists.
</p>
</tp:rationale>
</tp:docstring>
</property>
<property name="ActivePlaylist" type="(b(oss))" tp:name-for-bindings="Active_Playlist" tp:type="Maybe_Playlist" access="read">
<annotation name="org.qtproject.QtDBus.QtTypeName" value="PlaylistType"/>
<annotation name="org.freedesktop.DBus.Property.EmitsChangedSignal" value="true"/>
<tp:docstring xmlns="http://www.w3.org/1999/xhtml">
<p>
The currently-active playlist.
</p>
<p>
If there is no currently-active playlist, the structure's Valid field
will be false, and the Playlist details are undefined.
</p>
<p>
Note that this may not have a value even after ActivatePlaylist is
called with a valid playlist id as ActivatePlaylist implementations
have the option of simply inserting the contents of the playlist into
the current tracklist.
</p>
</tp:docstring>
</property>
<signal name="PlaylistChanged" tp:name-for-bindings="Playlist_Changed">
<annotation name="org.qtproject.QtDBus.QtTypeName.Out0" value="Playlist"/>
<arg name="Playlist" type="(oss)" tp:type="Playlist">
<tp:docstring>
The playlist which details have changed.
</tp:docstring>
</arg>
<tp:docstring xmlns="http://www.w3.org/1999/xhtml">
<p>Indicates that either the Name or Icon attribute of a
playlist has changed.
</p>
<p>Client implementations should be aware that this signal
may not be implemented.
</p>
<tp:rationale>
Without this signal, media players have no way to notify clients
of a change in the attributes of a playlist other than the active one
</tp:rationale>
</tp:docstring>
</signal>
</interface>
</node>
<!-- vim:set sw=2 sts=2 et ft=xml: -->
@@ -1,352 +0,0 @@
<?xml version="1.0" ?>
<node name="/Track_List_Interface" xmlns:tp="http://telepathy.freedesktop.org/wiki/DbusSpec#extensions-v0">
<interface name="org.mpris.MediaPlayer2.TrackList">
<tp:docstring xmlns="http://www.w3.org/1999/xhtml">
<p>
Provides access to a short list of tracks which were recently played or
will be played shortly. This is intended to provide context to the
currently-playing track, rather than giving complete access to the
media player's playlist.
</p>
<p>
Example use cases are the list of tracks from the same album as the
currently playing song or the
<a href="http://projects.gnome.org/rhythmbox/">Rhythmbox</a> play queue.
</p>
<p>
Each track in the tracklist has a unique identifier.
The intention is that this uniquely identifies the track within
the scope of the tracklist. In particular, if a media item
(a particular music file, say) occurs twice in the track list, each
occurrence should have a different identifier. If a track is removed
from the middle of the playlist, it should not affect the track ids
of any other tracks in the tracklist.
</p>
<p>
As a result, the traditional track identifiers of URLs and position
in the playlist cannot be used. Any scheme which satisfies the
uniqueness requirements is valid, as clients should not make any
assumptions about the value of the track id beyond the fact
that it is a unique identifier.
</p>
<p>
Note that the (memory and processing) burden of implementing the
TrackList interface and maintaining unique track ids for the
playlist can be mitigated by only exposing a subset of the playlist when
it is very long (the 20 or so tracks around the currently playing
track, for example). This is a recommended practice as the tracklist
interface is not designed to enable browsing through a large list of tracks,
but rather to provide clients with context about the currently playing track.
</p>
</tp:docstring>
<tp:mapping name="Metadata_Map" array-name="Metadata_Map_List">
<tp:docstring xmlns="http://www.w3.org/1999/xhtml">
<p>A mapping from metadata attribute names to values.</p>
<p>
The <b>mpris:trackid</b> attribute must always be present, and must be
of D-Bus type "o". This contains a D-Bus path that uniquely identifies
the track within the scope of the playlist. There may or may not be
an actual D-Bus object at that path; this specification says nothing
about what interfaces such an object may implement.
</p>
<p>
If the length of the track is known, it should be provided in the
metadata property with the "mpris:length" key. The length must be
given in microseconds, and be represented as a signed 64-bit integer.
</p>
<p>
If there is an image associated with the track, a URL for it may be
provided using the "mpris:artUrl" key. For other metadata, fields
defined by the
<a href="http://xesam.org/main/XesamOntology">Xesam ontology</a>
should be used, prefixed by "xesam:". See the
<a href="http://www.freedesktop.org/wiki/Specifications/mpris-spec/metadata">metadata page on the freedesktop.org wiki</a>
for a list of common fields.
</p>
<p>
Lists of strings should be passed using the array-of-string ("as")
D-Bus type. Dates should be passed as strings using the ISO 8601
extended format (eg: 2007-04-29T14:35:51). If the timezone is
known, RFC 3339's internet profile should be used (eg:
2007-04-29T14:35:51+02:00).
</p>
</tp:docstring>
<tp:member type="s" name="Attribute">
<tp:docstring xmlns="http://www.w3.org/1999/xhtml">
<p>
The name of the attribute; see the
<a href="http://www.freedesktop.org/wiki/Specifications/mpris-spec/metadata">metadata page</a>
for guidelines on names to use.
</p>
</tp:docstring>
</tp:member>
<tp:member type="v" name="Value">
<tp:docstring xmlns="http://www.w3.org/1999/xhtml">
<p>The value of the attribute, in the most appropriate format.</p>
</tp:docstring>
</tp:member>
</tp:mapping>
<tp:simple-type name="Uri" type="s">
<tp:docstring xmlns="http://www.w3.org/1999/xhtml">
<p>A unique resource identifier.</p>
</tp:docstring>
</tp:simple-type>
<method name="GetTracksMetadata" tp:name-for-bindings="Get_Tracks_Metadata">
<arg direction="in" name="TrackIds" type="ao" tp:type="Track_Id[]">
<tp:docstring>
<p>The list of track ids for which metadata is requested.</p>
</tp:docstring>
</arg>
<annotation name="org.qtproject.QtDBus.QtTypeName.Out0" value="MetadataMap"/>
<arg direction="out" type="aa{sv}" tp:type="Metadata_Map[]" name="Metadata">
<tp:docstring>
<p>Metadata of the set of tracks given as input.</p>
<p>See the type documentation for more details.</p>
</tp:docstring>
</arg>
<tp:docstring xmlns="http://www.w3.org/1999/xhtml">
<p>Gets all the metadata available for a set of tracks.</p>
<p>
Each set of metadata must have a "mpris:trackid" entry at the very least,
which contains a string that uniquely identifies this track within
the scope of the tracklist.
</p>
</tp:docstring>
</method>
<method name="AddTrack" tp:name-for-bindings="Add_Track">
<arg direction="in" type="s" tp:type="Uri" name="Uri">
<tp:docstring>
<p>
The uri of the item to add. Its uri scheme should be an element of the
<strong>org.mpris.MediaPlayer2.SupportedUriSchemes</strong>
property and the mime-type should match one of the elements of the
<strong>org.mpris.MediaPlayer2.SupportedMimeTypes</strong>
</p>
</tp:docstring>
</arg>
<arg direction="in" type="o" tp:type="Track_Id" name="AfterTrack">
<tp:docstring>
<p>
The identifier of the track after which
the new item should be inserted. The path
<literal>/org/mpris/MediaPlayer2/TrackList/NoTrack</literal>
indicates that the track should be inserted at the
start of the track list.
</p>
</tp:docstring>
</arg>
<arg direction="in" type="b" name="SetAsCurrent">
<tp:docstring>
<p>
Whether the newly inserted track should be considered as
the current track. Setting this to true has the same effect as
calling GoTo afterwards.
</p>
</tp:docstring>
</arg>
<tp:docstring xmlns="http://www.w3.org/1999/xhtml">
<p>Adds a URI in the TrackList.</p>
<p>
If the <tp:member-ref>CanEditTracks</tp:member-ref> property is false,
this has no effect.
</p>
<p>
Note: Clients should not assume that the track has been added at the
time when this method returns. They should wait for a TrackAdded (or
TrackListReplaced) signal.
</p>
</tp:docstring>
</method>
<method name="RemoveTrack" tp:name-for-bindings="Remove__Track">
<arg direction="in" type="o" tp:type="Track_Id" name="TrackId">
<tp:docstring>
<p>Identifier of the track to be removed.</p>
<p>
<literal>/org/mpris/MediaPlayer2/TrackList/NoTrack</literal>
is <em>not</em> a valid value for this argument.
</p>
</tp:docstring>
</arg>
<tp:docstring xmlns="http://www.w3.org/1999/xhtml">
<p>Removes an item from the TrackList.</p>
<p>If the track is not part of this tracklist, this has no effect.</p>
<p>
If the <tp:member-ref>CanEditTracks</tp:member-ref> property is false,
this has no effect.
</p>
<p>
Note: Clients should not assume that the track has been removed at the
time when this method returns. They should wait for a TrackRemoved (or
TrackListReplaced) signal.
</p>
</tp:docstring>
</method>
<method name="GoTo" tp:name-for-bindings="Go_To">
<arg direction="in" type="o" tp:type="Track_Id" name="TrackId">
<tp:docstring>
<p>Identifier of the track to skip to.</p>
<p>
<literal>/org/mpris/MediaPlayer2/TrackList/NoTrack</literal>
is <em>not</em> a valid value for this argument.
</p>
</tp:docstring>
</arg>
<tp:docstring xmlns="http://www.w3.org/1999/xhtml">
<p>Skip to the specified TrackId.</p>
<p>If the track is not part of this tracklist, this has no effect.</p>
<p>
If this object is not <strong>/org/mpris/MediaPlayer2</strong>,
the current TrackList's tracks should be replaced with the contents of
this TrackList, and the TrackListReplaced signal should be fired from
<strong>/org/mpris/MediaPlayer2</strong>.
</p>
</tp:docstring>
</method>
<property name="Tracks" type="ao" tp:type="Track_Id[]" tp:name-for-bindings="Tracks" access="read">
<annotation name="org.freedesktop.DBus.Property.EmitsChangedSignal" value="invalidates"/>
<tp:docstring>
<p>
An array which contains the identifier of each track
in the tracklist, in order.
</p>
<p>
The <literal>org.freedesktop.DBus.Properties.PropertiesChanged</literal>
signal is emited every time this property changes, but the signal
message does not contain the new value.
Client implementations should rather rely on the
<tp:member-ref>TrackAdded</tp:member-ref>,
<tp:member-ref>TrackRemoved</tp:member-ref> and
<tp:member-ref>TrackListReplaced</tp:member-ref> signals to keep their
representation of the tracklist up to date.
</p>
</tp:docstring>
</property>
<property name="CanEditTracks" type="b" tp:name-for-bindings="Can_Edit_Tracks" access="read">
<annotation name="org.freedesktop.DBus.Property.EmitsChangedSignal" value="true"/>
<tp:docstring xmlns="http://www.w3.org/1999/xhtml">
<p>
If <strong>false</strong>, calling
<tp:member-ref>AddTrack</tp:member-ref> or
<tp:member-ref>RemoveTrack</tp:member-ref> will have no effect,
and may raise a NotSupported error.
</p>
</tp:docstring>
</property>
<signal name="TrackListReplaced" tp:name-for-bindings="Track_List_Replaced">
<arg name="Tracks" type="ao" tp:type="Track_Id[]">
<tp:docstring>
<p>The new content of the tracklist.</p>
</tp:docstring>
</arg>
<arg name="CurrentTrack" type="o" tp:type="Track_Id">
<tp:docstring>
<p>The identifier of the track to be considered as current.</p>
<p>
<literal>/org/mpris/MediaPlayer2/TrackList/NoTrack</literal>
indicates that there is no current track.
</p>
<p>
This should correspond to the <literal>mpris:trackid</literal> field of the
Metadata property of the <literal>org.mpris.MediaPlayer2.Player</literal>
interface.
</p>
</tp:docstring>
</arg>
<tp:docstring xmlns="http://www.w3.org/1999/xhtml">
<p>Indicates that the entire tracklist has been replaced.</p>
<p>
It is left up to the implementation to decide when
a change to the track list is invasive enough that
this signal should be emitted instead of a series of
TrackAdded and TrackRemoved signals.
</p>
</tp:docstring>
</signal>
<signal name="TrackAdded" tp:name-for-bindings="Track_Added">
<annotation name="org.qtproject.QtDBus.QtTypeName.Out0" value="MetadataMap"/>
<arg type="a{sv}" tp:type="Metadata_Map" name="Metadata">
<tp:docstring>
<p>The metadata of the newly added item.</p>
<p>This must include a mpris:trackid entry.</p>
<p>See the type documentation for more details.</p>
</tp:docstring>
</arg>
<arg type="o" tp:type="Track_Id" name="AfterTrack">
<tp:docstring>
<p>
The identifier of the track after which the new track
was inserted. The path
<literal>/org/mpris/MediaPlayer2/TrackList/NoTrack</literal>
indicates that the track was inserted at the
start of the track list.
</p>
</tp:docstring>
</arg>
<tp:docstring xmlns="http://www.w3.org/1999/xhtml">
<p>Indicates that a track has been added to the track list.</p>
</tp:docstring>
</signal>
<signal name="TrackRemoved" tp:name-for-bindings="Track_Removed">
<arg type="o" tp:type="Track_Id" name="TrackId">
<tp:docstring>
<p>The identifier of the track being removed.</p>
<p>
<literal>/org/mpris/MediaPlayer2/TrackList/NoTrack</literal>
is <em>not</em> a valid value for this argument.
</p>
</tp:docstring>
</arg>
<tp:docstring xmlns="http://www.w3.org/1999/xhtml">
<p>Indicates that a track has been removed from the track list.</p>
</tp:docstring>
</signal>
<signal name="TrackMetadataChanged" tp:name-for-bindings="Track_Metadata_Changed">
<arg type="o" tp:type="Track_Id" name="TrackId">
<tp:docstring>
<p>The id of the track which metadata has changed.</p>
<p>If the track id has changed, this will be the old value.</p>
<p>
<literal>/org/mpris/MediaPlayer2/TrackList/NoTrack</literal>
is <em>not</em> a valid value for this argument.
</p>
</tp:docstring>
</arg>
<annotation name="org.qtproject.QtDBus.QtTypeName.Out1" value="MetadataMap"/>
<arg type="a{sv}" tp:type="Metadata_Map" name="Metadata">
<tp:docstring>
<p>The new track metadata.</p>
<p>
This must include a mpris:trackid entry. If the track id has
changed, this will be the new value.
</p>
<p>See the type documentation for more details.</p>
</tp:docstring>
</arg>
<tp:docstring xmlns="http://www.w3.org/1999/xhtml">
<p>
Indicates that the metadata of a track in the tracklist has changed.
</p>
<p>
This may indicate that a track has been replaced, in which case the
mpris:trackid metadata entry is different from the TrackId argument.
</p>
</tp:docstring>
</signal>
</interface>
</node>
<!-- vim:set sw=2 sts=2 et ft=xml: -->
-198
View File
@@ -1,198 +0,0 @@
<?xml version="1.0" ?>
<node name="/Media_Player" xmlns:tp="http://telepathy.freedesktop.org/wiki/DbusSpec#extensions-v0">
<interface name="org.mpris.MediaPlayer2">
<annotation name="org.freedesktop.DBus.Property.EmitsChangedSignal" value="true"/>
<method name="Raise" tp:name-for-bindings="Raise">
<tp:docstring xmlns="http://www.w3.org/1999/xhtml">
<p>
Brings the media player's user interface to the front using any
appropriate mechanism available.
</p>
<p>
The media player may be unable to control how its user interface
is displayed, or it may not have a graphical user interface at all.
In this case, the <tp:member-ref>CanRaise</tp:member-ref> property is
<strong>false</strong> and this method does nothing.
</p>
</tp:docstring>
</method>
<method name="Quit" tp:name-for-bindings="Quit">
<tp:docstring xmlns="http://www.w3.org/1999/xhtml">
<p>Causes the media player to stop running.</p>
<p>
The media player may refuse to allow clients to shut it down.
In this case, the <tp:member-ref>CanQuit</tp:member-ref> property is
<strong>false</strong> and this method does nothing.
</p>
<p>
Note: Media players which can be D-Bus activated, or for which there is
no sensibly easy way to terminate a running instance (via the main
interface or a notification area icon for example) should allow clients
to use this method. Otherwise, it should not be needed.
</p>
<p>If the media player does not have a UI, this should be implemented.</p>
</tp:docstring>
</method>
<property name="CanQuit" type="b" tp:name-for-bindings="Can_Quit" access="read">
<tp:docstring xmlns="http://www.w3.org/1999/xhtml">
<p>
If <strong>false</strong>, calling
<tp:member-ref>Quit</tp:member-ref> will have no effect, and may
raise a NotSupported error. If <strong>true</strong>, calling
<tp:member-ref>Quit</tp:member-ref> will cause the media application
to attempt to quit (although it may still be prevented from quitting
by the user, for example).
</p>
</tp:docstring>
</property>
<property name="Fullscreen" type="b" tp:name-for-bindings="Fullscreen" access="readwrite">
<tp:added version="2.2" />
<annotation name="org.mpris.MediaPlayer2.property.optional" value="true"/>
<tp:docstring xmlns="http://www.w3.org/1999/xhtml">
<p>Whether the media player is occupying the fullscreen.</p>
<p>
This is typically used for videos. A value of <strong>true</strong>
indicates that the media player is taking up the full screen.
</p>
<p>
Media centre software may well have this value fixed to <strong>true</strong>
</p>
<p>
If <tp:member-ref>CanSetFullscreen</tp:member-ref> is <strong>true</strong>,
clients may set this property to <strong>true</strong> to tell the media player
to enter fullscreen mode, or to <strong>false</strong> to return to windowed
mode.
</p>
<p>
If <tp:member-ref>CanSetFullscreen</tp:member-ref> is <strong>false</strong>,
then attempting to set this property should have no effect, and may raise
an error. However, even if it is <strong>true</strong>, the media player
may still be unable to fulfil the request, in which case attempting to set
this property will have no effect (but should not raise an error).
</p>
<tp:rationale>
<p>
This allows remote control interfaces, such as LIRC or mobile devices like
phones, to control whether a video is shown in fullscreen.
</p>
</tp:rationale>
</tp:docstring>
</property>
<property name="CanSetFullscreen" type="b" tp:name-for-bindings="Can_Set_Fullscreen" access="read">
<tp:added version="2.2" />
<annotation name="org.mpris.MediaPlayer2.property.optional" value="true"/>
<tp:docstring xmlns="http://www.w3.org/1999/xhtml">
<p>
If <strong>false</strong>, attempting to set
<tp:member-ref>Fullscreen</tp:member-ref> will have no effect, and may
raise an error. If <strong>true</strong>, attempting to set
<tp:member-ref>Fullscreen</tp:member-ref> will not raise an error, and (if it
is different from the current value) will cause the media player to attempt to
enter or exit fullscreen mode.
</p>
<p>
Note that the media player may be unable to fulfil the request.
In this case, the value will not change. If the media player knows in
advance that it will not be able to fulfil the request, however, this
property should be <strong>false</strong>.
</p>
<tp:rationale>
<p>
This allows clients to choose whether to display controls for entering
or exiting fullscreen mode.
</p>
</tp:rationale>
</tp:docstring>
</property>
<property name="CanRaise" type="b" tp:name-for-bindings="Can_Raise" access="read">
<tp:docstring xmlns="http://www.w3.org/1999/xhtml">
<p>
If <strong>false</strong>, calling
<tp:member-ref>Raise</tp:member-ref> will have no effect, and may
raise a NotSupported error. If <strong>true</strong>, calling
<tp:member-ref>Raise</tp:member-ref> will cause the media application
to attempt to bring its user interface to the front, although it may
be prevented from doing so (by the window manager, for example).
</p>
</tp:docstring>
</property>
<property name="HasTrackList" type="b" tp:name-for-bindings="Has_TrackList" access="read">
<tp:docstring xmlns="http://www.w3.org/1999/xhtml">
<p>
Indicates whether the <strong>/org/mpris/MediaPlayer2</strong>
object implements the <strong>org.mpris.MediaPlayer2.TrackList</strong>
interface.
</p>
</tp:docstring>
</property>
<property name="Identity" type="s" tp:name-for-bindings="Identity" access="read">
<tp:docstring xmlns="http://www.w3.org/1999/xhtml">
<p>A friendly name to identify the media player to users.</p>
<p>This should usually match the name found in .desktop files</p>
<p>(eg: "VLC media player").</p>
</tp:docstring>
</property>
<property name="DesktopEntry" type="s" tp:name-for-bindings="Desktop_Entry" access="read">
<annotation name="org.mpris.MediaPlayer2.property.optional" value="true"/>
<tp:docstring xmlns="http://www.w3.org/1999/xhtml">
<p>The basename of an installed .desktop file which complies with the <a href="http://standards.freedesktop.org/desktop-entry-spec/latest/">Desktop entry specification</a>,
with the ".desktop" extension stripped.</p>
<p>
Example: The desktop entry file is "/usr/share/applications/vlc.desktop",
and this property contains "vlc"
</p>
</tp:docstring>
</property>
<property name="SupportedUriSchemes" type="as" tp:name-for-bindings="Supported_Uri_Schemes" access="read">
<tp:docstring xmlns="http://www.w3.org/1999/xhtml">
<p>
The URI schemes supported by the media player.
</p>
<p>
This can be viewed as protocols supported by the player in almost
all cases. Almost every media player will include support for the
"file" scheme. Other common schemes are "http" and "rtsp".
</p>
<p>
Note that URI schemes should be lower-case.
</p>
<tp:rationale>
<p>
This is important for clients to know when using the editing
capabilities of the Playlist interface, for example.
</p>
</tp:rationale>
</tp:docstring>
</property>
<property name="SupportedMimeTypes" type="as" tp:name-for-bindings="Supported_Mime_Types" access="read">
<tp:docstring xmlns="http://www.w3.org/1999/xhtml">
<p>
The mime-types supported by the media player.
</p>
<p>
Mime-types should be in the standard format (eg: audio/mpeg or
application/ogg).
</p>
<tp:rationale>
<p>
This is important for clients to know when using the editing
capabilities of the Playlist interface, for example.
</p>
</tp:rationale>
</tp:docstring>
</property>
</interface>
</node>
<!-- vim:set sw=2 sts=2 et ft=xml: -->
-176
View File
@@ -1,176 +0,0 @@
#include "mprisapplication.h"
#include <QDBusConnection>
#include "mediaplayer2adaptor.h"
#include "playeradaptor.h"
struct MprisApplicationPrivate {
std::unique_ptr<MediaPlayer2Adaptor> adaptor;
bool canQuit = false;
bool canRaise = false;
bool canSetFullscreen = false;
QString desktopEntry;
bool fullscreen = false;
bool hasTrackList = false;
QString identity;
QStringList supportedMimeTypes;
QStringList supportedUriSchemes;
};
MprisApplication::MprisApplication(const QString &appId, QObject *parent)
: QObject(parent)
, d(std::make_unique<MprisApplicationPrivate>())
{
d->adaptor = std::make_unique<MediaPlayer2Adaptor>(this);
QDBusConnection::sessionBus().registerService(QStringLiteral("org.mpris.MediaPlayer2.") + appId);
if (!QDBusConnection::sessionBus().registerObject(QStringLiteral("/org/mpris/MediaPlayer2"), this)) {
qWarning() << "Failed to register MPRIS interface";
}
}
MprisApplication::~MprisApplication() = default;
bool MprisApplication::canQuit() const
{
return d->canQuit;
}
void MprisApplication::setCanQuit(bool canQuit)
{
if (d->canQuit == canQuit) {
return;
}
d->canQuit = canQuit;
Q_EMIT canQuitChanged();
}
bool MprisApplication::canRaise() const
{
return d->canRaise;
}
void MprisApplication::setCanRaise(bool canRaise)
{
if (d->canRaise == canRaise) {
return;
}
d->canRaise = canRaise;
Q_EMIT canRaiseChanged();
}
bool MprisApplication::canSetFullscreen() const
{
return d->canSetFullscreen;
}
void MprisApplication::setCanSetFullscreen(bool can)
{
if (d->canSetFullscreen == can) {
return;
}
d->canSetFullscreen = can;
Q_EMIT canSetFullscreenChanged();
}
QString MprisApplication::desktopEntry() const
{
return d->desktopEntry;
}
void MprisApplication::setDesktopEntry(const QString &entry)
{
if (d->desktopEntry == entry) {
return;
}
d->desktopEntry = entry;
Q_EMIT desktopEntryChanged();
}
bool MprisApplication::fullscreen() const
{
return d->fullscreen;
}
void MprisApplication::setFullscreen(bool value)
{
if (d->fullscreen == value) {
return;
}
d->fullscreen = value;
Q_EMIT fullscreenChanged();
}
bool MprisApplication::hasTrackList() const
{
return d->hasTrackList;
}
void MprisApplication::setHasTrackList(bool has)
{
if (d->hasTrackList == has) {
return;
}
d->hasTrackList = has;
Q_EMIT hasTrackListChanged();
}
QString MprisApplication::identity() const
{
return d->identity;
}
void MprisApplication::setIdentity(const QString &appName)
{
if (d->identity == appName) {
return;
}
d->identity = appName;
Q_EMIT identityChanged();
}
QStringList MprisApplication::supportedMimeTypes() const
{
return d->supportedMimeTypes;
}
void MprisApplication::setSupportedMimeTypes(const QStringList &types) {
if (d->supportedMimeTypes == types) {
return;
}
d->supportedMimeTypes = types;
Q_EMIT supportedMimeTypesChanged();
}
QStringList MprisApplication::supportedUriSchemes() const
{
return d->supportedUriSchemes;
}
void MprisApplication::setSupportedUriSchemes(const QStringList &schemes)
{
if (d->supportedUriSchemes == schemes) {
return;
}
d->supportedMimeTypes = schemes;
Q_EMIT supportedUriSchemesChanged();
}
void MprisApplication::Quit()
{
Q_EMIT quitRequested();
}
void MprisApplication::Raise()
{
Q_EMIT raiseRequested();
}
-90
View File
@@ -1,90 +0,0 @@
#ifndef MPRISAPPLICATION_H
#define MPRISAPPLICATION_H
#include <QObject>
#include <memory>
struct MprisApplicationPrivate;
class MprisApplication : public QObject
{
Q_OBJECT
// DBus property names
Q_PROPERTY(bool CanQuit READ canQuit NOTIFY canQuitChanged)
Q_PROPERTY(bool CanRaise READ canRaise NOTIFY canRaiseChanged)
Q_PROPERTY(bool CanSetFullscreen READ canSetFullscreen NOTIFY canSetFullscreenChanged)
Q_PROPERTY(QString DesktopEntry READ desktopEntry NOTIFY desktopEntryChanged)
Q_PROPERTY(bool Fullscreen READ fullscreen WRITE setFullscreen NOTIFY fullscreenChanged)
Q_PROPERTY(bool HasTrackList READ hasTrackList NOTIFY hasTrackListChanged)
Q_PROPERTY(QString Identity READ identity NOTIFY identityChanged)
Q_PROPERTY(QStringList SupportedMimeTypes READ supportedMimeTypes NOTIFY supportedMimeTypesChanged)
Q_PROPERTY(QStringList SupportedUriSchemes READ supportedUriSchemes NOTIFY supportedUriSchemes)
// QML property names
Q_PROPERTY(bool canQuit READ canQuit WRITE setCanQuit NOTIFY canQuitChanged)
Q_PROPERTY(bool canRaise READ canRaise WRITE setCanRaise NOTIFY canRaiseChanged)
Q_PROPERTY(bool canSetFullscreen READ canSetFullscreen NOTIFY canSetFullscreenChanged)
Q_PROPERTY(QString desktopEntry READ desktopEntry NOTIFY desktopEntryChanged)
Q_PROPERTY(bool fullscreen READ fullscreen WRITE setFullscreen NOTIFY fullscreenChanged)
Q_PROPERTY(bool hasTrackList READ hasTrackList NOTIFY hasTrackListChanged)
Q_PROPERTY(QString identity READ identity NOTIFY identityChanged)
Q_PROPERTY(QStringList supportedMimeTypes READ supportedMimeTypes NOTIFY supportedMimeTypesChanged)
Q_PROPERTY(QStringList supportedUriSchemes READ supportedUriSchemes NOTIFY supportedUriSchemes)
friend class MediaPlayer2Adaptor;
public:
explicit MprisApplication(const QString &appId, QObject *parent = nullptr);
~MprisApplication();
bool canQuit() const;
void setCanQuit(bool canQuit);
Q_SIGNAL void canQuitChanged();
bool canRaise() const;
void setCanRaise(bool canRaise);
Q_SIGNAL void canRaiseChanged();
bool canSetFullscreen() const;
void setCanSetFullscreen(bool can);
Q_SIGNAL void canSetFullscreenChanged();
QString desktopEntry() const;
void setDesktopEntry(const QString &entry);
Q_SIGNAL void desktopEntryChanged();
bool fullscreen() const;
void setFullscreen(bool value);
Q_SIGNAL void fullscreenChanged();
bool hasTrackList() const;
void setHasTrackList(bool has);
Q_SIGNAL void hasTrackListChanged();
QString identity() const;
void setIdentity(const QString &appName);
Q_SIGNAL void identityChanged();
QStringList supportedMimeTypes() const;
void setSupportedMimeTypes(const QStringList &types);
Q_SIGNAL void supportedMimeTypesChanged();
QStringList supportedUriSchemes() const;
void setSupportedUriSchemes(const QStringList &schemes);
Q_SIGNAL void supportedUriSchemesChanged();
protected:
void Quit();
void Raise();
Q_SIGNALS:
void quitRequested();
void raiseRequested();
private:
std::unique_ptr<MprisApplicationPrivate> d;
};
#endif // MPRISAPPLICATION_H
-60
View File
@@ -1,60 +0,0 @@
#include "mprisplayer.h"
#include <playeradaptor.h>
MprisPlayer::MprisPlayer(QObject *parent)
: QObject(parent)
, m_adaptor(std::make_unique<PlayerAdaptor>(this))
{
QDBusConnection::sessionBus().registerService(QStringLiteral("org.mpris.MediaPlayer2.") + "audiotube");
if (!QDBusConnection::sessionBus().registerObject(QStringLiteral("/org/mpris/MediaPlayer2"), this)) {
qWarning() << "Failed to register MPRIS interface";
}
}
void MprisPlayer::Next()
{
Q_EMIT nextRequested();
}
void MprisPlayer::OpenUri(const QString &uri)
{
Q_EMIT openUriRequested(uri);
}
void MprisPlayer::Pause()
{
Q_EMIT pauseRequested();
}
void MprisPlayer::Play()
{
Q_EMIT playRequested();
}
void MprisPlayer::PlayPause()
{
Q_EMIT playPauseRequested();
}
void MprisPlayer::Previous()
{
Q_EMIT previousRequested();
}
void MprisPlayer::Seek(qlonglong offset)
{
Q_EMIT seekRequested(offset);
}
void MprisPlayer::SetPosition(const QDBusObjectPath &trackId, qlonglong position)
{
Q_EMIT setPositionRequested(MprisTrack {}, position); // TODO write MprisTrack class
}
void MprisPlayer::Stop()
{
Q_EMIT stopRequested();
}
MprisPlayer::~MprisPlayer() = default;
-59
View File
@@ -1,59 +0,0 @@
#ifndef MPRISPLAYER_H
#define MPRISPLAYER_H
#include <QObject>
#include <QString>
#include <memory>
class PlayerAdaptor;
class QDBusObjectPath;
class MprisTrack {};
class MprisPlayer : public QObject
{
Q_OBJECT
friend class PlayerAdaptor;
public:
explicit MprisPlayer(QObject *parent = nullptr);
~MprisPlayer();
void setCanQuit(bool canQuit);
void setCanRaise(bool canRaise);
void setCanSetFullscreen(bool canSetFullscreen);
void setDesktopEntry(const QString &entry);
void setFullscreen(bool fullscreen);
void setHasTrackList(bool hasTrackList);
void setIdentity(const QString &playerName);
void setSupportedMimeTypes(const QStringList &mimeTypes);
void setSupportedUriSchemes(const QStringList &uriSchemes);
protected:
void Next();
void OpenUri(const QString &uri);
void Pause();
void Play();
void PlayPause();
void Previous();
void Seek(qlonglong offset);
void SetPosition(const QDBusObjectPath &trackId, qlonglong position);
void Stop();
Q_SIGNALS:
void nextRequested();
void openUriRequested(const QString &uri);
void pauseRequested();
void playRequested();
void playPauseRequested();
void previousRequested();
void seekRequested(qlonglong offset);
void setPositionRequested(const MprisTrack &track, qlonglong position);
void stopRequested();
private:
std::unique_ptr<PlayerAdaptor> m_adaptor;
};
#endif // MPRISPLAYER_H
-76
View File
@@ -1,76 +0,0 @@
// SPDX-FileCopyrightText: 2021 Jonah Brüchert <[email protected]>
//
// SPDX-License-Identifier: GPL-2.0-only OR GPL-3.0-only OR LicenseRef-KDE-Accepted-GPL
#pragma once
#include <variant>
#include <tuple>
#include <vector>
#include <QtGlobal>
// MultiIterableView is usually used on a small number of vectors.
// The number is already known, so we can convert this into an if else if else etc tree
// instead of recursively calling the function
#ifdef __GNUC__
#define REMOVE_RECURSION __attribute__((always_inline))
#else
#define REMOVE_RECURSION
#endif
template <typename... Arguments>
class MultiIterableView {
private:
template<typename T, size_t i, size_t len>
REMOVE_RECURSION inline size_t count(const T &tuple, int initial_size = 0) const {
if constexpr(i < len) {
return count<T, i + 1, len>(tuple, initial_size + std::get<i>(tuple).size());
} else {
return initial_size;
}
}
template<typename T, size_t tuple_i, size_t tuple_len>
REMOVE_RECURSION inline std::variant<Arguments...> get_item(const T &tuple, size_t i) const {
if constexpr(tuple_i < tuple_len) {
if (i < std::get<tuple_i>(tuple).size()) {
return std::get<tuple_i>(tuple)[i];
} else {
return get_item<T, tuple_i + 1, tuple_len>(tuple, i - std::get<tuple_i>(tuple).size());
}
} else {
Q_UNREACHABLE();
}
}
template<typename T, size_t i, size_t len>
REMOVE_RECURSION inline bool everything_empty(const T &tuple, bool initial_state = true) const {
if constexpr(i < len) {
return everything_empty<T, i + 1, len>(tuple, initial_state && std::get<i>(tuple).empty());
} else {
return initial_state;
}
}
public:
explicit MultiIterableView(const std::vector<Arguments> &...lists)
: m_vectors(std::make_tuple(lists...))
{
}
size_t size() const {
constexpr size_t nvecs = std::tuple_size_v<decltype(m_vectors)>;
return count<decltype(m_vectors), 0, nvecs>(m_vectors);
}
std::variant<Arguments...> operator[](size_t i) const {
constexpr size_t nvecs = std::tuple_size_v<decltype(m_vectors)>;
return get_item<decltype(m_vectors), 0, nvecs>(m_vectors, i);
}
bool empty() const {
constexpr size_t nvecs = std::tuple_size_v<decltype(m_vectors)>;
return everything_empty<decltype(m_vectors), 0, nvecs>(m_vectors);
}
private:
std::tuple<std::vector<Arguments>...> m_vectors;
};
+113 -42
View File
@@ -1,46 +1,47 @@
// SPDX-FileCopyrightText: 2021 Jonah Brüchert <[email protected]>
//
// SPDX-License-Identifier: GPL-2.0-only OR GPL-3.0-only OR LicenseRef-KDE-Accepted-GPL
// SPDX-License-Identifier: GPL-2.0-or-later
#include "playlistmodel.h"
#include <QUrl>
#include "asyncytmusic.h"
#include "playlistutils.h"
#include <asyncytmusic.h>
PlaylistModel::PlaylistModel(QObject *parent)
: QAbstractListModel(parent)
{
connect(this, &PlaylistModel::playlistIdChanged, this, [=] {
connect(this, &PlaylistModel::initialVideoIdChanged, this, [=] {
if (m_initialVideoId.isEmpty()) {
return;
}
setLoading(true);
YTMusicThread::instance()->fetchPlaylist(m_playlistId);
AsyncYTMusic::instance().fetchWatchPlaylist(m_initialVideoId);
});
connect(&YTMusicThread::instance().get(), &AsyncYTMusic::fetchPlaylistFinished, this, [=](const playlist::Playlist &playlist) {
connect(this, &PlaylistModel::playlistIdChanged, this, [=] {
if (m_playlistId.isEmpty()) {
return;
}
setLoading(true);
AsyncYTMusic::instance().fetchWatchPlaylist(std::nullopt, m_playlistId);
});
connect(&AsyncYTMusic::instance(), &AsyncYTMusic::fetchWatchPlaylistFinished, this, [=](const watch::Playlist &playlist) {
setLoading(false);
beginResetModel();
m_playlist = playlist;
std::sort(m_playlist.thumbnails.begin(), m_playlist.thumbnails.end());
if (!m_playlist.tracks.empty()) {
m_currentVideoId = QString::fromStdString(m_playlist.tracks.front().video_id);
}
endResetModel();
Q_EMIT titleChanged();
Q_EMIT thumbnailUrlChanged();
currentVideoIdChanged();
});
}
int PlaylistModel::rowCount(const QModelIndex &parent) const
{
return parent.isValid() ? 0 : int(m_playlist.tracks.size());
}
QHash<int, QByteArray> PlaylistModel::roleNames() const
{
return {
{Title, "title"},
{Artists, "artists"},
{VideoId, "videoId"}
};
return parent.isValid() ? 0 : m_playlist.tracks.size();
}
QVariant PlaylistModel::data(const QModelIndex &index, int role) const
@@ -48,13 +49,18 @@ QVariant PlaylistModel::data(const QModelIndex &index, int role) const
switch (role) {
case Title:
return QString::fromStdString(m_playlist.tracks[index.row()].title);
case Artists:
return PlaylistUtils::artistsToString(m_playlist.tracks[index.row()].artists);
case VideoId:
if (m_playlist.tracks[index.row()].video_id) {
return QString::fromStdString(*m_playlist.tracks[index.row()].video_id);
}
return {};
return QString::fromStdString(m_playlist.tracks[index.row()].video_id);
case Artists: {
const auto artists = m_playlist.tracks[index.row()].artists;
QStringList artistNames;
std::transform(artists.begin(), artists.end(), std::back_inserter(artistNames), [](const meta::Artist &artist) {
return QString::fromStdString(artist.name);
});
return artistNames.join(", ");
}
case IsCurrent:
return m_playlist.tracks[index.row()].video_id == m_currentVideoId.toStdString();
}
Q_UNREACHABLE();
@@ -62,18 +68,25 @@ QVariant PlaylistModel::data(const QModelIndex &index, int role) const
return {};
}
QString PlaylistModel::playlistId() const
QHash<int, QByteArray> PlaylistModel::roleNames() const
{
auto id = m_playlistId;
id.remove(QStringLiteral("VL")); // Workaround: get_watch_playlist only accepts
// the playlists without the leading VL
return id;
return {
{Title, "title"},
{VideoId, "videoId"},
{Artists, "artists"},
{IsCurrent, "isCurrent"}
};
}
void PlaylistModel::setPlaylistId(const QString &playlistId)
QString PlaylistModel::initialVideoId() const
{
m_playlistId = playlistId;
Q_EMIT playlistIdChanged();
return m_initialVideoId;
}
void PlaylistModel::setInitialVideoId(const QString &videoId)
{
m_initialVideoId = videoId;
Q_EMIT initialVideoIdChanged();
}
bool PlaylistModel::loading() const
@@ -87,16 +100,74 @@ void PlaylistModel::setLoading(bool loading)
Q_EMIT loadingChanged();
}
QUrl PlaylistModel::thumbnailUrl() const
QString PlaylistModel::nextVideoId() const
{
if (m_playlist.thumbnails.empty()) {
return QUrl();
auto currentTrack = std::find_if(m_playlist.tracks.begin(), m_playlist.tracks.end(),
[=](const watch::Playlist::Track &track) {
return track.video_id == m_currentVideoId.toStdString();
});
if (currentTrack == m_playlist.tracks.end() || currentTrack + 1 == m_playlist.tracks.end()) {
return {};
}
return QUrl(QString::fromStdString(m_playlist.thumbnails.back().url));
return QString::fromStdString((currentTrack + 1)->video_id);
}
QString PlaylistModel::title() const
QString PlaylistModel::currentVideoId() const
{
return QString::fromStdString(m_playlist.title);
return m_currentVideoId;
}
void PlaylistModel::setCurrentVideoId(const QString &videoId)
{
const auto old = m_currentVideoId;
m_currentVideoId = videoId;
emitCurrentVideoChanged(old);
Q_EMIT currentVideoIdChanged();
}
void PlaylistModel::next()
{
const auto old = m_currentVideoId;
m_currentVideoId = nextVideoId();
emitCurrentVideoChanged(old);
Q_EMIT currentVideoIdChanged();
}
void PlaylistModel::skipTo(const QString &videoId)
{
const auto old = m_currentVideoId;
m_currentVideoId = videoId;
emitCurrentVideoChanged(old);
Q_EMIT currentVideoIdChanged();
}
void PlaylistModel::emitCurrentVideoChanged(const QString &oldVideoId)
{
const auto oldVideoIt = std::find_if(m_playlist.tracks.begin(), m_playlist.tracks.end(),
[=](const watch::Playlist::Track &track) {
return track.video_id == oldVideoId.toStdString();
});
const auto currentVideoIt = std::find_if(m_playlist.tracks.begin(), m_playlist.tracks.end(),
[=](const watch::Playlist::Track &track) {
return track.video_id == m_currentVideoId.toStdString();
});
int oldIndex = std::distance(m_playlist.tracks.begin(), oldVideoIt);
int newIndex = std::distance(m_playlist.tracks.begin(), currentVideoIt);
dataChanged(index(oldIndex), index(oldIndex), {IsCurrent});
dataChanged(index(newIndex), index(newIndex), {IsCurrent});
}
QString PlaylistModel::playlistId() const
{
return m_playlistId;
}
void PlaylistModel::setPlaylistId(const QString &playlistId)
{
m_playlistId = playlistId;
Q_EMIT playlistIdChanged();
}
+33 -21
View File
@@ -1,10 +1,10 @@
// SPDX-FileCopyrightText: 2021 Jonah Brüchert <[email protected]>
// SPDX-FileCopyrightText: 2021 Jonah Brüchert <[email protected]>
//
// SPDX-License-Identifier: GPL-2.0-only OR GPL-3.0-only OR LicenseRef-KDE-Accepted-GPL
// SPDX-License-Identifier: GPL-2.0-or-later
#pragma once
#include <QAbstractListModel>
#include <ytmusic.h>
class PlaylistModel : public QAbstractListModel
@@ -12,43 +12,55 @@ class PlaylistModel : public QAbstractListModel
Q_OBJECT
// input
Q_PROPERTY(QString playlistId READ playlistId WRITE setPlaylistId NOTIFY playlistIdChanged REQUIRED)
Q_PROPERTY(QString initialVideoId READ initialVideoId WRITE setInitialVideoId NOTIFY initialVideoIdChanged)
Q_PROPERTY(QString playlistId READ playlistId WRITE setPlaylistId NOTIFY playlistIdChanged)
// output
Q_PROPERTY(bool loading READ loading WRITE setLoading NOTIFY loadingChanged)
Q_PROPERTY(QUrl thumbnailUrl READ thumbnailUrl NOTIFY thumbnailUrlChanged)
Q_PROPERTY(QString title READ title NOTIFY titleChanged)
Q_PROPERTY(QString currentVideoId READ currentVideoId NOTIFY currentVideoIdChanged)
public:
explicit PlaylistModel(QObject *parent = nullptr);
enum Role {
Title,
Title = Qt::UserRole + 1,
VideoId,
Artists,
VideoId
IsCurrent
};
int rowCount(const QModelIndex &parent) const override;
QHash<int, QByteArray> roleNames() const override;
QVariant data(const QModelIndex &index, int role) const override;
explicit PlaylistModel(QObject *parent = nullptr);
QString playlistId() const;
void setPlaylistId(const QString &playlistId);
Q_SIGNAL void playlistIdChanged();
int rowCount(const QModelIndex &parent) const override;
QVariant data(const QModelIndex &index, int role) const override;
QHash<int, QByteArray> roleNames() const override;
QString initialVideoId() const;
void setInitialVideoId(const QString &videoId);
Q_SIGNAL void initialVideoIdChanged();
bool loading() const;
void setLoading(bool loading);
Q_SIGNAL void loadingChanged();
QUrl thumbnailUrl() const;
Q_SIGNAL void thumbnailUrlChanged();
QString nextVideoId() const;
QString title() const;
Q_SIGNAL void titleChanged();
QString currentVideoId() const;
void setCurrentVideoId(const QString &videoId);
Q_SIGNAL void currentVideoIdChanged();
Q_INVOKABLE void next();
Q_INVOKABLE void skipTo(const QString &videoId);
QString playlistId() const;
void setPlaylistId(const QString &playlistId);
Q_SIGNAL void playlistIdChanged();
private:
void emitCurrentVideoChanged(const QString &oldVideoId);
QString m_initialVideoId;
QString m_playlistId;
QString m_currentVideoId;
bool m_loading = false;
playlist::Playlist m_playlist {};
watch::Playlist m_playlist;
};
-24
View File
@@ -1,24 +0,0 @@
// SPDX-FileCopyrightText: 2021 Jonah Brüchert <[email protected]>
//
// SPDX-License-Identifier: GPL-2.0-only OR GPL-3.0-only OR LicenseRef-KDE-Accepted-GPL
#include "playlistutils.h"
#include <QString>
#include <numeric>
#include <ytmusic.h>
QString PlaylistUtils::artistsToString(const std::vector<meta::Artist> &artists)
{
if (!artists.empty()) {
return std::accumulate(artists.begin() + 1, artists.end(),
QString::fromStdString(artists.front().name),
[](QString &string, const meta::Artist &artist) {
return string.append(QStringLiteral(", %1").arg(QString::fromStdString(artist.name)));
});
}
return {};
}
-20
View File
@@ -1,20 +0,0 @@
// SPDX-FileCopyrightText: 2021 Jonah Brüchert <[email protected]>
//
// SPDX-License-Identifier: GPL-2.0-only OR GPL-3.0-only OR LicenseRef-KDE-Accepted-GPL
#pragma once
#include <vector>
class QString;
namespace meta {
struct Artist;
}
class PlaylistUtils
{
public:
PlaylistUtils() = delete;
static QString artistsToString(const std::vector<meta::Artist> &artists);
};
-2
View File
@@ -4,7 +4,5 @@
<file alias="AlbumPage.qml">contents/ui/AlbumPage.qml</file>
<file alias="ArtistPage.qml">contents/ui/ArtistPage.qml</file>
<file alias="PlayerFooter.qml">contents/ui/PlayerFooter.qml</file>
<file alias="SearchPage.qml">contents/ui/SearchPage.qml</file>
<file alias="PlaylistPage.qml">contents/ui/PlaylistPage.qml</file>
</qresource>
</RCC>
+11 -44
View File
@@ -1,9 +1,11 @@
// SPDX-FileCopyrightText: 2021 Jonah Brüchert <[email protected]>
//
// SPDX-License-Identifier: GPL-2.0-only OR GPL-3.0-only OR LicenseRef-KDE-Accepted-GPL
// SPDX-License-Identifier: GPL-2.0-or-later
#include "searchmodel.h"
#include <QDebug>
SearchModel::SearchModel(QObject *parent)
: QAbstractListModel(parent)
{
@@ -16,22 +18,23 @@ SearchModel::SearchModel(QObject *parent)
}
setLoading(true);
YTMusicThread::instance()->search(m_searchQuery);
AsyncYTMusic::instance().search(m_searchQuery);
});
connect(&YTMusicThread::instance().get(), &AsyncYTMusic::searchFinished, this, [=](const std::vector<search::SearchResultItem> &results) {
connect(&AsyncYTMusic::instance(), &AsyncYTMusic::searchFinished, this, [=](const std::vector<search::SearchResultItem> &results) {
beginResetModel();
setLoading(false);
m_searchResults = results;
endResetModel();
});
connect(&YTMusicThread::instance().get(), &AsyncYTMusic::errorOccurred, this, [=] {
setLoading(false);
});
}
SearchModel::~SearchModel()
{
}
int SearchModel::rowCount(const QModelIndex &parent) const
{
return parent.isValid() ? 0 : int(m_searchResults.size());
return parent.isValid() ? 0 : m_searchResults.size();
}
QVariant SearchModel::data(const QModelIndex &index, int role) const
@@ -71,40 +74,6 @@ QVariant SearchModel::data(const QModelIndex &index, int role) const
Q_UNREACHABLE();
}
}, m_searchResults.at(index.row()));
case VideoId:
return std::visit([&](auto&& arg) {
using T = std::decay_t<decltype(arg)>;
if constexpr (std::is_same_v<T, search::Album>) {
return QString();
} else if constexpr (std::is_same_v<T, search::Artist>) {
return QString();
} else if constexpr (std::is_same_v<T, search::Playlist>) {
return QString();
} else if constexpr (std::is_same_v<T, search::Song>) {
return QString::fromStdString(arg.video_id);
} else if constexpr (std::is_same_v<T, search::Video>) {
return QString::fromStdString(arg.video_id);
} else {
Q_UNREACHABLE();
}
}, m_searchResults.at(index.row()));
case Artists:
return QVariant::fromValue(std::visit([&](auto&& arg) {
using T = std::decay_t<decltype(arg)>;
if constexpr (std::is_same_v<T, search::Album>) {
return std::vector<meta::Artist>();
} else if constexpr (std::is_same_v<T, search::Artist>) {
return std::vector<meta::Artist>();
} else if constexpr (std::is_same_v<T, search::Playlist>) {
return std::vector<meta::Artist>();
} else if constexpr (std::is_same_v<T, search::Song>) {
return arg.artists;
} else if constexpr (std::is_same_v<T, search::Video>) {
return arg.artists;
} else {
Q_UNREACHABLE();
}
}, m_searchResults.at(index.row())));
}
Q_UNREACHABLE();
@@ -116,9 +85,7 @@ QHash<int, QByteArray> SearchModel::roleNames() const
{
return {
{Title, "title"},
{Type, "type"},
{VideoId, "videoId"},
{Artists, "artists"}
{Type, "type"}
};
}
+3 -4
View File
@@ -1,6 +1,6 @@
// SPDX-FileCopyrightText: 2021 Jonah Brüchert <[email protected]>
//
// SPDX-License-Identifier: GPL-2.0-only OR GPL-3.0-only OR LicenseRef-KDE-Accepted-GPL
// SPDX-License-Identifier: GPL-2.0-or-later
#pragma once
@@ -28,12 +28,11 @@ public:
enum Role {
Title = Qt::UserRole + 1,
Type,
VideoId,
Artists
Type
};
explicit SearchModel(QObject *parent = nullptr);
~SearchModel();
int rowCount(const QModelIndex &parent) const override;
QVariant data(const QModelIndex &index, int role) const override;
-308
View File
@@ -1,308 +0,0 @@
// SPDX-FileCopyrightText: 2021 Jonah Brüchert <[email protected]>
//
// SPDX-License-Identifier: GPL-2.0-only OR GPL-3.0-only OR LicenseRef-KDE-Accepted-GPL
#include "userplaylistmodel.h"
#include <asyncytmusic.h>
#include <algorithm>
#include <random>
#include <QRandomGenerator>
#include "playlistutils.h"
UserPlaylistModel::UserPlaylistModel(QObject *parent)
: QAbstractListModel(parent)
, m_mprisApp(QStringLiteral("audiotube"))
, m_mprisPlayer()
{
connect(this, &UserPlaylistModel::initialVideoIdChanged, this, [=] {
if (m_initialVideoId.isEmpty()) {
return;
}
setLoading(true);
YTMusicThread::instance()->fetchWatchPlaylist(m_initialVideoId);
});
connect(this, &UserPlaylistModel::playlistIdChanged, this, [=] {
if (m_playlistId.isEmpty()) {
return;
}
setLoading(true);
YTMusicThread::instance()->fetchWatchPlaylist(std::nullopt, m_playlistId);
});
connect(&YTMusicThread::instance().get(), &AsyncYTMusic::fetchWatchPlaylistFinished, this, [=](const watch::Playlist &playlist) {
setLoading(false);
beginResetModel();
m_playlist = playlist;
endResetModel();
if (m_shuffle) {
shufflePlaylist();
// reset shuffle
setShuffle(false);
}
if (!m_playlist.tracks.empty()) {
setCurrentVideoId(QString::fromStdString(m_playlist.tracks.front().video_id));
} else {
setCurrentVideoId({});
}
});
connect(&YTMusicThread::instance().get(), &AsyncYTMusic::errorOccurred, this, [=] {
setLoading(false);
});
m_mprisApp.setCanQuit(true);
m_mprisApp.setDesktopEntry("org.kde.audiotube.desktop");
m_mprisApp.setIdentity(QStringLiteral("AudioTube"));
}
int UserPlaylistModel::rowCount(const QModelIndex &parent) const
{
return parent.isValid() ? 0 : int(m_playlist.tracks.size());
}
QVariant UserPlaylistModel::data(const QModelIndex &index, int role) const
{
switch (role) {
case Title:
return QString::fromStdString(m_playlist.tracks[index.row()].title);
case VideoId:
return QString::fromStdString(m_playlist.tracks[index.row()].video_id);
case Artists:
return PlaylistUtils::artistsToString(m_playlist.tracks[index.row()].artists);
case IsCurrent:
return m_playlist.tracks[index.row()].video_id == m_currentVideoId.toStdString();
}
Q_UNREACHABLE();
return {};
}
QHash<int, QByteArray> UserPlaylistModel::roleNames() const
{
return {
{Title, "title"},
{VideoId, "videoId"},
{Artists, "artists"},
{IsCurrent, "isCurrent"}
};
}
QString UserPlaylistModel::initialVideoId() const
{
return m_initialVideoId;
}
void UserPlaylistModel::setInitialVideoId(const QString &videoId)
{
m_initialVideoId = videoId;
Q_EMIT initialVideoIdChanged();
}
bool UserPlaylistModel::loading() const
{
return m_loading;
}
void UserPlaylistModel::setLoading(bool loading)
{
m_loading = loading;
Q_EMIT loadingChanged();
}
QString UserPlaylistModel::nextVideoId() const
{
auto currentTrack = std::find_if(m_playlist.tracks.begin(), m_playlist.tracks.end(),
[=](const watch::Playlist::Track &track) {
return track.video_id == m_currentVideoId.toStdString();
});
if (currentTrack == m_playlist.tracks.end() || currentTrack + 1 == m_playlist.tracks.end()) {
return {};
}
return QString::fromStdString((currentTrack + 1)->video_id);
}
QString UserPlaylistModel::currentVideoId() const
{
return m_currentVideoId;
}
void UserPlaylistModel::setCurrentVideoId(const QString &videoId)
{
const auto old = m_currentVideoId;
m_currentVideoId = videoId;
emitCurrentVideoChanged(old);
Q_EMIT currentVideoIdChanged();
Q_EMIT canSkipChanged();
}
bool UserPlaylistModel::canSkip() const
{
const auto currentTrackIt = std::find_if(m_playlist.tracks.begin(), m_playlist.tracks.end(),
[=](const watch::Playlist::Track &track) {
return track.video_id == m_currentVideoId.toStdString();
});
return currentTrackIt != m_playlist.tracks.end() - 1
&& currentTrackIt != m_playlist.tracks.end()
&& !m_playlist.tracks.empty();
}
void UserPlaylistModel::next()
{
setCurrentVideoId(nextVideoId());
Q_EMIT currentVideoIdChanged();
Q_EMIT canSkipChanged();
}
void UserPlaylistModel::skipTo(const QString &videoId)
{
const auto old = m_currentVideoId;
m_currentVideoId = videoId;
emitCurrentVideoChanged(old);
Q_EMIT currentVideoIdChanged();
Q_EMIT canSkipChanged();
}
void UserPlaylistModel::playNext(const QString &videoId, const QString &title, const std::vector<meta::Artist> &artists)
{
const auto currentIt = std::find_if(m_playlist.tracks.begin(), m_playlist.tracks.end(),
[=](const watch::Playlist::Track &track) {
return track.video_id == m_currentVideoId.toStdString();
});
watch::Playlist::Track track;
track.video_id = videoId.toStdString();
track.title = title.toStdString();
track.artists = artists;
if (currentIt == m_playlist.tracks.end() || m_playlist.tracks.empty()) {
beginInsertRows({}, 0, 0);
m_playlist.tracks.push_back(std::move(track));
endInsertRows();
setCurrentVideoId(videoId);
Q_EMIT canSkipChanged();
return;
}
if (currentIt == m_playlist.tracks.end() - 1) {
int index = std::distance(m_playlist.tracks.begin(), currentIt + 1);
beginInsertRows({}, index, index);
m_playlist.tracks.push_back(std::move(track));
endInsertRows();
Q_EMIT canSkipChanged();
return;
}
int index = std::distance(m_playlist.tracks.begin(), currentIt + 1);
beginInsertRows({}, index, index);
m_playlist.tracks.insert(currentIt + 1, std::move(track));
endInsertRows();
Q_EMIT canSkipChanged();
}
void UserPlaylistModel::append(const QString &videoId, const QString &title, const std::vector<meta::Artist> &artists)
{
watch::Playlist::Track track;
track.video_id = videoId.toStdString();
track.title = title.toStdString();
track.artists = artists;
beginInsertRows({}, m_playlist.tracks.size(), m_playlist.tracks.size());
m_playlist.tracks.push_back(std::move(track));
endInsertRows();
if (m_playlist.tracks.size() == 1) {
setCurrentVideoId(videoId);
}
}
void UserPlaylistModel::clear()
{
beginResetModel();
m_playlist.tracks.clear();
endResetModel();
setCurrentVideoId({});
Q_EMIT canSkipChanged();
}
void UserPlaylistModel::remove(const QString &videoId)
{
if (m_currentVideoId == videoId) {
setCurrentVideoId(nextVideoId());
}
const auto trackIt = std::find_if(m_playlist.tracks.begin(), m_playlist.tracks.end(), [&](const watch::Playlist::Track &track) {
return track.video_id == videoId.toStdString();
});
int index = std::distance(m_playlist.tracks.begin(), trackIt);
beginRemoveRows({}, index, index);
m_playlist.tracks.erase(trackIt);
endRemoveRows();
Q_EMIT canSkipChanged();
}
void UserPlaylistModel::shufflePlaylist()
{
// Only shuffle playlist after current track
if (!m_currentVideoId.isEmpty()) {
const auto currentIt = std::find_if(m_playlist.tracks.begin(), m_playlist.tracks.end(),
[=](const watch::Playlist::Track &track) {
return track.video_id == m_currentVideoId.toStdString();
});
std::shuffle(currentIt + 1, m_playlist.tracks.end(), *QRandomGenerator::global());
} else {
std::shuffle(m_playlist.tracks.begin(), m_playlist.tracks.end(), *QRandomGenerator::global());
}
Q_EMIT dataChanged(index(0), index(m_playlist.tracks.size() - 1), {});
}
void UserPlaylistModel::emitCurrentVideoChanged(const QString &oldVideoId)
{
const auto oldVideoIt = std::find_if(m_playlist.tracks.begin(), m_playlist.tracks.end(),
[=](const watch::Playlist::Track &track) {
return track.video_id == oldVideoId.toStdString();
});
const auto currentVideoIt = std::find_if(m_playlist.tracks.begin(), m_playlist.tracks.end(),
[=](const watch::Playlist::Track &track) {
return track.video_id == m_currentVideoId.toStdString();
});
int oldIndex = std::distance(m_playlist.tracks.begin(), oldVideoIt);
int newIndex = std::distance(m_playlist.tracks.begin(), currentVideoIt);
Q_EMIT dataChanged(index(oldIndex), index(oldIndex), {IsCurrent});
Q_EMIT dataChanged(index(newIndex), index(newIndex), {IsCurrent});
}
bool UserPlaylistModel::shuffle() const
{
return m_shuffle;
}
void UserPlaylistModel::setShuffle(bool shuffle)
{
m_shuffle = shuffle;
Q_EMIT shuffleChanged();
}
QString UserPlaylistModel::playlistId() const
{
return m_playlistId;
}
void UserPlaylistModel::setPlaylistId(const QString &playlistId)
{
m_playlistId = playlistId;
Q_EMIT playlistIdChanged();
}
-87
View File
@@ -1,87 +0,0 @@
// SPDX-FileCopyrightText: 2021 Jonah Brüchert <[email protected]>
//
// SPDX-License-Identifier: GPL-2.0-only OR GPL-3.0-only OR LicenseRef-KDE-Accepted-GPL
#pragma once
#include <QAbstractListModel>
#include <ytmusic.h>
#include "mprisapplication.h"
#include "mprisplayer.h"
class UserPlaylistModel : public QAbstractListModel
{
Q_OBJECT
// input
Q_PROPERTY(QString initialVideoId READ initialVideoId WRITE setInitialVideoId NOTIFY initialVideoIdChanged)
Q_PROPERTY(QString playlistId READ playlistId WRITE setPlaylistId NOTIFY playlistIdChanged)
Q_PROPERTY(bool shuffle READ shuffle WRITE setShuffle NOTIFY shuffleChanged)
// output
Q_PROPERTY(bool loading READ loading WRITE setLoading NOTIFY loadingChanged)
Q_PROPERTY(QString currentVideoId READ currentVideoId NOTIFY currentVideoIdChanged)
Q_PROPERTY(bool canSkip READ canSkip NOTIFY canSkipChanged)
public:
enum Role {
Title = Qt::UserRole + 1,
VideoId,
Artists,
IsCurrent
};
explicit UserPlaylistModel(QObject *parent = nullptr);
int rowCount(const QModelIndex &parent) const override;
QVariant data(const QModelIndex &index, int role) const override;
QHash<int, QByteArray> roleNames() const override;
QString initialVideoId() const;
void setInitialVideoId(const QString &videoId);
Q_SIGNAL void initialVideoIdChanged();
bool loading() const;
void setLoading(bool loading);
Q_SIGNAL void loadingChanged();
QString nextVideoId() const;
QString currentVideoId() const;
void setCurrentVideoId(const QString &videoId);
Q_SIGNAL void currentVideoIdChanged();
bool canSkip() const;
Q_SIGNAL void canSkipChanged();
QString playlistId() const;
void setPlaylistId(const QString &playlistId);
Q_SIGNAL void playlistIdChanged();
void setShuffle(bool shuffle);
bool shuffle() const;
Q_SIGNAL void shuffleChanged();
Q_INVOKABLE void next();
Q_INVOKABLE void skipTo(const QString &videoId);
Q_INVOKABLE void playNext(const QString &videoId, const QString &title, const std::vector<meta::Artist> &artists);
Q_INVOKABLE void append(const QString &videoId, const QString &title, const std::vector<meta::Artist> &artists);
Q_INVOKABLE void clear();
Q_INVOKABLE void remove(const QString &videoId);
Q_INVOKABLE void shufflePlaylist();
private:
void emitCurrentVideoChanged(const QString &oldVideoId);
QString m_initialVideoId;
QString m_playlistId;
QString m_currentVideoId;
bool m_loading = false;
bool m_shuffle = false;
watch::Playlist m_playlist;
MprisApplication m_mprisApp;
MprisPlayer m_mprisPlayer;
};
+6 -8
View File
@@ -1,29 +1,26 @@
// SPDX-FileCopyrightText: 2021 Jonah Brüchert <[email protected]>
//
// SPDX-License-Identifier: GPL-2.0-only OR GPL-3.0-only OR LicenseRef-KDE-Accepted-GPL
// SPDX-License-Identifier: GPL-2.0-or-later
#include "videoinfoextractor.h"
#include <asyncytmusic.h>
#include <QDebug>
VideoInfoExtractor::VideoInfoExtractor(QObject *parent)
: QObject(parent)
{
connect(this, &VideoInfoExtractor::videoIdChanged, this, [=] {
if (m_videoId.isEmpty()) {
m_videoInfo = {};
Q_EMIT audioUrlChanged();
Q_EMIT titleChanged();
Q_EMIT songChanged();
Q_EMIT thumbnailChanged();
return;
}
setLoading(true);
YTMusicThread::instance()->extractVideoInfo(QString::fromStdString(m_videoId.toStdString()));
AsyncYTMusic::instance().extractVideoInfo(QString::fromStdString(m_videoId.toStdString()));
});
connect(&YTMusicThread::instance().get(), &AsyncYTMusic::extractVideoInfoFinished, this, [=](const video_info::VideoInfo &info) {
connect(&AsyncYTMusic::instance(), &AsyncYTMusic::extractVideoInfoFinished, this, [=](const video_info::VideoInfo &info) {
m_videoInfo = info;
setLoading(false);
Q_EMIT audioUrlChanged();
@@ -82,6 +79,7 @@ QString VideoInfoExtractor::title() const
QString VideoInfoExtractor::thumbnail() const
{
qDebug() << "thumb" << QString::fromStdString(m_videoInfo.thumnnail);
return QString::fromStdString(m_videoInfo.thumnnail);
}
+1 -1
View File
@@ -1,6 +1,6 @@
// SPDX-FileCopyrightText: 2021 Jonah Brüchert <[email protected]>
//
// SPDX-License-Identifier: GPL-2.0-only OR GPL-3.0-only OR LicenseRef-KDE-Accepted-GPL
// SPDX-License-Identifier: GPL-2.0-or-later
#pragma once
+32 -45
View File
@@ -1,6 +1,6 @@
// SPDX-FileCopyrightText: 2021 Jonah Brüchert <[email protected]>
//
// SPDX-License-Identifier: GPL-2.0-only OR GPL-3.0-only OR LicenseRef-KDE-Accepted-GPL
// SPDX-License-Identifier: GPL-2.0-or-later
#include "ytmusic.h"
@@ -15,8 +15,6 @@ using namespace py::literals;
#define UNEXPORT __attribute__ ((visibility("hidden")))
constexpr auto TESTED_YTMUSICAPI_VERSION = "0.16.0";
struct UNEXPORT YTMusicPrivate {
py::scoped_interpreter guard {};
py::object ytmusic;
@@ -24,7 +22,7 @@ struct UNEXPORT YTMusicPrivate {
};
template <typename T>
std::optional<T> optional_key(py::handle obj, const char *name) {
std::optional<T> optional_key(const py::handle &obj, const char *name) {
if (!obj.cast<py::dict>().contains(name)) {
return std::nullopt;
}
@@ -32,7 +30,7 @@ std::optional<T> optional_key(py::handle obj, const char *name) {
return obj[name].cast<T>();
}
meta::Thumbnail extract_thumbnail(py::handle thumbnail) {
meta::Thumbnail extract_thumbnail(const py::handle &thumbnail) {
return {
thumbnail["url"].cast<std::string>(),
thumbnail["width"].cast<int>(),
@@ -40,14 +38,14 @@ meta::Thumbnail extract_thumbnail(py::handle thumbnail) {
};
}
meta::Artist extract_meta_artist(py::handle artist) {
meta::Artist extract_meta_artist(const py::handle &artist) {
return {
artist["name"].cast<std::string>(),
artist["id"].cast<std::optional<std::string>>()
};
};
album::Track extract_album_track(py::handle track) {
album::Track extract_album_track(const py::handle &track) {
return {
track["index"].cast<std::string>(),
track["title"].cast<std::string>(),
@@ -58,24 +56,24 @@ album::Track extract_album_track(py::handle track) {
};
}
video_info::Format extract_format(py::handle format) {
video_info::Format extract_format(const py::handle &format) {
return {
optional_key<int>(format, "quality"),
format["quality"].cast<int>(),
format["url"].cast<std::string>(),
format["vcodec"].cast<std::string>(),
format["acodec"].cast<std::string>()
};
}
playlist::Track extract_playlist_track(py::handle track);
watch::Playlist::Track extract_watch_track(py::handle track);
playlist::Track extract_playlist_track(const py::handle &track);
watch::Playlist::Track extract_watch_track(const py::handle &track);
template <typename T>
inline auto extract_py_list(py::handle obj) {
const auto list = obj.cast<py::list>();
inline auto extract_py_list(const py::handle &obj) {
const py::list list = obj.cast<py::list>();
std::vector<T> output;
std::transform(list.begin(), list.end(), std::back_inserter(output), [](py::handle item) {
std::transform(list.begin(), list.end(), std::back_inserter(output), [](const py::handle &item) {
if constexpr(std::is_same_v<T, meta::Thumbnail>) {
return extract_thumbnail(item);
} else if constexpr(std::is_same_v<T, meta::Artist>) {
@@ -96,19 +94,19 @@ inline auto extract_py_list(py::handle obj) {
return output;
}
meta::Album extract_meta_album(py::handle album) {
meta::Album extract_meta_album(const py::handle &album) {
return meta::Album {
album["name"].cast<std::string>(),
album["id"].cast<std::optional<std::string>>()
};
}
watch::Playlist::Track extract_watch_track(py::handle track) {
watch::Playlist::Track extract_watch_track(const py::handle &track) {
return {
track["title"].cast<std::string>(),
track["length"].cast<std::optional<std::string>>(),
track["length"].cast<std::string>(),
track["videoId"].cast<std::string>(),
optional_key<std::string>(track, "playlistId"),
track["playlistId"].cast<std::string>(),
extract_py_list<meta::Thumbnail>(track["thumbnail"]),
track["likeStatus"].cast<std::optional<std::string>>(),
extract_py_list<meta::Artist>(track["artists"]),
@@ -123,7 +121,7 @@ watch::Playlist::Track extract_watch_track(py::handle track) {
}
playlist::Track extract_playlist_track(py::handle track) {
playlist::Track extract_playlist_track(const py::handle &track) {
return {
track["videoId"].cast<std::optional<std::string>>(),
track["title"].cast<std::string>(),
@@ -143,7 +141,7 @@ playlist::Track extract_playlist_track(py::handle track) {
};
}
artist::Artist::Song::Album extract_song_album(py::handle album) {
artist::Artist::Song::Album extract_song_album(const py::handle &album) {
return {
album["name"].cast<std::string>(),
album["id"].cast<std::string>()
@@ -151,14 +149,14 @@ artist::Artist::Song::Album extract_song_album(py::handle album) {
};
template <typename T>
auto extract_artist_section_results(py::handle section) {
auto extract_artist_section_results(const py::handle &section) {
if (!section.cast<py::dict>().contains("results")) {
return std::vector<T>();
}
const py::list py_results = section["results"];
std::vector<T> results;
std::transform(py_results.begin(), py_results.end(), std::back_inserter(results), [](py::handle result) {
std::transform(py_results.begin(), py_results.end(), std::back_inserter(results), [](const py::handle &result) {
if constexpr(std::is_same_v<T, artist::Artist::Song>) {
return artist::Artist::Song {
result["videoId"].cast<std::string>(),
@@ -171,7 +169,7 @@ auto extract_artist_section_results(py::handle section) {
return artist::Artist::Album {
result["title"].cast<std::string>(),
extract_py_list<meta::Thumbnail>(result["thumbnails"]),
result["year"].cast<std::optional<std::string>>(),
result["year"].cast<std::string>(),
result["browseId"].cast<std::string>(),
std::nullopt
};
@@ -199,7 +197,7 @@ auto extract_artist_section_results(py::handle section) {
}
template<typename T>
std::optional<artist::Artist::Section<T>> extract_artist_section(py::handle artist, const char* name) {
std::optional<artist::Artist::Section<T>> extract_artist_section(const py::handle &artist, const char* name) {
if (artist.cast<py::dict>().contains(name)) {
const auto section = artist[name];
return artist::Artist::Section<T> {
@@ -212,8 +210,8 @@ std::optional<artist::Artist::Section<T>> extract_artist_section(py::handle arti
}
}
std::optional<search::SearchResultItem> extract_search_result(py::handle result) {
const auto resultType = result["resultType"].cast<std::string>();
search::SearchResultItem extract_search_result(const py::handle &result) {
const std::string resultType = result["resultType"].cast<std::string>();
if (resultType == "video") {
return search::Video {
{
@@ -259,10 +257,8 @@ std::optional<search::SearchResultItem> extract_search_result(py::handle result)
optional_key<std::string>(result, "radioId")
};
} else {
std::cerr << "Warning: Unsupported search result type found" << std::endl;
std::cerr << "It's called: " << resultType;
return std::nullopt;
}
Py_UNREACHABLE();
};
}
YTMusic::YTMusic(
@@ -276,12 +272,10 @@ YTMusic::YTMusic(
const auto module = py::module::import("ytmusicapi");
d->ytmusic = module.attr("YTMusic")(auth, user, requests_session, proxies, language);
setenv("LC_ALL", "en_US.utf8", true);
const auto version = module.attr("_version").attr("__version__").cast<std::string>();
if (version != TESTED_YTMUSICAPI_VERSION) {
if (version != "0.14.3") {
std::cerr << "Running with untested version of ytmusicapi." << std::endl;
std::cerr << "The currently tested and supported version is " << TESTED_YTMUSICAPI_VERSION << std::endl;
std::cerr << "The currently tested and supported version is 0.14.3" << std::endl;
}
}
@@ -294,13 +288,9 @@ std::vector<search::SearchResultItem> YTMusic::search(
const bool ignore_spelling) const
{
const auto results = d->ytmusic.attr("search")(query, filter, limit, ignore_spelling).cast<py::list>();
std::vector<search::SearchResultItem> output;
for (const auto &result : results) {
if (const auto opt = extract_search_result(result); opt.has_value()) {
output.push_back(opt.value());
}
};
std::transform(results.begin(), results.end(), std::back_inserter(output), extract_search_result);
return output;
}
@@ -400,7 +390,7 @@ std::vector<artist::Artist::Album> YTMusic::get_artist_albums(const std::string
const auto py_albums = d->ytmusic.attr("get_artist_albums")(channel_id, params);
std::vector<artist::Artist::Album> albums;
std::transform(py_albums.begin(), py_albums.end(), std::back_inserter(albums), [](py::handle album) {
std::transform(py_albums.begin(), py_albums.end(), std::back_inserter(albums), [](const py::handle &album) {
return artist::Artist::Album {
album["title"].cast<std::string>(),
extract_py_list<meta::Thumbnail>(album["thumbnails"]),
@@ -440,10 +430,7 @@ watch::Playlist YTMusic::get_watch_playlist(const std::optional<std::string> &vi
int limit,
const std::optional<std::string> &params) const
{
const auto playlist = d->ytmusic.attr("get_watch_playlist")("videoId"_a = videoId,
"playlistId"_a = playlistId,
"limit"_a = py::int_(limit),
"params"_a = params);
const auto playlist = d->ytmusic.attr("get_watch_playlist")(videoId, playlistId, limit, params);
return {
extract_py_list<watch::Playlist::Track>(playlist["tracks"]),
+7 -7
View File
@@ -1,6 +1,6 @@
// SPDX-FileCopyrightText: 2021 Jonah Brüchert <[email protected]>
//
// SPDX-License-Identifier: GPL-2.0-only OR GPL-3.0-only OR LicenseRef-KDE-Accepted-GPL
// SPDX-License-Identifier: GPL-2.0-or-later
#ifndef YTMUSIC_H
#define YTMUSIC_H
@@ -20,7 +20,7 @@ struct Thumbnail {
int width;
int height;
bool operator<(const Thumbnail &other) const {
bool operator<(const Thumbnail other) const {
return height < other.height;
}
};
@@ -107,8 +107,8 @@ struct Artist {
struct Album {
std::string title;
std::vector<meta::Thumbnail> thumbnails;
std::optional<std::string> year;
std::string browse_id;
std::string year;
std::string browseId;
std::optional<std::string> type;
};
@@ -228,7 +228,7 @@ struct Playlist {
namespace video_info {
struct Format {
std::optional<int> quality;
int quality;
std::string url;
std::string vcodec;
std::string acodec;
@@ -250,9 +250,9 @@ namespace watch {
struct Playlist {
struct Track {
std::string title;
std::optional<std::string> length;
std::string length;
std::string video_id;
std::optional<std::string> playlistId;
std::string playlistId;
std::vector<meta::Thumbnail> thumbnail;
std::optional<std::string> like_status;
std::vector<meta::Artist> artists;