Compare commits

..
Author SHA1 Message Date
Jonah Brüchert a458b36ed3 Add placeholder message to search page 2021-07-10 19:37:28 +02:00
Mathis Brüchert 1c51c183f0 move search field into header 2021-07-10 19:14:38 +02:00
Mohammad Shavez 7a69653933 Fix: Hide timestamps when queue is cleared 2021-07-10 13:24:19 +05:30
l10n daemon script f9a286b136 SVN_SILENT made messages (.desktop file) - always resolve ours
In case of conflict in i18n, keep the version of the branch "ours"
To resolve a particular conflict, "git checkout --ours path/to/file.desktop"
2021-07-05 01:18:42 +00:00
l10n daemon script 87e1a7ef90 GIT_SILENT made messages (after extraction) 2021-07-05 00:20:18 +00:00
l10n daemon script e5561d0256 SVN_SILENT made messages (.desktop file) - always resolve ours
In case of conflict in i18n, keep the version of the branch "ours"
To resolve a particular conflict, "git checkout --ours path/to/file.desktop"
2021-07-04 01:16:40 +00:00
l10n daemon script 998ba22a21 GIT_SILENT made messages (after extraction) 2021-07-04 00:18:54 +00:00
l10n daemon script a79fb43569 SVN_SILENT made messages (.desktop file) - always resolve ours
In case of conflict in i18n, keep the version of the branch "ours"
To resolve a particular conflict, "git checkout --ours path/to/file.desktop"
2021-07-02 01:14:16 +00:00
l10n daemon script 0365309415 GIT_SILENT made messages (after extraction) 2021-07-02 00:19:14 +00:00
Jonah Brüchert c0df2785df Lazy-initialize YTMusic object
So it can't throw exceptions in the constructor,
and we can actually properly handle them.
2021-06-30 01:49:24 +02:00
Jonah Brüchert e0ae3f0c93 Fix i18n usage 2021-06-28 02:00:18 +02:00
Jonah Brüchert b95850013b Regenerate flatpak sources 2021-06-28 00:06:08 +02:00
Jonah Brüchert 4ec46a10bf Add artist radio feature 2021-06-27 16:28:25 +02:00
l10n daemon script 05e9949487 SVN_SILENT made messages (.desktop file) - always resolve ours
In case of conflict in i18n, keep the version of the branch "ours"
To resolve a particular conflict, "git checkout --ours path/to/file.desktop"
2021-06-23 01:17:05 +00:00
l10n daemon script 7b1bce6297 GIT_SILENT made messages (after extraction) 2021-06-23 00:20:23 +00:00
l10n daemon script b6fa3b3aa9 GIT_SILENT made messages (after extraction) 2021-06-21 00:20:46 +00:00
Jonah Brüchert 5b5e41a563 Display title of the video that could not be played 2021-06-21 01:20:29 +02:00
Jonah Brüchert 8fcac61500 Fix loading Thomas Bangalter 2021-06-21 01:15:27 +02:00
Jonah Brüchert 0420a694f7 Set KAboutData for KCrash 2021-06-18 16:16:35 +02:00
Jonah Brüchert 78cf01b0e8 Enable KCrash 2021-06-18 16:15:58 +02:00
Jonah Brüchert b5f8ae8d85 Add copyright headers to find modules 2021-06-17 14:04:32 +02:00
Jonah Brüchert 58c183df56 Add find modules for python dependencies 2021-06-17 01:15:32 +02:00
Jonah Brüchert 2272f88db9 Add text to playlist actions 2021-06-17 00:45:01 +02:00
Jonah Brüchert d7f1a408fd Only leave space for the album cover if there is one 2021-06-17 00:43:02 +02:00
Jonah Brüchert b7c99086e9 Simplify setting the translation domain 2021-06-16 22:32:10 +02:00
Jonah Brüchert 28c5b7d562 License some data files as CC0-1.0 2021-06-16 21:44:57 +02:00
Jonah Brüchert c163b6b995 Set translation domain 2021-06-16 21:42:53 +02:00
Jonah Brüchert 7e62862bd3 Add CI job to check reuse compliance 2021-06-16 21:36:08 +02:00
Jonah Brüchert 89402fb770 Fix reuse compliance 2021-06-16 21:35:56 +02:00
Jonah Brüchert 4717953a06 Use title capitalization in actions 2021-06-16 21:25:44 +02:00
Jonah Brüchert eefab11079 example: Fix typo 2021-06-16 21:22:07 +02:00
Jonah Brüchert 25d5749970 Make YTMusicThread destructor override 2021-06-16 21:21:52 +02:00
Jonah Brüchert 5e4c45038f asyncytmusic.h: Fix typo 2021-06-16 21:20:05 +02:00
Jonah Brüchert 7967d37f14 Make PlaylistUtils a namespace 2021-06-16 21:18:26 +02:00
Jonah Brüchert 1ee5a49c72 Make VideoInfoExtractor constructor explicit 2021-06-16 21:15:57 +02:00
Jonah Brüchert 44aedfd702 Add comment about the setenv 2021-06-16 21:14:22 +02:00
Jonah Brüchert 5e4fcb7d35 metainfo: Add launchable 2021-06-16 21:12:46 +02:00
l10n daemon script d6dcce1a88 SVN_SILENT made messages (.desktop file) - always resolve ours
In case of conflict in i18n, keep the version of the branch "ours"
To resolve a particular conflict, "git checkout --ours path/to/file.desktop"
2021-06-16 01:25:39 +00:00
l10n daemon script e34530bf7d GIT_SILENT made messages (after extraction) 2021-06-16 00:20:38 +00:00
Jonah Brüchert 56b440f689 Use KFormat to format the timestamps 2021-06-13 23:00:48 +02:00
Jonah Brüchert e2cebadaef Move contents into MultiIterableView
makes it easier and safer and we currently don't need the lists anywhere else
2021-06-13 18:41:13 +02:00
l10n daemon script 49d55d73d1 GIT_SILENT made messages (after extraction) 2021-06-11 00:19:11 +00:00
Jonah Brüchert a9ec57a008 Fix playback from playlist page 2021-06-10 22:33:28 +02:00
Jonah Brüchert f4e11ba490 Depend on at least the cmake version required by FindKF5 2021-06-10 19:16:06 +02:00
Jonah Brüchert 44176b49ac metainfo: Add information about input devices 2021-06-10 18:51:11 +02:00
Jonah Brüchert 79ff9230ba Extend appstream metadata 2021-06-10 18:47:12 +02:00
l10n daemon script d6682dbfe3 SVN_SILENT made messages (.desktop file) - always resolve ours
In case of conflict in i18n, keep the version of the branch "ours"
To resolve a particular conflict, "git checkout --ours path/to/file.desktop"
2021-06-07 01:17:55 +00:00
l10n daemon script ef53ac4b1a GIT_SILENT made messages (after extraction) 2021-06-07 00:20:04 +00:00
Tobias Fella c503d0607a Add missing license texts 2021-06-06 13:09:27 +02:00
Tobias Fella 5f63abd8bb Fix license identifiers 2021-06-06 13:09:17 +02:00
l10n daemon script e2530e94cf SVN_SILENT made messages (.desktop file) - always resolve ours
In case of conflict in i18n, keep the version of the branch "ours"
To resolve a particular conflict, "git checkout --ours path/to/file.desktop"
2021-06-06 01:20:14 +00:00
l10n daemon script 1f3e1ff98e GIT_SILENT made messages (after extraction) 2021-06-06 00:20:04 +00:00
Luigi Toscano f7353bfcd5 svg file: temporarily fix the wrong headers
An SVN file is a valid XML file, but it is mostly handled by a graphic
program.
It seems the metadata should be added though the editor using some
standard SVG fields, but it is not fully clear (at least to me)
which ones are the correct ones, see also:

https://github.com/fsfe/reuse-tool/issues/180

In any case, the SPDX header before the xml line makes this
an invalid SVG file (even though some relaxed parser may still
accept it), so remove the SPDX comment for now.

CCMAIL: [email protected]
2021-06-06 00:40:09 +02:00
Luigi Toscano bdeca89a95 Fix appdata: the xml header must be the 1st
Otherwise it is not a valid XML file. Please see also:
https://community.kde.org/Guidelines_and_HOWTOs/Licensing#XML_Files_.28appdata.xml.2C_.2A.qrc.29

CCMAIL: [email protected]
2021-06-06 00:34:42 +02:00
Jonah Brüchert a707a0523f Enable reuseItems in all list views 2021-06-05 13:23:27 +02:00
l10n daemon script 70243a6e59 SVN_SILENT made messages (.desktop file) - always resolve ours
In case of conflict in i18n, keep the version of the branch "ours"
To resolve a particular conflict, "git checkout --ours path/to/file.desktop"
2021-06-05 01:17:27 +00:00
Jonah Brüchert 2f4cb7868a Update tested ytmusicapi version 2021-06-05 00:33:18 +02:00
Jonah Brüchert 1fa0a3f4b2 Add reuse headers to currently unlicensed files 2021-06-04 17:36:13 +02:00
l10n daemon script f24a74d195 SVN_SILENT made messages (.desktop file) - always resolve ours
In case of conflict in i18n, keep the version of the branch "ours"
To resolve a particular conflict, "git checkout --ours path/to/file.desktop"
2021-06-04 01:25:30 +00:00
l10n daemon script 38c448335f GIT_SILENT made messages (after extraction) 2021-06-04 00:22:38 +00:00
l10n daemon script 9afeae2ccc SVN_SILENT made messages (.desktop file) - always resolve ours
In case of conflict in i18n, keep the version of the branch "ours"
To resolve a particular conflict, "git checkout --ours path/to/file.desktop"
2021-05-30 01:17:11 +00:00
l10n daemon script 583973a731 GIT_SILENT made messages (after extraction) 2021-05-30 00:19:35 +00:00
Yuri Chornoivan dc5c25cf42 Add message extraction script 2021-05-27 18:46:59 +03:00
l10n daemon script a4fcc55638 SVN_SILENT made messages (.desktop file) - always resolve ours
In case of conflict in i18n, keep the version of the branch "ours"
To resolve a particular conflict, "git checkout --ours path/to/file.desktop"
2021-05-26 01:27:39 +00:00
l10n daemon script 1aa7559fe7 GIT_SILENT made messages (after extraction) 2021-05-26 00:22:08 +00:00
Mohammad Shavez 6f4ec382e8 Hide timestamps when no media is playing 2021-05-25 07:19:03 +00:00
Mohammad Shavez a67631ec92 Added timestamps around progress bar 2021-05-25 07:19:03 +00:00
Jonah Brüchert d861b7cc59 Update tested ytmusicapi version 2021-05-25 01:13:59 +02:00
l10n daemon script 87fd82b43b SVN_SILENT made messages (.desktop file) - always resolve ours
In case of conflict in i18n, keep the version of the branch "ours"
To resolve a particular conflict, "git checkout --ours path/to/file.desktop"
2021-05-24 01:15:14 +00:00
l10n daemon script 0902b4aa19 GIT_SILENT made messages (after extraction) 2021-05-24 00:18:37 +00:00
l10n daemon script 7ccb638662 SVN_SILENT made messages (.desktop file) - always resolve ours
In case of conflict in i18n, keep the version of the branch "ours"
To resolve a particular conflict, "git checkout --ours path/to/file.desktop"
2021-05-23 01:15:24 +00:00
l10n daemon script c35c563878 GIT_SILENT made messages (after extraction) 2021-05-23 00:18:44 +00:00
l10n daemon script 84cdaade07 SVN_SILENT made messages (.desktop file) - always resolve ours
In case of conflict in i18n, keep the version of the branch "ours"
To resolve a particular conflict, "git checkout --ours path/to/file.desktop"
2021-05-22 01:17:11 +00:00
l10n daemon script f3dec29198 GIT_SILENT made messages (after extraction) 2021-05-22 00:18:15 +00:00
Jonah Brüchert 3f5b4b03f7 Improve MultiIterableView 2021-05-07 12:54:12 +02:00
Jonah Brüchert 5fe78c7879 Regenerate flatapak sources 2021-05-07 12:53:21 +02:00
Jonah Brüchert 6f52571cbd make video_info::Format::quality optional 2021-05-07 12:45:38 +02:00
Jonah Brüchert 5c6eba4309 Account for albums with an unknown year 2021-05-01 23:34:52 +02:00
Jonah Brüchert 6fa90884ba Add multiiterableview and use it in artistmodel 2021-05-01 23:34:49 +02:00
Jonah Brüchert 4f3c953541 README: Add note about qtimageformats 2021-05-01 15:51:27 +02:00
Jonah Brüchert cf7623864b Add categories to the desktop file 2021-04-30 21:12:53 +02:00
Jonah Brüchert 6081fdc819 flatpak: Update youtube-dl 2021-04-26 15:09:12 +02:00
Jonah Brüchert c085d808f9 Don't allow skipping after the last song 2021-04-24 23:04:12 +02:00
Jonah Brüchert 9245f2e123 Update ytmusicapi to 0.16.0 2021-04-24 14:59:32 +02:00
Jonah Brüchert aa9c378a26 Replace deprecated std::random_shuffle 2021-04-24 14:52:34 +02:00
Jonah Brüchert 637a9b2406 Delay search 2021-04-24 14:51:31 +02:00
Jonah Brüchert 5e5ee60b9f Elide text in playlist items 2021-04-17 00:23:48 +02:00
Jonah Brüchert 50ebdbabe7 flatpak: Update youtube-dl 2021-04-16 23:44:00 +02:00
Jonah Brüchert decdc38b6c Extract common logic into map_optional function 2021-04-13 18:09:33 +02:00
Jonah Brüchert 7ef68d7fe3 Print error message using std::cerr 2021-04-13 18:08:26 +02:00
Jonah Brüchert 79ee47e8df flatpak: Update ytmusicapi to 0.15.1 2021-04-11 23:24:22 +02:00
Jonah Brüchert 2304923809 Update tested ytmusicapi version to 0.15.1 2021-04-11 23:22:58 +02:00
Jonah Brüchert 1ee8b4abae Enable selectByMouse for text field 2021-04-11 23:16:20 +02:00
Jonah Brüchert 43d4bb5999 ytmusic: Fix watch::Playlist::Track extraction with ytmusicapi 0.15.0 2021-04-11 23:15:22 +02:00
Jonah Brüchert ce454730c1 Downgrade ytmusicapi 2021-04-11 23:03:49 +02:00
Jonah Brüchert be70f56b4b flatpak: Update pip packages 2021-04-11 22:55:26 +02:00
Jonah Brüchert 2b6c89d9e6 Fix enabled state of play button 2021-04-11 00:32:16 +02:00
Mathis Brüchert 8fa564e7f0 Implement shuffling 2021-03-27 18:11:40 +01:00
Jonah Brüchert eb105e2f91 Relicense as LicenseRef-KDE-Accepted-GPL
@mbruchert was asked and approved.
2021-03-24 18:19:59 +01:00
Jonah Brüchert 4f35497e3f Fix layouting issues with qqc2-breze-style 2021-03-24 18:01:05 +01:00
Jonah Brüchert 56c2b4dd79 Clean up unused includes 2021-03-20 20:09:47 +01:00
Jonah Brüchert 4948eb55ca Fix playing playlists 2021-03-20 18:39:34 +01:00
Jonah Brüchert 1a0762b7f1 Add support for playlists
Fixes #3
2021-03-20 17:33:06 +01:00
Jonah Brüchert 6bfac31b31 Rename PlaylistModel to UserPlaylistModel
As preparation to introduce a model for predefined playlists
2021-03-20 16:31:22 +01:00
Jonah Brüchert 4aeb7854cb Allow playing the video audio from the artist page too 2021-03-20 16:23:25 +01:00
Jonah Brüchert 1d8fe8ee07 Allow playing the audio stream of videos while real video playback is not supported 2021-03-20 16:21:35 +01:00
Jonah Brüchert 1c7f2b2870 Reset current video ID when playlist is empty 2021-03-20 16:21:35 +01:00
Kuba Prussak 937fa6dc81 Included pythons requirements
Including python pip's requirements .txt allows for quick and simple instalation of dependencies.
2021-03-19 19:06:20 +00:00
Jonah Brüchert f4499cae34 Improve flatpak recipe 2021-03-17 15:11:43 +01:00
Jonah Brüchert 93b34c5f01 Set minimum required Qt version to 5.15 2021-03-17 15:02:36 +01:00
Jonah Brüchert 48bba75168 Fix extracting "arte concert"
Closes #1

Also enables XKCD-powered python error messages. They are funny and a lot better than unexplained crashes.
2021-03-15 19:28:54 +01:00
Jonah Brüchert c18c26fa0d Allow removing items from the playlist 2021-03-15 16:30:57 +01:00
Jonah Brüchert cdcb3eefe4 Clean up thread usage 2021-03-15 15:46:13 +01:00
Jonah Brüchert 81f89f6b1b handle python errors 2021-03-15 15:43:03 +01:00
Jonah Brüchert 1d9452e369 Add python3 troubleshooting to README 2021-03-14 20:23:12 +01:00
Jonah Brüchert 18f9c0ce29 Elide text in list items 2021-03-13 23:51:26 +01:00
Jonah Brüchert 7551cea9bb Update licensing and appstream metadate 2021-03-13 22:03:34 +01:00
Jonah Brüchert 85cbda5b2f Add playlist append 2021-03-13 18:37:20 +01:00
Jonah Brüchert 932aa950bc Allow to use the play next functionality with all songs 2021-03-13 18:25:12 +01:00
Jonah Brüchert a2dce3ea4f Only allow skipping if there is a next track 2021-03-13 18:03:10 +01:00
Jonah Brüchert d13a77c60b Allow manually inserting into the playlist 2021-03-13 17:54:52 +01:00
Jonah Brüchert fd5bebd93f Don't show controls if the footer is maximized
The back / forward button overlay doesn't make sense there
2021-03-13 01:39:29 +01:00
Jonah Brüchert e131cfc9cc Workaround encoding issues on Manjaro 2021-03-12 15:04:40 +01:00
Jonah Brüchert 8ee189a653 Clip playlist ListView 2021-03-12 00:24:05 +01:00
Jonah Brüchert 2698f27609 Fix various warnings 2021-03-11 23:39:45 +01:00
Jonah Brüchert 68d9f26178 Add flatpak recipe 2021-03-11 21:35:17 +01:00
Jonah Brüchert c5fb7f62fd Disable expand button if no playlist exists 2021-03-11 20:56:43 +01:00
Jonah Brüchert c748e2860d Elide title 2021-03-11 20:40:12 +01:00
Jonah Brüchert fa37b86904 Reduce footer size 2021-03-11 20:39:22 +01:00
Jonah Brüchert f7e1451fb6 Workaround QML engine crash
random-changes-driven-development
2021-03-11 20:04:13 +01:00
Jonah Brüchert 87a195eaaa Fix icon in desktop file 2021-03-11 18:49:57 +01:00
Mathis Brüchert 61a8396b09 show cover in player 2021-03-11 17:47:47 +01:00
Jonah Brüchert 71d87d419f Implement thumbnail fetching in extract_video_info 2021-03-11 17:47:27 +01:00
63 changed files with 2502 additions and 602 deletions

No files matched your search

+5
View File
@@ -1 +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
CMakeLists.txt.user
flatpak/flatpak-builder-tools/
+6
View File
@@ -0,0 +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
include:
- 'https://invent.kde.org/sysadmin/ci-tooling/raw/master/invent/ci-reuse.yml'
+4
View File
@@ -0,0 +1,4 @@
Format: https://www.debian.org/doc/packaging-manuals/copyright-format/1.0/
Upstream-Name: AudioTube
Upstream-Contact: Jonah Brüchert <[email protected]>
Source: https://invent.kde.org/plasma-mobile/audiotube
+11 -5
View File
@@ -1,18 +1,22 @@
cmake_minimum_required(VERSION 3.14)
# SPDX-FileCopyrightText: 2021 Jonah Brüchert <[email protected]>
#
# SPDX-License-Identifier: BSD-2-Clause
cmake_minimum_required(VERSION 3.16.0)
project(audiotube)
include(FeatureSummary)
set(QT5_MIN_VERSION 5.12)
set(KF5_MIN_VERSION 5.65)
set(QT5_MIN_VERSION 5.15)
set(KF5_MIN_VERSION 5.81)
set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
find_package(ECM ${KF5_MIN_VERSION} REQUIRED NO_MODULE)
set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} ${ECM_MODULE_PATH})
set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} ${ECM_MODULE_PATH} ${CMAKE_SOURCE_DIR}/cmake)
include(KDEInstallDirs)
include(KDECMakeSettings)
@@ -24,8 +28,10 @@ include(ECMPoQmTools)
kde_enable_exceptions()
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(KF5 ${KF5_MIN_VERSION} REQUIRED COMPONENTS Kirigami2 I18n CoreAddons Crash)
find_package(pybind11 REQUIRED)
find_package(YoutubeDL REQUIRED RUNTIME)
find_package(YTMusicAPI REQUIRED RUNTIME)
add_subdirectory(src)
+22
View File
@@ -0,0 +1,22 @@
Copyright (c) <year> <owner>. All rights reserved.
Redistribution and use in source and binary forms, with or without modification,
are permitted provided that the following conditions are met:
1. Redistributions of source code must retain the above copyright notice,
this list of conditions and the following disclaimer.
2. Redistributions in binary form must reproduce the above copyright notice,
this list of conditions and the following disclaimer in the documentation
and/or other materials provided with the distribution.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE
USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+119
View File
@@ -0,0 +1,119 @@
Creative Commons Legal Code
CC0 1.0 Universal CREATIVE COMMONS CORPORATION IS NOT A LAW FIRM AND DOES
NOT PROVIDE LEGAL SERVICES. DISTRIBUTION OF THIS DOCUMENT DOES NOT CREATE
AN ATTORNEY-CLIENT RELATIONSHIP. CREATIVE COMMONS PROVIDES THIS INFORMATION
ON AN "AS-IS" BASIS. CREATIVE COMMONS MAKES NO WARRANTIES REGARDING THE USE
OF THIS DOCUMENT OR THE INFORMATION OR WORKS PROVIDED HEREUNDER, AND DISCLAIMS
LIABILITY FOR DAMAGES RESULTING FROM THE USE OF THIS DOCUMENT OR THE INFORMATION
OR WORKS PROVIDED HEREUNDER.
Statement of Purpose
The laws of most jurisdictions throughout the world automatically confer exclusive
Copyright and Related Rights (defined below) upon the creator and subsequent
owner(s) (each and all, an "owner") of an original work of authorship and/or
a database (each, a "Work").
Certain owners wish to permanently relinquish those rights to a Work for the
purpose of contributing to a commons of creative, cultural and scientific
works ("Commons") that the public can reliably and without fear of later claims
of infringement build upon, modify, incorporate in other works, reuse and
redistribute as freely as possible in any form whatsoever and for any purposes,
including without limitation commercial purposes. These owners may contribute
to the Commons to promote the ideal of a free culture and the further production
of creative, cultural and scientific works, or to gain reputation or greater
distribution for their Work in part through the use and efforts of others.
For these and/or other purposes and motivations, and without any expectation
of additional consideration or compensation, the person associating CC0 with
a Work (the "Affirmer"), to the extent that he or she is an owner of Copyright
and Related Rights in the Work, voluntarily elects to apply CC0 to the Work
and publicly distribute the Work under its terms, with knowledge of his or
her Copyright and Related Rights in the Work and the meaning and intended
legal effect of CC0 on those rights.
1. Copyright and Related Rights. A Work made available under CC0 may be protected
by copyright and related or neighboring rights ("Copyright and Related Rights").
Copyright and Related Rights include, but are not limited to, the following:
i. the right to reproduce, adapt, distribute, perform, display, communicate,
and translate a Work;
ii. moral rights retained by the original author(s) and/or performer(s);
iii. publicity and privacy rights pertaining to a person's image or likeness
depicted in a Work;
iv. rights protecting against unfair competition in regards to a Work, subject
to the limitations in paragraph 4(a), below;
v. rights protecting the extraction, dissemination, use and reuse of data
in a Work;
vi. database rights (such as those arising under Directive 96/9/EC of the
European Parliament and of the Council of 11 March 1996 on the legal protection
of databases, and under any national implementation thereof, including any
amended or successor version of such directive); and
vii. other similar, equivalent or corresponding rights throughout the world
based on applicable law or treaty, and any national implementations thereof.
2. Waiver. To the greatest extent permitted by, but not in contravention of,
applicable law, Affirmer hereby overtly, fully, permanently, irrevocably and
unconditionally waives, abandons, and surrenders all of Affirmer's Copyright
and Related Rights and associated claims and causes of action, whether now
known or unknown (including existing as well as future claims and causes of
action), in the Work (i) in all territories worldwide, (ii) for the maximum
duration provided by applicable law or treaty (including future time extensions),
(iii) in any current or future medium and for any number of copies, and (iv)
for any purpose whatsoever, including without limitation commercial, advertising
or promotional purposes (the "Waiver"). Affirmer makes the Waiver for the
benefit of each member of the public at large and to the detriment of Affirmer's
heirs and successors, fully intending that such Waiver shall not be subject
to revocation, rescission, cancellation, termination, or any other legal or
equitable action to disrupt the quiet enjoyment of the Work by the public
as contemplated by Affirmer's express Statement of Purpose.
3. Public License Fallback. Should any part of the Waiver for any reason be
judged legally invalid or ineffective under applicable law, then the Waiver
shall be preserved to the maximum extent permitted taking into account Affirmer's
express Statement of Purpose. In addition, to the extent the Waiver is so
judged Affirmer hereby grants to each affected person a royalty-free, non
transferable, non sublicensable, non exclusive, irrevocable and unconditional
license to exercise Affirmer's Copyright and Related Rights in the Work (i)
in all territories worldwide, (ii) for the maximum duration provided by applicable
law or treaty (including future time extensions), (iii) in any current or
future medium and for any number of copies, and (iv) for any purpose whatsoever,
including without limitation commercial, advertising or promotional purposes
(the "License"). The License shall be deemed effective as of the date CC0
was applied by Affirmer to the Work. Should any part of the License for any
reason be judged legally invalid or ineffective under applicable law, such
partial invalidity or ineffectiveness shall not invalidate the remainder of
the License, and in such case Affirmer hereby affirms that he or she will
not (i) exercise any of his or her remaining Copyright and Related Rights
in the Work or (ii) assert any associated claims and causes of action with
respect to the Work, in either case contrary to Affirmer's express Statement
of Purpose.
4. Limitations and Disclaimers.
a. No trademark or patent rights held by Affirmer are waived, abandoned, surrendered,
licensed or otherwise affected by this document.
b. Affirmer offers the Work as-is and makes no representations or warranties
of any kind concerning the Work, express, implied, statutory or otherwise,
including without limitation warranties of title, merchantability, fitness
for a particular purpose, non infringement, or the absence of latent or other
defects, accuracy, or the present or absence of errors, whether or not discoverable,
all to the greatest extent permissible under applicable law.
c. Affirmer disclaims responsibility for clearing rights of other persons
that may apply to the Work or any use thereof, including without limitation
any person's Copyright and Related Rights in the Work. Further, Affirmer disclaims
responsibility for obtaining any necessary consents, permissions or other
rights required for any use of the Work.
d. Affirmer understands and acknowledges that Creative Commons is not a party
to this document and has no duty or obligation with respect to this CC0 or
use of the Work.
+117
View File
@@ -0,0 +1,117 @@
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
@@ -0,0 +1,232 @@
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
@@ -0,0 +1,12 @@
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,3 +7,9 @@ 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.
+3
View File
@@ -0,0 +1,3 @@
SPDX-FileCopyrightText: 2021 Jonah Brüchert <[email protected]>
SPDX-License-Identifier: CC0-1.0
+4
View File
@@ -0,0 +1,4 @@
[Project]
CreatedFrom=CMakeLists.txt
Manager=KDevCMakeManager
Name=audiotube
+3
View File
@@ -0,0 +1,3 @@
SPDX-FileCopyrightText: 2021 Jonah Brüchert <[email protected]>
SPDX-License-Identifier: CC0-1.0
+11
View File
@@ -0,0 +1,11 @@
# SPDX-FileCopyrightText: 2021 Jonah Brüchert <[email protected]>
#
# SPDX-License-Identifier: BSD-2-Clause
find_package(Python3 REQUIRED COMPONENTS Interpreter)
execute_process(COMMAND ${Python3_EXECUTABLE} -c "import ytmusicapi" RESULT_VARIABLE YTMUSICAPI_CHECK_RESULT)
if (${YTMUSICAPI_CHECK_RESULT} EQUAL 0)
set(YTMusicAPI_FOUND TRUE)
endif()
+11
View File
@@ -0,0 +1,11 @@
# SPDX-FileCopyrightText: 2021 Jonah Brüchert <[email protected]>
#
# SPDX-License-Identifier: BSD-2-Clause
find_package(Python3 REQUIRED COMPONENTS Interpreter)
execute_process(COMMAND ${Python3_EXECUTABLE} -c "import youtube_dl" RESULT_VARIABLE YTDL_CHECK_RESULT)
if (${YTDL_CHECK_RESULT} EQUAL 0)
set(YoutubeDL_FOUND TRUE)
endif()
+14
View File
@@ -0,0 +1,14 @@
{
"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/c6/75/05979677d9abc76851d13d8db3951e39017ac223545adab6e8576fa0cbe7/youtube_dl-2021.6.6.tar.gz",
"sha256": "cb2d3ee002158ede783e97a82c95f3817594df54367ea6a77ce5ceea4772f0ab"
}
]
}
+3
View File
@@ -0,0 +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
+39
View File
@@ -0,0 +1,39 @@
{
"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/4f/5a/597ef5911cb8919efe4d86206aa8b2658616d676a7088f0825ca08bd7cb8/urllib3-1.26.6.tar.gz",
"sha256": "f57b4c16c62fa2760b7e3d97c35b255512fb6b59a259730f36ba32ce9f8e342f"
},
{
"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/6d/78/f8db8d57f520a54f0b8a438319c342c61c22759d8f9a1cd2e2180b5e5ea9/certifi-2021.5.30.tar.gz",
"sha256": "2bbf76fd432960138b3ef6dda3dde0544f27cbf8546c458e60baf371917ba9ee"
},
{
"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/1b/8e/2bc4c8160083bbfaac215637f1e9f4a43263833c2e81212cba3073aeaa25/ytmusicapi-0.17.3.tar.gz",
"sha256": "9a249cc53efd6408034f401a9a4375272a9b339e8eb64f3a2e713a1ccd06d55b"
}
]
}
+3
View File
@@ -0,0 +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
+20
View File
@@ -0,0 +1,20 @@
#!/usr/bin/env bash
# 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
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
+3
View File
@@ -0,0 +1,3 @@
SPDX-FileCopyrightText: 2021 Mathis Brüchert <[email protected]>
SPDX-License-Identifier: GPL-2.0-only OR GPL-3.0-only OR LicenseRef-KDE-Accepted-GPL
+109 -12
View File
@@ -1,18 +1,115 @@
<?xml version="1.0" encoding="utf-8"?>
<!--
SPDX-FileCopyrightText: 2021 Jonah Brüchert <[email protected]>
SPDX-License-Identifier: CC0-1.0
-->
<component type="desktop-application">
<id>org.kde.audiotube</id>
<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>
<name>AudioTube</name>
<name xml:lang="ca">AudioTube</name>
<name xml:lang="ca-valencia">AudioTube</name>
<name xml:lang="cs">AudioTube</name>
<name xml:lang="de">AudioTube</name>
<name xml:lang="en-GB">AudioTube</name>
<name xml:lang="es">AudioTube</name>
<name xml:lang="eu">AudioTube</name>
<name xml:lang="fi">AudioTube</name>
<name xml:lang="fr">AudioTube</name>
<name xml:lang="hi">ओडियो-ट्यूब</name>
<name xml:lang="it">AudioTube</name>
<name xml:lang="ko">AudioTube</name>
<name xml:lang="nl">AudioTube</name>
<name xml:lang="pa">ਆਡੀਓ-ਟਿਊਬ</name>
<name xml:lang="pl">AudioTube</name>
<name xml:lang="pt">AudioTube</name>
<name xml:lang="pt-BR">AudioTube</name>
<name xml:lang="sk">AudioTube</name>
<name xml:lang="sl">AudioTube</name>
<name xml:lang="sv">AudioTube</name>
<name xml:lang="uk">AudioTube</name>
<name xml:lang="x-test">xxAudioTubexx</name>
<summary>Convergent YouTube Music client</summary>
<summary xml:lang="ca">Client convergent per a la música de YouTube</summary>
<summary xml:lang="ca-valencia">Client convergent per a la música de YouTube</summary>
<summary xml:lang="de">Konvergentes YouTube-Musikprogramm</summary>
<summary xml:lang="en-GB">Convergent YouTube Music client</summary>
<summary xml:lang="es">Cliente de música de YouTube convergente</summary>
<summary xml:lang="eu">YouTube Music bezero konbergentea</summary>
<summary xml:lang="fi">Mukautuva YouTube Music -asiakas</summary>
<summary xml:lang="fr">Client convergent pour musique sur YouTube</summary>
<summary xml:lang="hi">अभिसृत यूट्यूब संगीत क्लाएंट</summary>
<summary xml:lang="it">Client YouTube Music convergente</summary>
<summary xml:lang="ko">올인원 YouTube Music 클라이언트</summary>
<summary xml:lang="nl">Convergente muziekclient van YouTube</summary>
<summary xml:lang="pl">Całościowy program do muzyki z YouTube</summary>
<summary xml:lang="pt">Cliente de música do YouTube convergente</summary>
<summary xml:lang="pt-BR">Um cliente convergente para o YouTube Music</summary>
<summary xml:lang="sl">Konvergentni odjemalec glasbe YouTube</summary>
<summary xml:lang="sv">Konvergent YouTube-musikprogram</summary>
<summary xml:lang="uk">Зручний музичний клієнт YouTube</summary>
<summary xml:lang="x-test">xxConvergent YouTube Music clientxx</summary>
<metadata_license>CC0-1.0</metadata_license>
<project_license>GPL-2.0+</project_license>
<developer_name>KDE Community</developer_name>
<developer_name xml:lang="ca">La comunitat KDE</developer_name>
<developer_name xml:lang="ca-valencia">La comunitat KDE</developer_name>
<developer_name xml:lang="cs">Komunita KDE</developer_name>
<developer_name xml:lang="de">KDE-Gemeinschaft</developer_name>
<developer_name xml:lang="en-GB">KDE Community</developer_name>
<developer_name xml:lang="es">Comunidad KDE</developer_name>
<developer_name xml:lang="eu">KDE komunitatea</developer_name>
<developer_name xml:lang="fi">KDE-yhteisö</developer_name>
<developer_name xml:lang="fr">Communauté de KDE</developer_name>
<developer_name xml:lang="hi">केडीई समुदाय</developer_name>
<developer_name xml:lang="it">Comunità KDE</developer_name>
<developer_name xml:lang="ko">KDE 커뮤니티</developer_name>
<developer_name xml:lang="nl">KDE-gemeenschap</developer_name>
<developer_name xml:lang="pa">ਕੇਡੀਈ ਕਮਿਊਨਟੀ</developer_name>
<developer_name xml:lang="pl">Społeczność KDE</developer_name>
<developer_name xml:lang="pt">Comunidade do KDE</developer_name>
<developer_name xml:lang="pt-BR">A Comunidade KDE</developer_name>
<developer_name xml:lang="sk">KDE komunita</developer_name>
<developer_name xml:lang="sl">Skupnost KDE</developer_name>
<developer_name xml:lang="sv">KDE-gemenskapen</developer_name>
<developer_name xml:lang="uk">Спільнота KDE</developer_name>
<developer_name xml:lang="x-test">xxKDE Communityxx</developer_name>
<content_rating type="oars-1.0"/>
<url type="homepage">https://apps.kde.org/en/audiotube</url>
<launchable type="desktop-id">org.kde.audiotube.desktop</launchable>
<screenshots>
<screenshot>
<image>https://cdn.kde.org/screenshots/audiotube/desktop.png</image>
</screenshot>
<screenshot>
<image>https://cdn.kde.org/screenshots/audiotube/mobile_playlist.png</image>
</screenshot>
</screenshots>
<recommends>
<control>pointing</control>
<control>keyboard</control>
<control>touch</control>
</recommends>
<description>
<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>
<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 xml:lang="ca">L'AudioTube pot cercar música a YouTube, llistar àlbums i artistes, reproduir llistes de reproducció generades automàticament, àlbums i permet crear la vostra pròpia llista de reproducció.</p>
<p xml:lang="ca-valencia">L'AudioTube pot cercar música a YouTube, llistar àlbums i artistes, reproduir llistes de reproducció generades automàticament, àlbums i permet crear la vostra pròpia llista de reproducció.</p>
<p xml:lang="de">AudioTube kann Musik auf YouTube durchsuchen, Alben und Interpreten auflisten, automatisch generierte Wiedergabelisten und Alben abspielen und erlaubt es, eine eigene Wiedergabeliste zusammenzustellen.</p>
<p xml:lang="en-GB">AudioTube can search YouTube Music, list albums and artists, play automatically generated playlists, albums and allows to put your own playlist together.</p>
<p xml:lang="es">AudioTube puede buscar música de YouTube, listar álbumes y artistas, reproducir las listas de reproducción generadas, álbumes y le permite crear su propia lista de reproducción.</p>
<p xml:lang="eu">AudioTube-k YouTube Music-en bilatu dezake, albumak eta artistak zerrendatu, automatikoki sortutako jotze-zerrendak eta albumak jo, eta zure jotze-zerrenda osatzeko aukera eskaintzen dizu.</p>
<p xml:lang="fi">AudioTube osaa etsiä YouTube Music -haun, albumien ja artistien luettelun, luotujen soittolistojen automaattisen toiston ja omien soittolistojen kokoamisen.</p>
<p xml:lang="fr">AudioTube peut effectuer des recherches de musiques sur YouTube Music, établir une liste d'albums et d'artistes, lire des listes de lecture générées automatiquement, des albums et permet de composer sa propre liste de lecture.</p>
<p xml:lang="hi">ऑडियोट्यूब यूट्यूब संगीत खोज सकता है, एल्बम और कलाकारों की सूची बना सकता है, स्वचालित रूप से उत्पन्न की गई गीतसूची, एल्बम बजा सकता है और आपकी अपनी खुद की प्लेलिस्ट को एक साथ रखने में मदद करता है।</p>
<p xml:lang="it">AudioTube può eseguire ricerche su YouTube Music, elencare album e artisti, riprodurre scalette e album generati automaticamente e ti consente di creare la tua scaletta.</p>
<p xml:lang="ko">AudioTube는 YouTube Music을 검색하고, 앨범과 아티스트를 표시하고, 자동 생성된 재생 목록, 앨범을 재생하고, 사용자 정의 재생 목록을 만들 수 있습니다.</p>
<p xml:lang="nl">AudioTube kan in YouTube Music zoeken, een lijst maken van albums en artiesten, automatically gegenereerde afspeellijsten, albums afspelen en biedt u het samenstellen van uw eigen afspeellijst.</p>
<p xml:lang="pl">AudioTube może wyszukać muzyki na YouTube, wypisać albumy i wykonawców, odtwarzać samoczynnie utworzone listy odtwarzania, albumy oraz umożliwia tworzenie własnych list odtwarzania.</p>
<p xml:lang="pt">O AudioTube consegue pesquisar no YouTube Music, enumerar os álbuns e artistas, reproduzir listas geradas automaticamente, álbuns e permite-lhe reproduzir as suas próprias listas de reprodução.</p>
<p xml:lang="pt-BR">O AudioTube pode pesquisar no YouTube Music, listar álbuns e artistas, rodar listas de reprodução geradas automaticamente, álbuns inteiros, e criar a sua própria lista de reprodução.</p>
<p xml:lang="sl">AudioTube lahko išče po YouTube Music, izdela sezname albumov in avtorjev, samodejno predvaja generirane sezname, albume in sestavlja vaše sezname predvajanja.</p>
<p xml:lang="sv">AudioTube kan söka på YouTube Music, lista album och artister, spela upp automatiskt genererade spellistor, albums och låter dig sammanställa egna spellistor.</p>
<p xml:lang="uk">AudioTube може виконувати пошук на YouTube Music, показувати списки альбомів та виконавців, відтворювати створені автоматично списки відтворення, альбоми та надає вам змогу створювати власні списки відворення.</p>
<p xml:lang="x-test">xxAudioTube can search YouTube Music, list albums and artists, play automatically generated playlists, albums and allows to put your own playlist together.xx</p>
</description>
</component>
+47 -3
View File
@@ -1,9 +1,53 @@
[Desktop Entry]
Name=AudioTube
Comment=youtube_music Kirigami Application
Name[ca]=AudioTube
Name[ca@valencia]=AudioTube
Name[cs]=AudioTube
Name[de]=AudioTube
Name[en_GB]=AudioTube
Name[es]=AudioTube
Name[eu]=AudioTube
Name[fi]=AudioTube
Name[fr]=AudioTube
Name[hi]=ओडियो-ट्यूब
Name[it]=AudioTube
Name[ko]=AudioTube
Name[nl]=AudioTube
Name[pa]=ਆਡੀਓ-ਟਿਊਬ
Name[pl]=AudioTube
Name[pt]=AudioTube
Name[pt_BR]=AudioTube
Name[sk]=AudioTube
Name[sl]=AudioTube
Name[sv]=AudioTube
Name[uk]=AudioTube
Name[x-test]=xxAudioTubexx
Comment=YouTube Music client
Comment[ca]=Client de música de YouTube
Comment[ca@valencia]=Client de música de YouTube
Comment[cs]=Hudební klient YouTube
Comment[de]=YouTube-Musikprogramm
Comment[en_GB]=YouTube Music client
Comment[es]=Cliente de música de YouTube
Comment[eu]=YouTube Music bezeroa
Comment[fi]=YouTube Music -asiakas
Comment[fr]=Client de musique sur Youtube
Comment[hi]=यूट्यूब संगीत क्लाएंट
Comment[it]=Client YouTube Music
Comment[ko]=YouTube Music 클라이언트
Comment[nl]=Muziekclient van YouTube
Comment[pa]=ਯੂਟਿਊਬ ਸੰਗੀਤ ਕਲਾਈਂਟ
Comment[pl]=Program do muzyki z YouTube
Comment[pt]=Cliente do YouTube Music
Comment[pt_BR]=Cliente YouTube Music
Comment[sk]=Hudobný klient YouTube
Comment[sl]=Glasbeni odjemalec Youtube
Comment[sv]=YouTube-musikprogram
Comment[uk]=Музичний клієнт YouTube
Comment[x-test]=xxYouTube Music clientxx
Version=1.0
Exec=audiotube
Icon=applications-development
Icon=org.kde.audiotube
Type=Application
Terminal=false
Categories=Qt;KDE;
Categories=Qt;KDE;AudioVideo;Player;
+3
View File
@@ -0,0 +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
+42
View File
@@ -0,0 +1,42 @@
{
"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"] } ]
}
]
}
+3
View File
@@ -0,0 +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
+3
View File
@@ -0,0 +1,3 @@
SPDX-FileCopyrightText: 2021 Mathis Brüchert <[email protected]>
SPDX-License-Identifier: GPL-2.0-only OR GPL-3.0-only OR LicenseRef-KDE-Accepted-GPL
+7
View File
@@ -0,0 +1,7 @@
# SPDX-FileCopyrightText: 2021 Jonah Brüchert <[email protected]>
# SPDX-FileCopyrightText: 2021 Kuba Prussak <[email protected]>
#
# SPDX-License-Identifier: GPL-2.0-only OR GPL-3.0-only OR LicenseRef-KDE-Accepted-GPL
ytmusicapi==0.17.3
youtube_dl
+13 -2
View File
@@ -1,9 +1,14 @@
# SPDX-FileCopyrightText: 2021 Jonah Brüchert <[email protected]>
#
# SPDX-License-Identifier: BSD-2-Clause
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)
@@ -14,7 +19,12 @@ add_executable(audiotube
albummodel.cpp
videoinfoextractor.cpp
artistmodel.cpp
userplaylistmodel.cpp
playlistmodel.cpp
playlistutils.cpp
errorhandler.cpp
playerutils.cpp
multiiterableview.h
resources.qrc
)
@@ -26,9 +36,10 @@ target_link_libraries(audiotube
Qt5::QuickControls2
Qt5::Svg
KF5::I18n
KF5::CoreAddons
KF5::Crash
ytm
)
target_compile_definitions(audiotube PRIVATE -DQT_NO_KEYWORDS)
target_compile_definitions(audiotube PRIVATE -DQT_NO_KEYWORDS -DQT_NO_URL_CAST_FROM_STRING)
install(TARGETS audiotube ${KDE_INSTALL_TARGETS_DEFAULT_ARGS})
+4
View File
@@ -0,0 +1,4 @@
#! /usr/bin/env bash
# SPDX-FileCopyrightText: 2020 Tobias Fella <[email protected]>
# SPDX-License-Identifier: CC0-1.0
$XGETTEXT `find -name \*.cpp -o -name \*.qml -o -name \*.js` -o $podir/audiotube.pot
+18 -7
View File
@@ -1,6 +1,6 @@
// SPDX-FileCopyrightText: 2021 Jonah Brüchert <[email protected]>
//
// SPDX-License-Identifier: GPL-2.0-or-later
// SPDX-License-Identifier: GPL-2.0-only OR GPL-3.0-only OR LicenseRef-KDE-Accepted-GPL
#include "albummodel.h"
@@ -11,9 +11,9 @@ AlbumModel::AlbumModel(QObject *parent)
{
connect(this, &AlbumModel::browseIdChanged, this, [=] {
setLoading(true);
AsyncYTMusic::instance().fetchAlbum(m_browseId);
YTMusicThread::instance()->fetchAlbum(m_browseId);
});
connect(&AsyncYTMusic::instance(), &AsyncYTMusic::fetchAlbumFinished, this, [=](const album::Album &album) {
connect(&YTMusicThread::instance().get(), &AsyncYTMusic::fetchAlbumFinished, this, [=](const album::Album &album) {
setLoading(false);
beginResetModel();
@@ -25,20 +25,30 @@ 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 : m_album.tracks.size();
return parent.isValid() ? 0 : int(m_album.tracks.size());
}
QVariant AlbumModel::data(const QModelIndex &index, int role) const
{
switch (role) {
case Title:
return QString::fromStdString(m_album.tracks.at(index.row()).title);
return QString::fromStdString(m_album.tracks[index.row()].title);
case VideoId:
return QString::fromStdString(m_album.tracks.at(index.row()).video_id.value_or(std::string()));
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
}
});
}
Q_UNREACHABLE();
@@ -50,7 +60,8 @@ QHash<int, QByteArray> AlbumModel::roleNames() const
{
return {
{Title, "title"},
{VideoId, "videoId"}
{VideoId, "videoId"},
{Artists, "artists"}
};
}
+4 -3
View File
@@ -1,6 +1,6 @@
// SPDX-FileCopyrightText: 2021 Jonah Brüchert <[email protected]>
//
// SPDX-License-Identifier: GPL-2.0-or-later
// SPDX-License-Identifier: GPL-2.0-only OR GPL-3.0-only OR LicenseRef-KDE-Accepted-GPL
#pragma once
@@ -22,7 +22,8 @@ class AlbumModel : public QAbstractListModel
public:
enum Role {
Title = Qt::UserRole + 1,
VideoId
VideoId,
Artists
};
explicit AlbumModel(QObject *parent = nullptr);
@@ -50,7 +51,7 @@ public:
private:
QString m_browseId;
bool m_loading;
bool m_loading = false;
album::Album m_album;
};
+85 -89
View File
@@ -1,13 +1,11 @@
// SPDX-FileCopyrightText: 2021 Jonah Brüchert <[email protected]>
//
// SPDX-License-Identifier: GPL-2.0-or-later
// SPDX-License-Identifier: GPL-2.0-only OR GPL-3.0-only OR LicenseRef-KDE-Accepted-GPL
#include "artistmodel.h"
#include <asyncytmusic.h>
#include <QDebug>
ArtistModel::ArtistModel(QObject *parent)
: QAbstractListModel(parent)
{
@@ -18,93 +16,99 @@ ArtistModel::ArtistModel(QObject *parent)
setLoading(true);
AsyncYTMusic::instance().fetchArtist(m_channelId);
YTMusicThread::instance()->fetchArtist(m_channelId);
});
connect(&AsyncYTMusic::instance(), &AsyncYTMusic::fetchArtistFinished, this, [=](const artist::Artist &artist) {
connect(&YTMusicThread::instance().get(), &AsyncYTMusic::fetchArtistFinished, this, [=](const artist::Artist &artist) {
setLoading(false);
beginResetModel();
m_artist = artist;
std::sort(m_artist.thumbnails.begin(), m_artist.thumbnails.end());
auto albums = m_artist.albums ? m_artist.albums->results : std::vector<artist::Artist::Album>();
auto singles = m_artist.singles ? m_artist.singles->results : std::vector<artist::Artist::Single>();
auto songs = m_artist.songs ? m_artist.songs->results : std::vector<artist::Artist::Song>();
auto videos = m_artist.videos ? m_artist.videos->results : std::vector<artist::Artist::Video>();
m_view = std::optional(MultiIterableView(std::move(albums),
std::move(singles),
std::move(songs),
std::move(videos)));
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 : countItems(m_artist.songs)
+ countItems(m_artist.albums)
+ countItems(m_artist.singles)
+ countItems(m_artist.videos);
return parent.isValid() ? 0 : m_view ? int(m_view->size()) : 0;
}
QVariant ArtistModel::data(const QModelIndex &index, int role) const
{
if (!m_view) {
return {};
}
switch (role) {
case Title:
if (index.row() >= countItems(m_artist.songs)
+ countItems(m_artist.albums)
+ countItems(m_artist.singles)) {
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);
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;
}
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);
}
Q_UNREACHABLE();
}, m_view.value()[index.row()]));
case Type:
if (index.row() >= countItems(m_artist.songs)
+ countItems(m_artist.albums)
+ countItems(m_artist.singles)) {
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 (m_artist.videos.has_value()) {
return Video;
Q_UNREACHABLE();
}, m_view.value()[index.row()]);
case Artists:
return QVariant::fromValue(std::vector<meta::Artist> {
{
m_artist.name,
m_artist.channel_id
}
break;
} else if (index.row() >= countItems(m_artist.songs) + countItems(m_artist.albums)) {
if (m_artist.singles.has_value()) {
return Single;
});
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)) {
if (m_artist.albums.has_value()) {
return Album;
}
break;
} else {
return Song;
}
Q_UNREACHABLE();
}, m_view.value()[index.row()]);
}
Q_UNREACHABLE();
@@ -116,7 +120,9 @@ QHash<int, QByteArray> ArtistModel::roleNames() const
{
return {
{Title, "title"},
{Type, "type"}
{Type, "type"},
{Artists, "artists"},
{VideoId, "videoId"}
};
}
@@ -158,30 +164,20 @@ void ArtistModel::setLoading(bool loading)
void ArtistModel::triggerItem(int 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));
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), QString::fromStdString(item.title));
} else {
Q_UNREACHABLE();
}
}, m_view.value()[row]);
}
}
+11 -3
View File
@@ -1,13 +1,16 @@
// SPDX-FileCopyrightText: 2021 Jonah Brüchert <[email protected]>
//
// SPDX-License-Identifier: LGPL-2.0-or-later
// SPDX-License-Identifier: GPL-2.0-only OR GPL-3.0-only OR LicenseRef-KDE-Accepted-GPL
#pragma once
#include <QAbstractListModel>
#include <QUrl>
#include <optional>
#include <ytmusic.h>
#include "multiiterableview.h"
class ArtistModel : public QAbstractListModel
{
@@ -30,7 +33,9 @@ public:
enum Role {
Title,
Type
Type,
Artists,
VideoId
};
explicit ArtistModel(QObject *parent = nullptr);
@@ -57,11 +62,14 @@ public:
Q_SIGNAL void openAlbum(const QString &browseId);
Q_SIGNAL void openSong(const QString &videoId);
Q_SIGNAL void openVideo(const QString &videoId);
Q_SIGNAL void openVideo(const QString &videoId, const QString &title);
private:
QString m_channelId;
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;
};
+92 -50
View File
@@ -1,22 +1,26 @@
// SPDX-FileCopyrightText: 2021 Jonah Brüchert <[email protected]>
//
// SPDX-License-Identifier: GPL-2.0-or-later
// SPDX-License-Identifier: GPL-2.0-only OR GPL-3.0-only OR LicenseRef-KDE-Accepted-GPL
#include "asyncytmusic.h"
#include <QThread>
#include <exception>
#include <QDebug>
#include <pybind11/embed.h>
#include <iostream>
namespace py = pybind11;
static QThread *ytmthread = []() -> QThread * {
auto *thread = new QThread();
thread->setObjectName("YTMusicAPI");
return thread;
}();
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;
}
AsyncYTMusic::AsyncYTMusic(QObject *parent)
: QObject(parent)
@@ -30,6 +34,8 @@ 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);
@@ -39,25 +45,10 @@ 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);
}
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();
connect(this, &AsyncYTMusic::errorOccurred, this, [](const QString &err) {
std::cerr << qPrintable(err);
});
}
//
@@ -70,7 +61,11 @@ void AsyncYTMusic::search(const QString &query)
void AsyncYTMusic::internalSearch(const QString &query)
{
Q_EMIT searchFinished(m_ytdl.search(query.toStdString()));
try {
Q_EMIT searchFinished(m_ytm->search(query.toStdString()));
} catch (const py::error_already_set &err) {
Q_EMIT errorOccurred(QString::fromLocal8Bit(err.what()));
}
}
//
@@ -83,7 +78,11 @@ void AsyncYTMusic::fetchArtist(const QString &channelId)
void AsyncYTMusic::internalFetchArtist(const QString &channelId)
{
Q_EMIT fetchArtistFinished(m_ytdl.get_artist(channelId.toStdString()));
try {
Q_EMIT fetchArtistFinished(m_ytm->get_artist(channelId.toStdString()));
} catch (const py::error_already_set &err) {
Q_EMIT errorOccurred(QString::fromLocal8Bit(err.what()));
}
}
//
@@ -96,7 +95,11 @@ void AsyncYTMusic::fetchAlbum(const QString &browseId)
void AsyncYTMusic::internalFetchAlbum(const QString &browseId)
{
Q_EMIT fetchAlbumFinished(m_ytdl.get_album(browseId.toStdString()));
try {
Q_EMIT fetchAlbumFinished(m_ytm->get_album(browseId.toStdString()));
} catch (const py::error_already_set &err) {
Q_EMIT errorOccurred(QString::fromLocal8Bit(err.what()));
}
}
//
@@ -109,7 +112,11 @@ void AsyncYTMusic::fetchSong(const QString &videoId)
void AsyncYTMusic::internalFetchSong(const QString &videoId)
{
Q_EMIT fetchSongFinished(m_ytdl.get_song(videoId.toStdString()));
try {
Q_EMIT fetchSongFinished(m_ytm->get_song(videoId.toStdString()));
} catch (const py::error_already_set &err) {
Q_EMIT errorOccurred(QString::fromLocal8Bit(err.what()));
}
}
//
@@ -121,7 +128,11 @@ void AsyncYTMusic::fetchPlaylist(const QString &playlistId) {
void AsyncYTMusic::internalFetchPlaylist(const QString &playlistId)
{
Q_EMIT fetchPlaylistFinished(m_ytdl.get_playlist(playlistId.toStdString()));
try {
Q_EMIT fetchPlaylistFinished(m_ytm->get_playlist(playlistId.toStdString()));
} catch (const py::error_already_set &err) {
Q_EMIT errorOccurred(QString::fromLocal8Bit(err.what()));
}
}
//
@@ -134,19 +145,28 @@ void AsyncYTMusic::fetchArtistAlbums(const QString &channelId, const QString &pa
void AsyncYTMusic::internalFetchArtistAlbums(const QString &channelid, const QString &params)
{
Q_EMIT fetchArtistAlbumsFinished(m_ytdl.get_artist_albums(channelid.toStdString(), params.toStdString()));
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()));
}
}
//
// extractVideoInfo
//
void AsyncYTMusic::extractVideoInfo(const QString &videoId) {
qDebug() << "extract video " << videoId;
void AsyncYTMusic::extractVideoInfo(const QString &videoId)
{
Q_EMIT startExtractVideoInfo(videoId);
}
void AsyncYTMusic::internalExtractVideoInfo(const QString &videoId) {
Q_EMIT extractVideoInfoFinished(m_ytdl.extract_video_info(videoId.toStdString()));
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()));
}
}
//
@@ -159,19 +179,41 @@ void AsyncYTMusic::fetchWatchPlaylist(const std::optional<QString> &videoId, con
void AsyncYTMusic::internalFetchWatchPlaylist(const std::optional<QString> &videoId, const std::optional<QString> &playlistId)
{
Q_EMIT fetchWatchPlaylistFinished(m_ytdl.get_watch_playlist(
[&]() -> std::optional<std::string> {
if (!videoId.has_value()) {
return std::nullopt;
}
return videoId->toStdString();
}(),
[&]() -> std::optional<std::string> {
if (!playlistId.has_value()) {
return std::nullopt;
}
return playlistId->toStdString();
}()));
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()));
}
}
YTMusicThread &YTMusicThread::instance()
{
static YTMusicThread thread;
return thread;
}
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();
}
+46 -13
View File
@@ -1,6 +1,6 @@
// SPDX-FileCopyrightText: 2021 Jonah Brüchert <[email protected]>
//
// SPDX-License-Identifier: GPL-2.0-or-later
// SPDX-License-Identifier: GPL-2.0-only OR GPL-3.0-only OR LicenseRef-KDE-Accepted-GPL
#pragma once
@@ -20,23 +20,38 @@ 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>();
}
Q_ASSERT(m_item);
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>);
@@ -65,6 +80,9 @@ 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);
@@ -90,5 +108,20 @@ 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);
YTMusic m_ytdl;
// Python interpreter will be initialized from the thread calling the methods
Lazy<YTMusic> m_ytm;
};
class YTMusicThread : private QThread {
public:
static YTMusicThread &instance();
~YTMusicThread() override;
AsyncYTMusic *operator->();
AsyncYTMusic &get();
private:
YTMusicThread();
AsyncYTMusic m_ytm;
};
+38 -4
View File
@@ -1,4 +1,8 @@
import QtQuick 2.1
// 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.15
import org.kde.kirigami 2.14 as Kirigami
import QtQuick.Controls 2.14 as Controls
import QtQuick.Layouts 1.3
@@ -25,15 +29,45 @@ Kirigami.ScrollablePage {
title: albumModel.title
}
reuseItems: true
model: AlbumModel {
id: albumModel
}
delegate: Kirigami.BasicListItem {
delegate: Kirigami.SwipeListItem {
id: delegateItem
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)
}
+52 -14
View File
@@ -1,4 +1,8 @@
import QtQuick 2.1
// 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.15
import org.kde.kirigami 2.14 as Kirigami
import QtQuick.Controls 2.14 as Controls
import QtQuick.Layouts 1.3
@@ -15,6 +19,9 @@ Kirigami.ScrollablePage {
backgroundImage.source: artistModel.thumbnailUrl
title: artistModel.title
}
reuseItems: true
model: ArtistModel {
id: artistModel
@@ -28,8 +35,8 @@ Kirigami.ScrollablePage {
play(videoId)
}
onOpenVideo: (videoId) => {
onOpenVideo: (videoId, title) => {
askPlayVideoAudio(videoId, title)
}
}
section.property: "type"
@@ -47,23 +54,54 @@ Kirigami.ScrollablePage {
}
}
}
delegate: Kirigami.BasicListItem {
delegate: Kirigami.SwipeListItem {
id: delegateItem
required property string title
required property int type
required property int index
required property var artists
required property string videoId
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"
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
}
}
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)
}
+143 -79
View File
@@ -1,81 +1,128 @@
// 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
Image {
Layout.fillWidth: true
Layout.fillHeight: true
source: info.thumbnail
}
GridLayout {
id: playerLayout
readonly property bool mobile: width > height
Controls.ScrollView {
Layout.fillHeight: footerLayout.maximized
Layout.fillWidth: true
flow: width > height ? GridLayout.LeftToRight : GridLayout.TopToBottom
visible: footerLayout.maximized
ListView {
id: playlistView
anchors.fill: parent
Item {
Layout.fillWidth: info.thumbnail
Layout.fillHeight: info.thumbnail
Image {
anchors.fill: parent
model: PlaylistModel {
id: playlistModel
source: info.thumbnail
fillMode: Image.PreserveAspectFit
}
delegate: Kirigami.BasicListItem {
required property string title
required property string videoId
required property string artists
required property bool isCurrent
}
highlighted: isCurrent
Item {
Layout.fillWidth: true
Layout.fillHeight: true
onClicked: playlistModel.skipTo(videoId)
Controls.ScrollView {
anchors.fill: parent
ColumnLayout {
ListView {
anchors.fill: parent
id: playlistView
Kirigami.Heading {
Layout.fillWidth: true
clip: true
level: 2
text: title
Controls.BusyIndicator {
anchors.centerIn: parent
visible: UserPlaylistModel.loading || UserPlaylistModel.loading
}
Controls.Label {
Layout.fillWidth: true
text: artists
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 {
text: i18n("Clear")
icon.name: "edit-clear-all"
onClicked: UserPlaylistModel.clear()
}
Controls.ToolButton {
text: i18n("Shuffle")
icon.name: "media-playlist-shuffle"
onClicked: UserPlaylistModel.shufflePlaylist()
}
}
}
}
}
Controls.BusyIndicator {
anchors.centerIn: parent
visible: playlistModel.loading || playlistModel.loading
}
}
}
Behavior on height {
NumberAnimation {
}
}
@@ -91,19 +138,19 @@ ColumnLayout {
VideoInfoExtractor {
id: info
onSongChanged: audio.play()
videoId: playlistModel.currentVideoId
videoId: UserPlaylistModel.currentVideoId
}
Audio {
id: audio
source: info.audioUrl
onStatusChanged: {
if (status === Audio.EndOfMedia) {
console.log("Song ended")
playlistModel.next()
console.log("Song ended");
UserPlaylistModel.next();
}
}
}
@@ -112,13 +159,9 @@ 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()
}
@@ -127,13 +170,10 @@ ColumnLayout {
display: Controls.AbstractButton.IconOnly
Layout.preferredWidth: parent.height
Layout.fillHeight: true
enabled: playlistView.count > 1
enabled: UserPlaylistModel.canSkip
visible: !info.loading
icon.name: "media-skip-forward"
onClicked: playlistModel.next()
onClicked: UserPlaylistModel.next()
}
Controls.BusyIndicator {
@@ -143,45 +183,69 @@ ColumnLayout {
ColumnLayout {
Layout.fillHeight: true
Layout.topMargin: Kirigami.Units.largeSpacing
Layout.bottomMargin: Kirigami.Units.largeSpacing
Layout.topMargin: Kirigami.Units.smallSpacing
Layout.bottomMargin: Kirigami.Units.smallSpacing
Kirigami.Heading {
level: 2
level: 3
Layout.fillWidth: true
elide: Qt.ElideRight
text: info.title ? info.title : i18n("No media playing")
}
Controls.Slider {
Layout.fillWidth: true
RowLayout{
from: 0
to: audio.duration
value: audio.position
enabled: audio.seekable
onMoved: {
console.log("Value:", value)
audio.seek(Math.floor(value))
Controls.Label{
visible: info.title
text: PlayerUtils.formatTimestamp(audio.position)
}
Behavior on value {
NumberAnimation {
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));
}
Behavior on value {
NumberAnimation {
}
}
}
Controls.Label{
visible: info.title
text: PlayerUtils.formatTimestamp(audio.duration)
}
}
}
Controls.ToolButton {
display: Controls.AbstractButton.IconOnly
Layout.preferredWidth: parent.height
text: i18n("Expand")
enabled: playlistView.count > 0
Layout.fillHeight: true
icon.name: footer.maximized ? "arrow-down" : "arrow-up"
onClicked: footer.maximized = !footer.maximized
icon.name: footerLayout.maximized ? "arrow-down" : "arrow-up"
onClicked: footerLayout.maximized = !footerLayout.maximized
}
}
Behavior on height {
NumberAnimation {
}
}
}
+85
View File
@@ -0,0 +1,85 @@
// 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.15
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
}
reuseItems: true
delegate: Kirigami.SwipeListItem {
id: delegateItem
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)
}
]
onClicked: play(videoId)
}
Controls.BusyIndicator {
anchors.centerIn: parent
visible: playlistModel.loading
}
}
}
+126
View File
@@ -0,0 +1,126 @@
// 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.15
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 {
property alias searchQuery: searchModel.searchQuery
title: searchQuery
ListView {
reuseItems: true
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, title) => {
askPlayVideoAudio(videoId, title)
}
}
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
required property string radioPlaylistId
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)
},
Kirigami.Action {
icon.name: "radio"
text: i18n("Radio")
visible: delegateItem.type === SearchModel.Artist && delegateItem.radioPlaylistId
onTriggered: playPlaylist(delegateItem.radioPlaylistId)
}
]
onClicked: searchModel.triggerItem(index)
}
Controls.BusyIndicator {
anchors.centerIn: parent
visible: searchModel.loading
}
Kirigami.PlaceholderMessage {
anchors.centerIn: parent
width: parent.width - (Kirigami.Units.largeSpacing * 4)
visible: parent.count === 0 && !searchModel.loading
text: i18n("Find music on YouTube Music")
helpfulAction: Kirigami.Action {
onTriggered: searchField.forceActiveFocus()
text: "Search"
icon.name: "search"
}
}
}
}
+68 -73
View File
@@ -1,95 +1,90 @@
// 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.Controls 2.12 as Controls
import QtQuick.Layouts 1.3
import org.kde.kirigami 2.14 as Kirigami
import org.kde.ytmusic 1.0
Kirigami.ApplicationWindow {
id: root
property alias searchField: searchField
header: Controls.Control {
padding: Kirigami.Units.largeSpacing
background: Rectangle {
width: parent.width
height: parent.height
anchors.fill: parent
Kirigami.Theme.inherit: false
Kirigami.Theme.colorSet: Kirigami.Theme.Header
color: Kirigami.Theme.backgroundColor
}
contentItem: RowLayout{
Item {
Layout.fillWidth: true
}
Kirigami.SearchField {
id: searchField
delaySearch: true
selectByMouse: true
Layout.fillWidth: true
Layout.maximumWidth: 400
onAccepted: {
pageStack.clear()
pageStack.push("qrc:/SearchPage.qml", {
"searchQuery": text})
}
}
Item {
Layout.fillWidth: true
}
}
}
title: i18n("AudioTube")
controlsVisible: !footer.maximized
contextDrawer: Kirigami.ContextDrawer {
id: contextDrawer
}
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
}
}
}
pageStack.initialPage: "qrc:/SearchPage.qml"
function play(videoId) {
footer.videoId = videoId
UserPlaylistModel.initialVideoId = videoId
}
function playPlaylist(playlistId) {
footer.playlistId = playlistId
UserPlaylistModel.playlistId = playlistId
}
function playShufflePlaylist(playlistId) {
UserPlaylistModel.shuffle = true
UserPlaylistModel.playlistId = playlistId
}
function askPlayVideoAudio(videoId, title) {
showPassiveNotification(i18n("Video playback is not supported yet. Do you want to play only the audio of \"%1\"?", title),
"long",
i18n("Play only Audio"),
function() {
play(videoId)
})
}
Connections {
target: ErrorHandler
function onErrorOccurred(error) {
showPassiveNotification(error)
}
}
footer: PlayerFooter {}
+11
View File
@@ -0,0 +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
#include "errorhandler.h"
ErrorHandler::ErrorHandler(QObject *parent)
: QObject(parent)
{
connect(&YTMusicThread::instance().get(), &AsyncYTMusic::errorOccurred, this, &ErrorHandler::errorOccurred);
}
+19
View File
@@ -0,0 +1,19 @@
// 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);
};
+4
View File
@@ -1,2 +1,6 @@
# SPDX-FileCopyrightText: 2021 Jonah Brüchert <[email protected]>
#
# SPDX-License-Identifier: BSD-2-Clause
add_executable(ytm_example main.cpp)
target_link_libraries(ytm_example PRIVATE ytm)
+9 -4
View File
@@ -1,6 +1,6 @@
// SPDX-FileCopyrightText: 2021 Jonah Brüchert <[email protected]>
//
// SPDX-License-Identifier: GPL-2.0-or-later
// SPDX-License-Identifier: GPL-2.0-only OR GPL-3.0-only OR LicenseRef-KDE-Accepted-GPL
#include <ytmusic.h>
@@ -8,7 +8,7 @@
int main() {
const auto ytm = YTMusic();
const auto results = ytm.search("Syd Matters");
const auto results = ytm.search("Thomas Bangalter");
std::cout << "Found " << results.size() << " results." << std::endl;
@@ -17,7 +17,12 @@ int main() {
using T = std::decay_t<decltype(arg)>;
if constexpr (std::is_same_v<T, search::Album>) {
std::cout << arg.title << std::endl;
ytm.get_album(arg.browse_id);
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);
}
}
} 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);
@@ -37,7 +42,7 @@ int main() {
} else if constexpr (std::is_same_v<T, search::Video>) {
std::cout << arg.title << std::endl;
} else {
std::cout << "non excaustive visitor";
std::cout << "non exaustive visitor";
}
}, result);
}
+25 -7
View File
@@ -1,18 +1,24 @@
// SPDX-FileCopyrightText: 2021 Jonah Brüchert <[email protected]>
//
// SPDX-License-Identifier: GPL-2.0-or-later
// SPDX-License-Identifier: GPL-2.0-only OR GPL-3.0-only OR LicenseRef-KDE-Accepted-GPL
#include <QApplication>
#include <QQmlApplicationEngine>
#include <QtQml>
#include <QUrl>
#include <KLocalizedContext>
#include <KLocalizedString>
#include <KCrash>
#include <KAboutData>
#include "searchmodel.h"
#include "albummodel.h"
#include "videoinfoextractor.h"
#include "artistmodel.h"
#include "userplaylistmodel.h"
#include "errorhandler.h"
#include "playlistmodel.h"
#include "playerutils.h"
constexpr auto URI = "org.kde.ytmusic";
@@ -20,9 +26,14 @@ Q_DECL_EXPORT int main(int argc, char *argv[])
{
QGuiApplication::setAttribute(Qt::AA_EnableHighDpiScaling);
QApplication app(argc, argv);
QCoreApplication::setOrganizationName("KDE");
QCoreApplication::setOrganizationDomain("kde.org");
QCoreApplication::setApplicationName("audiotube");
QCoreApplication::setOrganizationName(QStringLiteral("KDE"));
QCoreApplication::setOrganizationDomain(QStringLiteral("kde.org"));
QCoreApplication::setApplicationName(QStringLiteral("audiotube"));
KLocalizedString::setApplicationDomain("audiotube");
KAboutData::setApplicationData(KAboutData(QStringLiteral("audiotube"), QStringLiteral("AudioTube")));
KCrash::initialize();
QQmlApplicationEngine engine;
@@ -31,6 +42,15 @@ 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();
});
qmlRegisterSingletonType<PlayerUtils>(URI, 1, 0, "PlayerUtils", [](QQmlEngine *, QJSEngine *) {
return new PlayerUtils();
});
engine.rootContext()->setContextObject(new KLocalizedContext(&engine));
engine.load(QUrl(QStringLiteral("qrc:///main.qml")));
@@ -39,7 +59,5 @@ Q_DECL_EXPORT int main(int argc, char *argv[])
return -1;
}
int ret = app.exec();
AsyncYTMusic::stopInstance();
return ret;
return app.exec();
}
+76
View File
@@ -0,0 +1,76 @@
// 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(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;
};
+15
View File
@@ -0,0 +1,15 @@
// 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 "playerutils.h"
PlayerUtils::PlayerUtils(QObject *parent) : QObject(parent)
{
}
QString PlayerUtils::formatTimestamp(quint64 stamp)
{
return m_format.formatDuration(stamp, KFormat::FoldHours);
}
+22
View File
@@ -0,0 +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
#pragma once
#include <QObject>
#include <KFormat>
class PlayerUtils : public QObject
{
Q_OBJECT
public:
explicit PlayerUtils(QObject *parent = nullptr);
Q_INVOKABLE QString formatTimestamp(quint64 stamp);
private:
KFormat m_format;
};
+41 -112
View File
@@ -1,47 +1,46 @@
// SPDX-FileCopyrightText: 2021 Jonah Brüchert <[email protected]>
//
// SPDX-License-Identifier: GPL-2.0-or-later
// SPDX-License-Identifier: GPL-2.0-only OR GPL-3.0-only OR LicenseRef-KDE-Accepted-GPL
#include "playlistmodel.h"
#include <asyncytmusic.h>
#include <QUrl>
#include "asyncytmusic.h"
#include "playlistutils.h"
PlaylistModel::PlaylistModel(QObject *parent)
: QAbstractListModel(parent)
{
connect(this, &PlaylistModel::initialVideoIdChanged, this, [=] {
if (m_initialVideoId.isEmpty()) {
return;
}
setLoading(true);
AsyncYTMusic::instance().fetchWatchPlaylist(m_initialVideoId);
});
connect(this, &PlaylistModel::playlistIdChanged, this, [=] {
if (m_playlistId.isEmpty()) {
return;
}
setLoading(true);
AsyncYTMusic::instance().fetchWatchPlaylist(std::nullopt, m_playlistId);
YTMusicThread::instance()->fetchPlaylist(m_playlistId);
});
connect(&AsyncYTMusic::instance(), &AsyncYTMusic::fetchWatchPlaylistFinished, this, [=](const watch::Playlist &playlist) {
connect(&YTMusicThread::instance().get(), &AsyncYTMusic::fetchPlaylistFinished, this, [=](const playlist::Playlist &playlist) {
setLoading(false);
beginResetModel();
m_playlist = playlist;
if (!m_playlist.tracks.empty()) {
m_currentVideoId = QString::fromStdString(m_playlist.tracks.front().video_id);
}
std::sort(m_playlist.thumbnails.begin(), m_playlist.thumbnails.end());
endResetModel();
currentVideoIdChanged();
Q_EMIT titleChanged();
Q_EMIT thumbnailUrlChanged();
});
}
int PlaylistModel::rowCount(const QModelIndex &parent) const
{
return parent.isValid() ? 0 : m_playlist.tracks.size();
return parent.isValid() ? 0 : int(m_playlist.tracks.size());
}
QHash<int, QByteArray> PlaylistModel::roleNames() const
{
return {
{Title, "title"},
{Artists, "artists"},
{VideoId, "videoId"}
};
}
QVariant PlaylistModel::data(const QModelIndex &index, int role) const
@@ -49,18 +48,13 @@ 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 QVariant::fromValue(m_playlist.tracks[index.row()].artists);
case VideoId:
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();
if (m_playlist.tracks[index.row()].video_id) {
return QString::fromStdString(*m_playlist.tracks[index.row()].video_id);
}
return {};
}
Q_UNREACHABLE();
@@ -68,25 +62,18 @@ QVariant PlaylistModel::data(const QModelIndex &index, int role) const
return {};
}
QHash<int, QByteArray> PlaylistModel::roleNames() const
QString PlaylistModel::playlistId() const
{
return {
{Title, "title"},
{VideoId, "videoId"},
{Artists, "artists"},
{IsCurrent, "isCurrent"}
};
auto id = m_playlistId;
id.remove(QStringLiteral("VL")); // Workaround: get_watch_playlist only accepts
// the playlists without the leading VL
return id;
}
QString PlaylistModel::initialVideoId() const
void PlaylistModel::setPlaylistId(const QString &playlistId)
{
return m_initialVideoId;
}
void PlaylistModel::setInitialVideoId(const QString &videoId)
{
m_initialVideoId = videoId;
Q_EMIT initialVideoIdChanged();
m_playlistId = playlistId;
Q_EMIT playlistIdChanged();
}
bool PlaylistModel::loading() const
@@ -100,74 +87,16 @@ void PlaylistModel::setLoading(bool loading)
Q_EMIT loadingChanged();
}
QString PlaylistModel::nextVideoId() const
QUrl PlaylistModel::thumbnailUrl() 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 {};
if (m_playlist.thumbnails.empty()) {
return QUrl();
}
return QString::fromStdString((currentTrack + 1)->video_id);
return QUrl(QString::fromStdString(m_playlist.thumbnails.back().url));
}
QString PlaylistModel::currentVideoId() const
QString PlaylistModel::title() const
{
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();
return QString::fromStdString(m_playlist.title);
}
+24 -36
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-or-later
// SPDX-License-Identifier: GPL-2.0-only OR GPL-3.0-only OR LicenseRef-KDE-Accepted-GPL
#pragma once
#include <QAbstractListModel>
#include <ytmusic.h>
class PlaylistModel : public QAbstractListModel
@@ -12,55 +12,43 @@ class PlaylistModel : 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(QString playlistId READ playlistId WRITE setPlaylistId NOTIFY playlistIdChanged REQUIRED)
// output
Q_PROPERTY(bool loading READ loading WRITE setLoading NOTIFY loadingChanged)
Q_PROPERTY(QString currentVideoId READ currentVideoId NOTIFY currentVideoIdChanged)
Q_PROPERTY(QUrl thumbnailUrl READ thumbnailUrl NOTIFY thumbnailUrlChanged)
Q_PROPERTY(QString title READ title NOTIFY titleChanged)
public:
enum Role {
Title = Qt::UserRole + 1,
VideoId,
Artists,
IsCurrent
};
explicit PlaylistModel(QObject *parent = nullptr);
enum Role {
Title,
Artists,
VideoId
};
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();
Q_INVOKABLE void next();
Q_INVOKABLE void skipTo(const QString &videoId);
QVariant data(const QModelIndex &index, int role) const override;
QString playlistId() const;
void setPlaylistId(const QString &playlistId);
Q_SIGNAL void playlistIdChanged();
private:
void emitCurrentVideoChanged(const QString &oldVideoId);
bool loading() const;
void setLoading(bool loading);
Q_SIGNAL void loadingChanged();
QString m_initialVideoId;
QUrl thumbnailUrl() const;
Q_SIGNAL void thumbnailUrlChanged();
QString title() const;
Q_SIGNAL void titleChanged();
private:
QString m_playlistId;
QString m_currentVideoId;
bool m_loading = false;
watch::Playlist m_playlist;
playlist::Playlist m_playlist {};
};
+28
View File
@@ -0,0 +1,28 @@
// 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>
namespace PlaylistUtils {
QString 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 {};
}
}
+16
View File
@@ -0,0 +1,16 @@
// 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;
}
namespace PlaylistUtils {
QString artistsToString(const std::vector<meta::Artist> &artists);
};
+8
View File
@@ -1,8 +1,16 @@
<!--
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
-->
<RCC>
<qresource prefix="/">
<file alias="main.qml">contents/ui/main.qml</file>
<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>
+58 -12
View File
@@ -1,11 +1,9 @@
// SPDX-FileCopyrightText: 2021 Jonah Brüchert <[email protected]>
//
// SPDX-License-Identifier: GPL-2.0-or-later
// SPDX-License-Identifier: GPL-2.0-only OR GPL-3.0-only OR LicenseRef-KDE-Accepted-GPL
#include "searchmodel.h"
#include <QDebug>
SearchModel::SearchModel(QObject *parent)
: QAbstractListModel(parent)
{
@@ -18,23 +16,22 @@ SearchModel::SearchModel(QObject *parent)
}
setLoading(true);
AsyncYTMusic::instance().search(m_searchQuery);
YTMusicThread::instance()->search(m_searchQuery);
});
connect(&AsyncYTMusic::instance(), &AsyncYTMusic::searchFinished, this, [=](const std::vector<search::SearchResultItem> &results) {
connect(&YTMusicThread::instance().get(), &AsyncYTMusic::searchFinished, this, [=](const std::vector<search::SearchResultItem> &results) {
beginResetModel();
setLoading(false);
m_searchResults = results;
endResetModel();
});
}
SearchModel::~SearchModel()
{
connect(&YTMusicThread::instance().get(), &AsyncYTMusic::errorOccurred, this, [=] {
setLoading(false);
});
}
int SearchModel::rowCount(const QModelIndex &parent) const
{
return parent.isValid() ? 0 : m_searchResults.size();
return parent.isValid() ? 0 : int(m_searchResults.size());
}
QVariant SearchModel::data(const QModelIndex &index, int role) const
@@ -74,6 +71,52 @@ 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())));
case RadioPlaylistId:
return std::visit([&](auto &&arg) {
using T = std::decay_t<decltype(arg)>;
if constexpr (std::is_same_v<T, search::Artist>) {
if (arg.radio_id) {
return QString::fromStdString(*arg.radio_id);
}
}
return QString();
}, m_searchResults.at(index.row()));
}
Q_UNREACHABLE();
@@ -85,7 +128,10 @@ QHash<int, QByteArray> SearchModel::roleNames() const
{
return {
{Title, "title"},
{Type, "type"}
{Type, "type"},
{VideoId, "videoId"},
{Artists, "artists"},
{RadioPlaylistId, "radioPlaylistId"},
};
}
@@ -124,7 +170,7 @@ void SearchModel::triggerItem(int row)
} else if constexpr (std::is_same_v<T, search::Song>) {
Q_EMIT openSong(QString::fromStdString(arg.video_id));
} else if constexpr (std::is_same_v<T, search::Video>) {
Q_EMIT openVideo(QString::fromStdString(arg.video_id));
Q_EMIT openVideo(QString::fromStdString(arg.video_id), QString::fromStdString(arg.title));
} else {
Q_UNREACHABLE();
}
+6 -4
View File
@@ -1,6 +1,6 @@
// SPDX-FileCopyrightText: 2021 Jonah Brüchert <[email protected]>
//
// SPDX-License-Identifier: GPL-2.0-or-later
// SPDX-License-Identifier: GPL-2.0-only OR GPL-3.0-only OR LicenseRef-KDE-Accepted-GPL
#pragma once
@@ -28,11 +28,13 @@ public:
enum Role {
Title = Qt::UserRole + 1,
Type
Type,
VideoId,
Artists,
RadioPlaylistId
};
explicit SearchModel(QObject *parent = nullptr);
~SearchModel();
int rowCount(const QModelIndex &parent) const override;
QVariant data(const QModelIndex &index, int role) const override;
@@ -52,7 +54,7 @@ public:
Q_SIGNAL void openArtist(const QString &browseId);
Q_SIGNAL void openPlaylist(const QString &browseId);
Q_SIGNAL void openSong(const QString &videoId);
Q_SIGNAL void openVideo(const QString &videoId);
Q_SIGNAL void openVideo(const QString &videoId, const QString &title);
private:
QString m_searchQuery;
+302
View File
@@ -0,0 +1,302 @@
// 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)
{
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);
});
}
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();
}
+81
View File
@@ -0,0 +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
#pragma once
#include <QAbstractListModel>
#include <ytmusic.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;
};
+8 -7
View File
@@ -1,26 +1,29 @@
// SPDX-FileCopyrightText: 2021 Jonah Brüchert <[email protected]>
//
// SPDX-License-Identifier: GPL-2.0-or-later
// SPDX-License-Identifier: GPL-2.0-only OR GPL-3.0-only OR LicenseRef-KDE-Accepted-GPL
#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);
AsyncYTMusic::instance().extractVideoInfo(QString::fromStdString(m_videoId.toStdString()));
YTMusicThread::instance()->extractVideoInfo(QString::fromStdString(m_videoId.toStdString()));
});
connect(&AsyncYTMusic::instance(), &AsyncYTMusic::extractVideoInfoFinished, this, [=](const video_info::VideoInfo &info) {
connect(&YTMusicThread::instance().get(), &AsyncYTMusic::extractVideoInfoFinished, this, [=](const video_info::VideoInfo &info) {
m_videoInfo = info;
setLoading(false);
Q_EMIT audioUrlChanged();
@@ -30,7 +33,6 @@ VideoInfoExtractor::VideoInfoExtractor(QObject *parent)
});
}
QUrl VideoInfoExtractor::audioUrl() const
{
if (m_videoInfo.formats.empty()) {
@@ -79,7 +81,6 @@ QString VideoInfoExtractor::title() const
QString VideoInfoExtractor::thumbnail() const
{
qDebug() << "thumb" << QString::fromStdString(m_videoInfo.thumnnail);
return QString::fromStdString(m_videoInfo.thumnnail);
}
+2 -2
View File
@@ -1,6 +1,6 @@
// SPDX-FileCopyrightText: 2021 Jonah Brüchert <[email protected]>
//
// SPDX-License-Identifier: GPL-2.0-or-later
// SPDX-License-Identifier: GPL-2.0-only OR GPL-3.0-only OR LicenseRef-KDE-Accepted-GPL
#pragma once
@@ -21,7 +21,7 @@ class VideoInfoExtractor : public QObject
Q_PROPERTY(bool loading READ loading WRITE setLoading NOTIFY loadingChanged)
public:
VideoInfoExtractor(QObject *parent = nullptr);
explicit VideoInfoExtractor(QObject *parent = nullptr);
QUrl audioUrl() const;
Q_SIGNAL void audioUrlChanged();
+93 -54
View File
@@ -1,6 +1,6 @@
// SPDX-FileCopyrightText: 2021 Jonah Brüchert <[email protected]>
//
// SPDX-License-Identifier: GPL-2.0-or-later
// SPDX-License-Identifier: GPL-2.0-only OR GPL-3.0-only OR LicenseRef-KDE-Accepted-GPL
#include "ytmusic.h"
@@ -15,14 +15,51 @@ using namespace py::literals;
#define UNEXPORT __attribute__ ((visibility("hidden")))
constexpr auto TESTED_YTMUSICAPI_VERSION = "0.17.3";
struct UNEXPORT YTMusicPrivate {
py::scoped_interpreter guard {};
py::object ytmusic;
std::optional<std::string> auth;
std::optional<std::string> user;
std::optional<bool> requests_session;
std::optional<std::map<std::string, std::string> > proxies;
std::string language;
py::object get_ytmusic() {
if (ytmusic.is_none()) {
const auto module = py::module::import("ytmusicapi");
ytmusic = module.attr("YTMusic")(auth, user, requests_session, proxies, language);
// Some of the called python code randomly fails if the encoding is not utf8
setenv("LC_ALL", "en_US.utf8", true);
const auto version = module.attr("_version").attr("__version__").cast<std::string>();
if (version != TESTED_YTMUSICAPI_VERSION) {
std::cerr << "Running with untested version of ytmusicapi." << std::endl;
std::cerr << "The currently tested and supported version is " << TESTED_YTMUSICAPI_VERSION << std::endl;
}
}
return ytmusic;
}
py::object get_ytdl() {
// lazy initialization
if (ytdl.is_none()) {
ytdl = py::module::import("youtube_dl").attr("YoutubeDL")(py::dict());
}
return ytdl;
}
private:
py::object ytmusic = py::none();
py::object ytdl = py::none();
};
template <typename T>
std::optional<T> optional_key(const py::handle &obj, const char *name) {
std::optional<T> optional_key(py::handle obj, const char *name) {
if (!obj.cast<py::dict>().contains(name)) {
return std::nullopt;
}
@@ -30,7 +67,7 @@ std::optional<T> optional_key(const py::handle &obj, const char *name) {
return obj[name].cast<T>();
}
meta::Thumbnail extract_thumbnail(const py::handle &thumbnail) {
meta::Thumbnail extract_thumbnail(py::handle thumbnail) {
return {
thumbnail["url"].cast<std::string>(),
thumbnail["width"].cast<int>(),
@@ -38,14 +75,14 @@ meta::Thumbnail extract_thumbnail(const py::handle &thumbnail) {
};
}
meta::Artist extract_meta_artist(const py::handle &artist) {
meta::Artist extract_meta_artist(py::handle artist) {
return {
artist["name"].cast<std::string>(),
artist["id"].cast<std::optional<std::string>>()
};
};
album::Track extract_album_track(const py::handle &track) {
album::Track extract_album_track(py::handle track) {
return {
track["index"].cast<std::string>(),
track["title"].cast<std::string>(),
@@ -56,24 +93,28 @@ album::Track extract_album_track(const py::handle &track) {
};
}
video_info::Format extract_format(const py::handle &format) {
video_info::Format extract_format(py::handle format) {
return {
format["quality"].cast<int>(),
optional_key<int>(format, "quality"),
format["url"].cast<std::string>(),
format["vcodec"].cast<std::string>(),
format["acodec"].cast<std::string>()
};
}
playlist::Track extract_playlist_track(const py::handle &track);
watch::Playlist::Track extract_watch_track(const py::handle &track);
playlist::Track extract_playlist_track(py::handle track);
watch::Playlist::Track extract_watch_track(py::handle track);
template <typename T>
inline auto extract_py_list(const py::handle &obj) {
const py::list list = obj.cast<py::list>();
inline auto extract_py_list(py::handle obj) {
if (obj.is_none()) {
return std::vector<T>();
}
const auto list = obj.cast<py::list>();
std::vector<T> output;
std::transform(list.begin(), list.end(), std::back_inserter(output), [](const py::handle &item) {
std::transform(list.begin(), list.end(), std::back_inserter(output), [](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>) {
@@ -94,19 +135,19 @@ inline auto extract_py_list(const py::handle &obj) {
return output;
}
meta::Album extract_meta_album(const py::handle &album) {
meta::Album extract_meta_album(py::handle album) {
return meta::Album {
album["name"].cast<std::string>(),
album["id"].cast<std::optional<std::string>>()
};
}
watch::Playlist::Track extract_watch_track(const py::handle &track) {
watch::Playlist::Track extract_watch_track(py::handle track) {
return {
track["title"].cast<std::string>(),
track["length"].cast<std::string>(),
track["length"].cast<std::optional<std::string>>(),
track["videoId"].cast<std::string>(),
track["playlistId"].cast<std::string>(),
optional_key<std::string>(track, "playlistId"),
extract_py_list<meta::Thumbnail>(track["thumbnail"]),
track["likeStatus"].cast<std::optional<std::string>>(),
extract_py_list<meta::Artist>(track["artists"]),
@@ -121,7 +162,7 @@ watch::Playlist::Track extract_watch_track(const py::handle &track) {
}
playlist::Track extract_playlist_track(const py::handle &track) {
playlist::Track extract_playlist_track(py::handle track) {
return {
track["videoId"].cast<std::optional<std::string>>(),
track["title"].cast<std::string>(),
@@ -141,7 +182,7 @@ playlist::Track extract_playlist_track(const py::handle &track) {
};
}
artist::Artist::Song::Album extract_song_album(const py::handle &album) {
artist::Artist::Song::Album extract_song_album(py::handle album) {
return {
album["name"].cast<std::string>(),
album["id"].cast<std::string>()
@@ -149,14 +190,14 @@ artist::Artist::Song::Album extract_song_album(const py::handle &album) {
};
template <typename T>
auto extract_artist_section_results(const py::handle &section) {
auto extract_artist_section_results(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), [](const py::handle &result) {
std::transform(py_results.begin(), py_results.end(), std::back_inserter(results), [](py::handle result) {
if constexpr(std::is_same_v<T, artist::Artist::Song>) {
return artist::Artist::Song {
result["videoId"].cast<std::string>(),
@@ -169,7 +210,7 @@ auto extract_artist_section_results(const py::handle &section) {
return artist::Artist::Album {
result["title"].cast<std::string>(),
extract_py_list<meta::Thumbnail>(result["thumbnails"]),
result["year"].cast<std::string>(),
result["year"].cast<std::optional<std::string>>(),
result["browseId"].cast<std::string>(),
std::nullopt
};
@@ -197,7 +238,7 @@ auto extract_artist_section_results(const py::handle &section) {
}
template<typename T>
std::optional<artist::Artist::Section<T>> extract_artist_section(const py::handle &artist, const char* name) {
std::optional<artist::Artist::Section<T>> extract_artist_section(py::handle artist, const char* name) {
if (artist.cast<py::dict>().contains(name)) {
const auto section = artist[name];
return artist::Artist::Section<T> {
@@ -210,8 +251,8 @@ std::optional<artist::Artist::Section<T>> extract_artist_section(const py::handl
}
}
search::SearchResultItem extract_search_result(const py::handle &result) {
const std::string resultType = result["resultType"].cast<std::string>();
std::optional<search::SearchResultItem> extract_search_result(py::handle result) {
const auto resultType = result["resultType"].cast<std::string>();
if (resultType == "video") {
return search::Video {
{
@@ -257,8 +298,10 @@ search::SearchResultItem extract_search_result(const py::handle &result) {
optional_key<std::string>(result, "radioId")
};
} else {
Py_UNREACHABLE();
};
std::cerr << "Warning: Unsupported search result type found" << std::endl;
std::cerr << "It's called: " << resultType;
return std::nullopt;
}
}
YTMusic::YTMusic(
@@ -269,14 +312,11 @@ YTMusic::YTMusic(
const std::string &language)
: d(std::make_unique<YTMusicPrivate>())
{
const auto module = py::module::import("ytmusicapi");
d->ytmusic = module.attr("YTMusic")(auth, user, requests_session, proxies, language);
const auto version = module.attr("_version").attr("__version__").cast<std::string>();
if (version != "0.14.3") {
std::cerr << "Running with untested version of ytmusicapi." << std::endl;
std::cerr << "The currently tested and supported version is 0.14.3" << std::endl;
}
d->auth = auth;
d->user = user;
d->requests_session = requests_session;
d->proxies = proxies;
d->language = language;
}
YTMusic::~YTMusic() = default;
@@ -287,17 +327,21 @@ std::vector<search::SearchResultItem> YTMusic::search(
const int limit,
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;
const auto results = d->get_ytmusic().attr("search")(query, filter, limit, ignore_spelling).cast<py::list>();
std::transform(results.begin(), results.end(), std::back_inserter(output), extract_search_result);
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());
}
};
return output;
}
artist::Artist YTMusic::get_artist(const std::string &channel_id) const
{
const auto artist = d->ytmusic.attr("get_artist")(channel_id);
const auto artist = d->get_ytmusic().attr("get_artist")(channel_id);
return artist::Artist {
artist["description"].cast<std::optional<std::string>>(),
artist["views"].cast<std::optional<std::string>>(),
@@ -315,7 +359,7 @@ artist::Artist YTMusic::get_artist(const std::string &channel_id) const
album::Album YTMusic::get_album(const std::string &browseId) const
{
const auto album = d->ytmusic.attr("get_album")(browseId);
const auto album = d->get_ytmusic().attr("get_album")(browseId);
return {
album["title"].cast<std::string>(),
@@ -338,7 +382,7 @@ album::Album YTMusic::get_album(const std::string &browseId) const
song::Song YTMusic::get_song(const std::string &video_id) const
{
const auto song = d->ytmusic.attr("get_song")(video_id);
const auto song = d->get_ytmusic().attr("get_song")(video_id);
return {
song["videoId"].cast<std::string>(),
@@ -370,7 +414,7 @@ song::Song YTMusic::get_song(const std::string &video_id) const
playlist::Playlist YTMusic::get_playlist(const std::string &playlist_id, int limit) const
{
const auto playlist = d->ytmusic.attr("get_playlist")(playlist_id, limit);
const auto playlist = d->get_ytmusic().attr("get_playlist")(playlist_id, limit);
return {
playlist["id"].cast<std::string>(),
@@ -387,10 +431,10 @@ playlist::Playlist YTMusic::get_playlist(const std::string &playlist_id, int lim
std::vector<artist::Artist::Album> YTMusic::get_artist_albums(const std::string &channel_id, const std::string &params) const
{
const auto py_albums = d->ytmusic.attr("get_artist_albums")(channel_id, params);
const auto py_albums = d->get_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), [](const py::handle &album) {
std::transform(py_albums.begin(), py_albums.end(), std::back_inserter(albums), [](py::handle album) {
return artist::Artist::Album {
album["title"].cast<std::string>(),
extract_py_list<meta::Thumbnail>(album["thumbnails"]),
@@ -407,15 +451,7 @@ video_info::VideoInfo YTMusic::extract_video_info(const std::string &video_id) c
{
using namespace pybind11::literals;
// lazy initialization
if (d->ytdl.is_none()) {
const auto module = py::module::import("youtube_dl");
py::dict options;
d->ytdl = module.attr("YoutubeDL")(options);
}
const auto info = d->ytdl.attr("extract_info")(video_id, "download"_a=py::bool_(false));
//py::print(py::module::import("json").attr("dumps")(info, "indent"_a=4));
const auto info = d->get_ytdl().attr("extract_info")(video_id, "download"_a=py::bool_(false));
return {
info["id"].cast<std::string>(),
@@ -430,7 +466,10 @@ 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, playlistId, limit, params);
const auto playlist = d->get_ytmusic().attr("get_watch_playlist")("videoId"_a = videoId,
"playlistId"_a = playlistId,
"limit"_a = py::int_(limit),
"params"_a = 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-or-later
// SPDX-License-Identifier: GPL-2.0-only OR GPL-3.0-only OR LicenseRef-KDE-Accepted-GPL
#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::string year;
std::string browseId;
std::optional<std::string> year;
std::string browse_id;
std::optional<std::string> type;
};
@@ -228,7 +228,7 @@ struct Playlist {
namespace video_info {
struct Format {
int quality;
std::optional<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::string length;
std::optional<std::string> length;
std::string video_id;
std::string playlistId;
std::optional<std::string> playlistId;
std::vector<meta::Thumbnail> thumbnail;
std::optional<std::string> like_status;
std::vector<meta::Artist> artists;