Compare commits

...
39 Commits
Author SHA1 Message Date
Bhushan Shah 762976159e appdata: add changelog for 21.12 2021-12-05 19:39:47 +05:30
Bhushan Shah de1a872f74 GIT_SILENT Update version number for 21.12 2021-12-05 10:15:46 +05:30
Dimitris Kardarakos 3f39fc9e90 Substitute video-play passive notification with an inline message
On mobile, the action of the video play notification was not properly shown. On top of that, an inline message seems more suitable for this purpose. An explicit cancel action has been added as well; previously it was accomplished by ignoring the notification.
2021-12-03 15:43:00 +02:00
Jonah Brüchert e8e6a5f1e2 Update some more places to ytdlp 2021-11-29 23:21:32 +01:00
Jonah Brüchert 51a9799281 Switch to yt-dlp 2021-11-29 01:43:37 +01:00
Jonah Brüchert 73078eb5e7 Commit forgotten changes 2021-11-11 12:00:51 +01:00
Jonah Brüchert d138b5c67b Further reduce amount of code of the async YTMusic wrapper 2021-11-11 12:00:16 +01:00
Jonah Brüchert ef3846df6b More awesome map_optional function 2021-11-11 11:40:27 +01:00
Jonah Brüchert a31494d83f Simplify multithreading 2021-11-11 11:22:43 +01:00
Jonah Brüchert b131fcc7d9 Make the progress bar smooth
The position update seems to come every second, so an animation duration of a second should produce a smooth progress.
2021-11-11 11:02:23 +01:00
Jonah Brüchert e6379db384 Update tested ytmusicapi version to 0.19.4 2021-11-04 22:36:17 +01:00
Jonah Brüchert f50cf92e9a flatpak: Update python packages 2021-10-27 00:37:12 +02:00
Jonah Brüchert e9e0e4f143 Fix typo 2021-09-30 01:08:06 +02:00
Jonah Brüchert dfc0b8cbcd Fix extracting album tracks with ytmusicapi 0.19.3 2021-09-30 00:02:03 +02:00
Jonah Brüchert 473b4ee83e Update flatpak runtime 2021-09-29 23:46:25 +02:00
Jonah Brüchert f40c9fd497 Update ytmusicapi 2021-09-29 23:32:36 +02:00
Jonah Brüchert 0ca21344f8 Fix some crashes 2021-09-23 21:58:18 +02:00
l10n daemon script d4d85a8b58 GIT_SILENT made messages (after extraction) 2021-09-22 00:20:11 +00:00
l10n daemon script cfd4b3de53 GIT_SILENT made messages (after extraction) 2021-09-20 00:21:06 +00:00
Jonah Brüchert 96c5f344cc Also offer playlist actions for videos 2021-09-06 23:26:54 +02:00
Jonah Brüchert d6e8ddca11 get_artist: Make description key optional 2021-09-04 21:35:35 +02:00
Jonah Brüchert db63766cc7 Make optional_key do the right thing even if the key exists but is None 2021-09-04 21:34:57 +02:00
Jonah Brüchert 048e876710 Add debug output for search results that could not be understood 2021-09-03 20:11:08 +02:00
Jonah Brüchert d7e74e2a5f SearchPage: Add section headers 2021-09-03 20:05:44 +02:00
Jonah Brüchert 722b78e49b Make album description optional 2021-09-03 19:40:27 +02:00
Jonah Brüchert 734caa0280 Fix compatibility with ytmusicapi 0.19.1 2021-09-03 17:39:50 +02:00
Bhushan Shah 69901cb69c GIT_SILENT: Update appstream data for 21.08 2021-08-31 15:40:02 +05:30
Bhushan Shah e230adf223 GIT_SILENT: drop the kdev4 file, we don't commit this to repo 2021-08-31 15:19:07 +05:30
Bhushan Shah 07584b73f4 GIT_SILENT: Update cmake version for 21.08 2021-08-31 15:13:22 +05:30
Jonah Brüchert 1b29a028a6 cmake: Prepare for PlaMo gear 2021-08-09 11:51:46 +02:00
l10n daemon script 736d1789c9 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-08-01 01:22:02 +00:00
l10n daemon script 01f22c517a GIT_SILENT made messages (after extraction) 2021-08-01 00:24:21 +00:00
l10n daemon script edd171c97b 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-27 01:26:36 +00:00
Jonah Brüchert 873c791262 Fix page stack sometimes appearing in the footer 2021-07-18 18:11:08 +02:00
Jonah Brüchert 068a5b756a Stop the loading animation if a query fails 2021-07-12 01:50:42 +02:00
Jonah Brüchert db35f2a5e6 Update ytmusicapi 2021-07-12 00:25:17 +02:00
Jonah Brüchert c06bb7ad03 Fix new search bar overlaying the player 2021-07-10 20:30:22 +02:00
Jonah Brüchert 1c63395497 Fix i18n 2021-07-10 19:51:47 +02:00
Jonah Brüchert ba79cd6b5a Add new dependencies to README 2021-07-10 19:38:43 +02:00
40 changed files with 546 additions and 529 deletions

No files matched your search

+2
View File
@@ -1,6 +1,8 @@
# SPDX-FileCopyrightText: 2021 Jonah Brüchert <[email protected]>
# SPDX-FileCopyrightText: 2021 Bhushan Shah <[email protected]>
#
# SPDX-License-Identifier: GPL-2.0-only OR GPL-3.0-only OR LicenseRef-KDE-Accepted-GPL
*.kdev4
CMakeLists.txt.user
flatpak/flatpak-builder-tools/
+7 -1
View File
@@ -8,6 +8,7 @@ project(audiotube)
include(FeatureSummary)
set(PROJECT_VERSION "21.12")
set(QT5_MIN_VERSION 5.15)
set(KF5_MIN_VERSION 5.81)
@@ -25,12 +26,17 @@ include(ECMSetupVersion)
include(ECMGenerateHeaders)
include(ECMPoQmTools)
ecm_setup_version(${PROJECT_VERSION}
VARIABLE_PREFIX AUDIOTUBE
VERSION_HEADER ${CMAKE_CURRENT_BINARY_DIR}/version.h
)
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 CoreAddons Crash)
find_package(pybind11 REQUIRED)
find_package(YoutubeDL REQUIRED RUNTIME)
find_package(Ytdlp REQUIRED RUNTIME)
find_package(YTMusicAPI REQUIRED RUNTIME)
add_subdirectory(src)
+1 -1
View File
@@ -4,7 +4,7 @@ AudioTube is a client for YouTube Music.
# Dependencies
It depends on Qt and Kirigami in addition to a few python packages:
It depends on Qt, Kirigami, KI18n, KCoreAddons and KCrash in addition to a few python packages:
* ytmusicapi
* youtube_dl
-4
View File
@@ -1,4 +0,0 @@
[Project]
CreatedFrom=CMakeLists.txt
Manager=KDevCMakeManager
Name=audiotube
-3
View File
@@ -1,3 +0,0 @@
SPDX-FileCopyrightText: 2021 Jonah Brüchert <[email protected]>
SPDX-License-Identifier: CC0-1.0
@@ -4,8 +4,8 @@
find_package(Python3 REQUIRED COMPONENTS Interpreter)
execute_process(COMMAND ${Python3_EXECUTABLE} -c "import youtube_dl" RESULT_VARIABLE YTDL_CHECK_RESULT)
execute_process(COMMAND ${Python3_EXECUTABLE} -c "import yt_dlp" RESULT_VARIABLE YTDLP_CHECK_RESULT)
if (${YTDL_CHECK_RESULT} EQUAL 0)
set(YoutubeDL_FOUND TRUE)
if (${YTDLP_CHECK_RESULT} EQUAL 0)
set(Ytdlp_FOUND TRUE)
endif()
-14
View File
@@ -1,14 +0,0 @@
{
"name": "python3-youtube_dl",
"buildsystem": "simple",
"build-commands": [
"pip3 install --verbose --exists-action=i --no-index --find-links=\"file://${PWD}\" --prefix=${FLATPAK_DEST} \"youtube_dl\" --no-build-isolation"
],
"sources": [
{
"type": "file",
"url": "https://files.pythonhosted.org/packages/c6/75/05979677d9abc76851d13d8db3951e39017ac223545adab6e8576fa0cbe7/youtube_dl-2021.6.6.tar.gz",
"sha256": "cb2d3ee002158ede783e97a82c95f3817594df54367ea6a77ce5ceea4772f0ab"
}
]
}
+29
View File
@@ -0,0 +1,29 @@
{
"name": "python3-yt-dlp",
"buildsystem": "simple",
"build-commands": [
"pip3 install --verbose --exists-action=i --no-index --find-links=\"file://${PWD}\" --prefix=${FLATPAK_DEST} \"yt-dlp\" --no-build-isolation"
],
"sources": [
{
"type": "file",
"url": "https://files.pythonhosted.org/packages/5e/2a/3cbe2e29926784d8718eb2f92357d7e22caf393f24e19287746076ffc9f2/yt_dlp-2021.11.10.1-py2.py3-none-any.whl",
"sha256": "9c3d85fdeeac3d61cfc85fd72d55fe6b63fcf1d19d05e2841cf2e544922ed157"
},
{
"type": "file",
"url": "https://files.pythonhosted.org/packages/69/77/591bbc51a5ed6a906a7813e60a9627f988f9546513fcf9d250eb31ec8689/websockets-10.1.tar.gz",
"sha256": "181d2b25de5a437b36aefedaf006ecb6fa3aa1328ec0236cdde15f32f9d3ff6d"
},
{
"type": "file",
"url": "https://files.pythonhosted.org/packages/16/b3/f7aa8edf2ff4495116f95fd442b2a346aa55d1d46313143c8814886dbcdb/mutagen-1.45.1-py3-none-any.whl",
"sha256": "9c9f243fcec7f410f138cb12c21c84c64fde4195481a30c9bfb05b5f003adfed"
},
{
"type": "file",
"url": "https://files.pythonhosted.org/packages/47/14/dd9ad29cd29ea4cc521286f2cb401ca7ac6fd5db0791c5e9bacaf2c9ac78/pycryptodomex-3.11.0.tar.gz",
"sha256": "0398366656bb55ebdb1d1d493a7175fc48ade449283086db254ac44c7d318d6d"
}
]
}
File renamed without changes.
+12 -12
View File
@@ -7,33 +7,33 @@
"sources": [
{
"type": "file",
"url": "https://files.pythonhosted.org/packages/4f/5a/597ef5911cb8919efe4d86206aa8b2658616d676a7088f0825ca08bd7cb8/urllib3-1.26.6.tar.gz",
"sha256": "f57b4c16c62fa2760b7e3d97c35b255512fb6b59a259730f36ba32ce9f8e342f"
"url": "https://files.pythonhosted.org/packages/7b/77/f341b20e7307f18ede4625867cbb8e18c20199117e0c23f7c6b53fe6597d/ytmusicapi-0.19.4-py3-none-any.whl",
"sha256": "d0e980b35cf290eae409dcdc6ee31c5c358b28baebf1052e9fc9f446fc7901b7"
},
{
"type": "file",
"url": "https://files.pythonhosted.org/packages/ea/b7/e0e3c1c467636186c39925827be42f16fee389dc404ac29e930e9136be70/idna-2.10.tar.gz",
"sha256": "b307872f855b18632ce0c21c5e45be78c0ea7ae4c15c828c20788b26921eb3f6"
"url": "https://files.pythonhosted.org/packages/92/96/144f70b972a9c0eabbd4391ef93ccd49d0f2747f4f6a2a2738e99e5adc65/requests-2.26.0-py2.py3-none-any.whl",
"sha256": "6c1246513ecd5ecd4528a0906f910e8f0f9c6b8ec72030dc9fd154dc1a6efd24"
},
{
"type": "file",
"url": "https://files.pythonhosted.org/packages/ee/2d/9cdc2b527e127b4c9db64b86647d567985940ac3698eeabc7ffaccb4ea61/chardet-4.0.0.tar.gz",
"sha256": "0d6f53a15db4120f2b08c94f11e7d93d2c911ee118b6b30a04ec3ee8310179fa"
"url": "https://files.pythonhosted.org/packages/c8/27/141554fc0f42c05dd318fbb0be0e3e018da686544a3ff452762e49ccac58/charset_normalizer-2.0.8-py3-none-any.whl",
"sha256": "83fcdeb225499d6344c8f7f34684c2981270beacc32ede2e669e94f7fa544405"
},
{
"type": "file",
"url": "https://files.pythonhosted.org/packages/6d/78/f8db8d57f520a54f0b8a438319c342c61c22759d8f9a1cd2e2180b5e5ea9/certifi-2021.5.30.tar.gz",
"sha256": "2bbf76fd432960138b3ef6dda3dde0544f27cbf8546c458e60baf371917ba9ee"
"url": "https://files.pythonhosted.org/packages/37/45/946c02767aabb873146011e665728b680884cd8fe70dde973c640e45b775/certifi-2021.10.8-py2.py3-none-any.whl",
"sha256": "d62a0163eb4c2344ac042ab2bdf75399a71a2d8c7d47eac2e2ee91b9d6339569"
},
{
"type": "file",
"url": "https://files.pythonhosted.org/packages/6b/47/c14abc08432ab22dc18b9892252efaf005ab44066de871e72a38d6af464b/requests-2.25.1.tar.gz",
"sha256": "27973dd4a904a4f13b263a19c866c13b92a39ed1c964655f025f3f8d3d75b804"
"url": "https://files.pythonhosted.org/packages/04/a2/d918dcd22354d8958fe113e1a3630137e0fc8b44859ade3063982eacd2a4/idna-3.3-py3-none-any.whl",
"sha256": "84d9dd047ffa80596e0f246e2eab0b391788b0503584e8945f2368256d2735ff"
},
{
"type": "file",
"url": "https://files.pythonhosted.org/packages/1b/8e/2bc4c8160083bbfaac215637f1e9f4a43263833c2e81212cba3073aeaa25/ytmusicapi-0.17.3.tar.gz",
"sha256": "9a249cc53efd6408034f401a9a4375272a9b339e8eb64f3a2e713a1ccd06d55b"
"url": "https://files.pythonhosted.org/packages/af/f4/524415c0744552cce7d8bf3669af78e8a069514405ea4fcbd0cc44733744/urllib3-1.26.7-py2.py3-none-any.whl",
"sha256": "c4fdf4019605b6e5423637e01bc9fe4daef873709a7973e195ceba0a62bbc844"
}
]
}
+1 -1
View File
@@ -16,5 +16,5 @@ else
git -C flatpak-builder-tools pull
fi
./flatpak-builder-tools/pip/flatpak-pip-generator youtube_dl
./flatpak-builder-tools/pip/flatpak-pip-generator yt-dlp
./flatpak-builder-tools/pip/flatpak-pip-generator ytmusicapi
+12 -4
View File
@@ -30,8 +30,8 @@ SPDX-License-Identifier: CC0-1.0
<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="ca">Client convergent de música de YouTube</summary>
<summary xml:lang="ca-valencia">Client convergent de 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>
@@ -42,7 +42,7 @@ SPDX-License-Identifier: CC0-1.0
<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="pl">Adaptacyjny program do YouTube Music</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>
@@ -76,6 +76,14 @@ SPDX-License-Identifier: CC0-1.0
<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>
<releases>
<release version="21.12" date="2021-12-07">
<url>https://www.plasma-mobile.org/2021/12/07/plasma-mobile-gear-21-12/</url>
</release>
<release version="21.08" date="2021-08-31">
<url>https://www.plasma-mobile.org/2021/08/31/plasma-mobile-gear-21-08/</url>
</release>
</releases>
<launchable type="desktop-id">org.kde.audiotube.desktop</launchable>
<screenshots>
<screenshot>
@@ -104,7 +112,7 @@ SPDX-License-Identifier: CC0-1.0
<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="pl">AudioTube może przeszukiwać serwis YouTube Music, 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>
+3 -1
View File
@@ -17,6 +17,7 @@ Name[pa]=ਆਡੀਓ-ਟਿਊਬ
Name[pl]=AudioTube
Name[pt]=AudioTube
Name[pt_BR]=AudioTube
Name[ro]=AudioTube
Name[sk]=AudioTube
Name[sl]=AudioTube
Name[sv]=AudioTube
@@ -37,9 +38,10 @@ Comment[it]=Client YouTube Music
Comment[ko]=YouTube Music 클라이언트
Comment[nl]=Muziekclient van YouTube
Comment[pa]=ਯੂਟਿਊਬ ਸੰਗੀਤ ਕਲਾਈਂਟ
Comment[pl]=Program do muzyki z YouTube
Comment[pl]=Program do YouTube Music
Comment[pt]=Cliente do YouTube Music
Comment[pt_BR]=Cliente YouTube Music
Comment[ro]=Client de muzică pentru YouTube
Comment[sk]=Hudobný klient YouTube
Comment[sl]=Glasbeni odjemalec Youtube
Comment[sv]=YouTube-musikprogram
+2 -2
View File
@@ -1,7 +1,7 @@
{
"id": "org.kde.audiotube",
"runtime": "org.kde.Platform",
"runtime-version": "5.15",
"runtime-version": "5.15-21.08",
"sdk": "org.kde.Sdk",
"command": "audiotube",
"tags": ["nightly"],
@@ -21,7 +21,7 @@
],
"modules": [
"flatpak/python3-youtube_dl.json",
"flatpak/python3-yt-dlp.json",
"flatpak/python3-ytmusicapi.json",
{
"name": "pybind11",
+2 -2
View File
@@ -3,5 +3,5 @@
#
# SPDX-License-Identifier: GPL-2.0-only OR GPL-3.0-only OR LicenseRef-KDE-Accepted-GPL
ytmusicapi==0.17.3
youtube_dl
ytmusicapi==0.19.4
ytdlp
+1
View File
@@ -24,6 +24,7 @@ add_executable(audiotube
playlistutils.cpp
errorhandler.cpp
playerutils.cpp
abstractytmusicmodel.cpp
multiiterableview.h
resources.qrc
)
+27
View File
@@ -0,0 +1,27 @@
// 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 "abstractytmusicmodel.h"
#include "asyncytmusic.h"
AbstractYTMusicModel::AbstractYTMusicModel(QObject *parent)
: QAbstractListModel(parent)
{
}
bool AbstractYTMusicModel::loading() const
{
return m_loading;
}
void AbstractYTMusicModel::setLoading(bool loading)
{
if (m_loading == loading)
return;
m_loading = loading;
Q_EMIT loadingChanged();
}
+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
#pragma once
#include <QAbstractListModel>
///
/// Base class for all models that work with data from the AsyncYTMusic class.
/// It provides a loading property, that is automatically set to false if a query fails.
///
class AbstractYTMusicModel : public QAbstractListModel
{
Q_OBJECT
Q_PROPERTY(bool loading READ loading WRITE setLoading NOTIFY loadingChanged)
public:
explicit AbstractYTMusicModel(QObject *parent = nullptr);
bool loading() const;
void setLoading(bool loading);
Q_SIGNAL void loadingChanged();
private:
bool m_loading = false;
};
+3 -20
View File
@@ -7,7 +7,7 @@
#include <QDebug>
AlbumModel::AlbumModel(QObject *parent)
: QAbstractListModel(parent)
: AbstractYTMusicModel(parent)
{
connect(this, &AlbumModel::browseIdChanged, this, [=] {
setLoading(true);
@@ -43,12 +43,7 @@ QVariant AlbumModel::data(const QModelIndex &index, int role) const
case VideoId:
return QString::fromStdString(m_album.tracks[index.row()].video_id.value_or(std::string()));
case Artists:
return QVariant::fromValue(std::vector<meta::Artist> {
{
m_album.tracks[index.row()].artists,
std::nullopt
}
});
return QVariant::fromValue(m_album.tracks[index.row()].artists);
}
Q_UNREACHABLE();
@@ -81,18 +76,6 @@ QString AlbumModel::title() const
return QString::fromStdString(m_album.title);
}
bool AlbumModel::loading() const
{
return m_loading;
}
void AlbumModel::setLoading(bool loading)
{
m_loading = loading;
Q_EMIT loadingChanged();
}
QUrl AlbumModel::thumbnailUrl() const
{
if (m_album.thumbnails.empty()) {
@@ -104,5 +87,5 @@ QUrl AlbumModel::thumbnailUrl() const
QString AlbumModel::playlistId() const
{
return QString::fromStdString(m_album.playlist_id);
return QString::fromStdString(m_album.audio_playlist_id);
}
+2 -7
View File
@@ -8,15 +8,15 @@
#include <QUrl>
#include "asyncytmusic.h"
#include "abstractytmusicmodel.h"
class AlbumModel : public QAbstractListModel
class AlbumModel : public AbstractYTMusicModel
{
Q_OBJECT
Q_PROPERTY(QString browseId READ browseId WRITE setBrowseId NOTIFY browseIdChanged REQUIRED)
Q_PROPERTY(QString title READ title NOTIFY titleChanged)
Q_PROPERTY(QUrl thumbnailUrl READ thumbnailUrl NOTIFY thumbnailUrlChanged)
Q_PROPERTY(bool loading READ loading WRITE setLoading NOTIFY loadingChanged)
Q_PROPERTY(QString playlistId READ playlistId NOTIFY playlistIdChanged)
public:
@@ -39,10 +39,6 @@ public:
QString title() const;
Q_SIGNAL void titleChanged();
bool loading() const;
void setLoading(bool loading);
Q_SIGNAL void loadingChanged();
QUrl thumbnailUrl() const;
Q_SIGNAL void thumbnailUrlChanged();
@@ -51,7 +47,6 @@ public:
private:
QString m_browseId;
bool m_loading = false;
album::Album m_album;
};
+1 -12
View File
@@ -7,7 +7,7 @@
#include <asyncytmusic.h>
ArtistModel::ArtistModel(QObject *parent)
: QAbstractListModel(parent)
: AbstractYTMusicModel(parent)
{
connect(this, &ArtistModel::channelIdChanged, this, [=] {
if (m_channelId.isEmpty()) {
@@ -151,17 +151,6 @@ QUrl ArtistModel::thumbnailUrl() const
return QUrl(QString::fromStdString(m_artist.thumbnails.back().url));
}
bool ArtistModel::loading() const
{
return m_loading;
}
void ArtistModel::setLoading(bool loading)
{
m_loading = loading;
Q_EMIT loadingChanged();
}
void ArtistModel::triggerItem(int row)
{
if (m_view) {
+5 -8
View File
@@ -10,9 +10,12 @@
#include <optional>
#include <ytmusic.h>
#include "multiiterableview.h"
class ArtistModel : public QAbstractListModel
#include "multiiterableview.h"
#include "abstractytmusicmodel.h"
class ArtistModel : public AbstractYTMusicModel
{
Q_OBJECT
@@ -20,7 +23,6 @@ class ArtistModel : public QAbstractListModel
Q_PROPERTY(QString title READ title NOTIFY titleChanged)
Q_PROPERTY(QUrl thumbnailUrl READ thumbnailUrl NOTIFY thumbnailUrlChanged)
Q_PROPERTY(bool loading READ loading WRITE setLoading NOTIFY loadingChanged)
public:
enum Type {
@@ -54,10 +56,6 @@ public:
QUrl thumbnailUrl() const;
Q_SIGNAL void thumbnailUrlChanged();
bool loading() const;
void setLoading(bool loading);
Q_SIGNAL void loadingChanged();
Q_INVOKABLE void triggerItem(int row);
Q_SIGNAL void openAlbum(const QString &browseId);
@@ -66,7 +64,6 @@ public:
private:
QString m_channelId;
bool m_loading = false;
artist::Artist m_artist;
std::optional<MultiIterableView<
+38 -86
View File
@@ -16,7 +16,11 @@ namespace py = pybind11;
template <typename R, typename T, typename OP>
std::optional<R> map_optional(const std::optional<T> &optional, OP op) {
if (optional.has_value()) {
return op(optional.value());
if constexpr (std::is_member_function_pointer<OP>::value) {
return (&optional.value()->*op)();
} else {
return op(optional.value());
}
}
return std::nullopt;
@@ -37,15 +41,6 @@ AsyncYTMusic::AsyncYTMusic(QObject *parent)
qRegisterMetaType<std::vector<meta::Artist>>();
qRegisterMetaType<meta::Artist>();
connect(this, &AsyncYTMusic::startSearch, this, &AsyncYTMusic::internalSearch);
connect(this, &AsyncYTMusic::startFetchArtist, this, &AsyncYTMusic::internalFetchArtist);
connect(this, &AsyncYTMusic::startFetchAlbum, this, &AsyncYTMusic::internalFetchAlbum);
connect(this, &AsyncYTMusic::startFetchSong, this, &AsyncYTMusic::internalFetchSong);
connect(this, &AsyncYTMusic::startFetchPlaylist, this, &AsyncYTMusic::internalFetchPlaylist);
connect(this, &AsyncYTMusic::startFetchArtistAlbums, this, &AsyncYTMusic::internalFetchArtistAlbums);
connect(this, &AsyncYTMusic::startExtractVideoInfo, this, &AsyncYTMusic::internalExtractVideoInfo);
connect(this, &AsyncYTMusic::startFetchWatchPlaylist, this, &AsyncYTMusic::internalFetchWatchPlaylist);
connect(this, &AsyncYTMusic::errorOccurred, this, [](const QString &err) {
std::cerr << qPrintable(err);
});
@@ -56,16 +51,9 @@ AsyncYTMusic::AsyncYTMusic(QObject *parent)
//
void AsyncYTMusic::search(const QString &query)
{
Q_EMIT startSearch(query);
}
void AsyncYTMusic::internalSearch(const QString &query)
{
try {
invokeAndCatchOnThread([=]() {
Q_EMIT searchFinished(m_ytm->search(query.toStdString()));
} catch (const py::error_already_set &err) {
Q_EMIT errorOccurred(QString::fromLocal8Bit(err.what()));
}
});
}
//
@@ -73,16 +61,9 @@ void AsyncYTMusic::internalSearch(const QString &query)
//
void AsyncYTMusic::fetchArtist(const QString &channelId)
{
Q_EMIT startFetchArtist(channelId);
}
void AsyncYTMusic::internalFetchArtist(const QString &channelId)
{
try {
invokeAndCatchOnThread([=]() {
Q_EMIT fetchArtistFinished(m_ytm->get_artist(channelId.toStdString()));
} catch (const py::error_already_set &err) {
Q_EMIT errorOccurred(QString::fromLocal8Bit(err.what()));
}
});
}
//
@@ -90,16 +71,9 @@ void AsyncYTMusic::internalFetchArtist(const QString &channelId)
//
void AsyncYTMusic::fetchAlbum(const QString &browseId)
{
Q_EMIT startFetchAlbum(browseId);
}
void AsyncYTMusic::internalFetchAlbum(const QString &browseId)
{
try {
invokeAndCatchOnThread([=]() {
Q_EMIT fetchAlbumFinished(m_ytm->get_album(browseId.toStdString()));
} catch (const py::error_already_set &err) {
Q_EMIT errorOccurred(QString::fromLocal8Bit(err.what()));
}
});
}
//
@@ -107,32 +81,21 @@ void AsyncYTMusic::internalFetchAlbum(const QString &browseId)
//
void AsyncYTMusic::fetchSong(const QString &videoId)
{
Q_EMIT startFetchSong(videoId);
}
void AsyncYTMusic::internalFetchSong(const QString &videoId)
{
try {
Q_EMIT fetchSongFinished(m_ytm->get_song(videoId.toStdString()));
} catch (const py::error_already_set &err) {
Q_EMIT errorOccurred(QString::fromLocal8Bit(err.what()));
}
invokeAndCatchOnThread([=]() {
auto maybeSong = m_ytm->get_song(videoId.toStdString());
if (maybeSong.has_value()) {
Q_EMIT fetchSongFinished(*maybeSong);
}
});
}
//
// fetchPlaylist
//
void AsyncYTMusic::fetchPlaylist(const QString &playlistId) {
Q_EMIT startFetchPlaylist(playlistId);
}
void AsyncYTMusic::internalFetchPlaylist(const QString &playlistId)
{
try {
invokeAndCatchOnThread([=]() {
Q_EMIT fetchPlaylistFinished(m_ytm->get_playlist(playlistId.toStdString()));
} catch (const py::error_already_set &err) {
Q_EMIT errorOccurred(QString::fromLocal8Bit(err.what()));
}
});
}
//
@@ -140,16 +103,9 @@ void AsyncYTMusic::internalFetchPlaylist(const QString &playlistId)
//
void AsyncYTMusic::fetchArtistAlbums(const QString &channelId, const QString &params)
{
Q_EMIT startFetchArtistAlbums(channelId, params);
}
void AsyncYTMusic::internalFetchArtistAlbums(const QString &channelid, const QString &params)
{
try {
Q_EMIT fetchArtistAlbumsFinished(m_ytm->get_artist_albums(channelid.toStdString(), params.toStdString()));
} catch (const py::error_already_set &err) {
Q_EMIT errorOccurred(QString::fromLocal8Bit(err.what()));
}
invokeAndCatchOnThread([=]() {
Q_EMIT fetchArtistAlbumsFinished(m_ytm->get_artist_albums(channelId.toStdString(), params.toStdString()));
});
}
//
@@ -157,16 +113,9 @@ void AsyncYTMusic::internalFetchArtistAlbums(const QString &channelid, const QSt
//
void AsyncYTMusic::extractVideoInfo(const QString &videoId)
{
Q_EMIT startExtractVideoInfo(videoId);
}
void AsyncYTMusic::internalExtractVideoInfo(const QString &videoId)
{
try {
invokeAndCatchOnThread([=]() {
Q_EMIT extractVideoInfoFinished(m_ytm->extract_video_info(videoId.toStdString()));
} catch (const py::error_already_set &err) {
Q_EMIT errorOccurred(QString::fromLocal8Bit(err.what()));
}
});
}
//
@@ -174,19 +123,22 @@ void AsyncYTMusic::internalExtractVideoInfo(const QString &videoId)
//
void AsyncYTMusic::fetchWatchPlaylist(const std::optional<QString> &videoId, const std::optional<QString> &playlistId)
{
Q_EMIT startFetchWatchPlaylist(videoId, playlistId);
invokeAndCatchOnThread([=]() {
Q_EMIT fetchWatchPlaylistFinished(m_ytm->get_watch_playlist(
map_optional<std::string>(videoId, &QString::toStdString),
map_optional<std::string>(playlistId, &QString::toStdString)
));
});
}
void AsyncYTMusic::internalFetchWatchPlaylist(const std::optional<QString> &videoId, const std::optional<QString> &playlistId)
{
try {
Q_EMIT fetchWatchPlaylistFinished(m_ytm->get_watch_playlist(
map_optional<std::string>(videoId, [](const QString &value) { return value.toStdString(); }),
map_optional<std::string>(playlistId, [](const QString &value) { return value.toStdString(); })
));
} catch (const py::error_already_set &err) {
Q_EMIT errorOccurred(QString::fromLocal8Bit(err.what()));
}
void AsyncYTMusic::invokeAndCatchOnThread(const std::function<void()> &fun) {
QMetaObject::invokeMethod(this, [=]() {
try {
fun();
} catch (const py::error_already_set &err) {
Q_EMIT errorOccurred(QString::fromLocal8Bit(err.what()));
}
});
}
YTMusicThread &YTMusicThread::instance()
+2 -23
View File
@@ -84,29 +84,8 @@ protected:
explicit AsyncYTMusic(QObject *parent = nullptr);
private:
Q_SIGNAL void startSearch(const QString &query);
Q_SLOT void internalSearch(const QString &query);
Q_SIGNAL void startFetchArtist(const QString &channelId);
Q_SLOT void internalFetchArtist(const QString &channelId);
Q_SIGNAL void startFetchAlbum(const QString &browseId);
Q_SLOT void internalFetchAlbum(const QString &browseId);
Q_SIGNAL void startFetchSong(const QString &videoId);
Q_SLOT void internalFetchSong(const QString &videoId);
Q_SIGNAL void startFetchPlaylist(const QString &playlistId);
Q_SLOT void internalFetchPlaylist(const QString &playlistId);
Q_SIGNAL void startFetchArtistAlbums(const QString &channelid, const QString &params);
Q_SLOT void internalFetchArtistAlbums(const QString &channelid, const QString &params);
Q_SIGNAL void startExtractVideoInfo(const QString &videoId);
Q_SLOT void internalExtractVideoInfo(const QString &videoId);
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);
/// Invokes the given function on the thread of the YTMusic object, and handles exceptions that occur while invoking it.
void invokeAndCatchOnThread(const std::function<void()> &fun);
// Python interpreter will be initialized from the thread calling the methods
Lazy<YTMusic> m_ytm;
+13 -1
View File
@@ -36,7 +36,15 @@ Kirigami.ScrollablePage {
}
onOpenVideo: (videoId, title) => {
askPlayVideoAudio(videoId, title)
videoPlayMessage.text = i18n("Video playback is not supported yet. Do you want to play only the audio of \"%1\"?", title)
videoPlayMessage.visible = true
videoPlayMessage.okAction = function() {
play(videoId)
videoPlayMessage.visible = false
}
videoPlayMessage.cancelAction = function() {
videoPlayMessage.visible = false
}
}
}
section.property: "type"
@@ -110,4 +118,8 @@ Kirigami.ScrollablePage {
visible: artistModel.loading
}
}
footer: ConfirmationMessage {
id: videoPlayMessage
}
}
+26
View File
@@ -0,0 +1,26 @@
// SPDX-FileCopyrightText: 2021 Dimitris Kardarakos <[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
Kirigami.InlineMessage {
property var okAction
property var cancelAction
visible: false
actions: [
Kirigami.Action {
text: i18n("OK")
onTriggered: okAction()
},
Kirigami.Action {
text: i18n("Cancel")
onTriggered: cancelAction()
}
]
}
+208 -198
View File
@@ -9,243 +9,253 @@ import org.kde.kirigami 2.12 as Kirigami
import org.kde.ytmusic 1.0
import QtMultimedia 5.12
ColumnLayout {
id: footerLayout
Item {
id: footerItem
property bool maximized: false
anchors.left: parent.left
anchors.right: parent.right
height: maximized ? applicationWindow().height : player.preferredHeight
height: maximized ? applicationWindow().height : 75
GridLayout {
id: playerLayout
Rectangle {
color: Kirigami.Theme.backgroundColor
Kirigami.Theme.colorSet: Kirigami.Theme.Window
anchors.fill: footerLayout
}
readonly property bool mobile: width > height
ColumnLayout {
id: footerLayout
height: parent.height
anchors.fill: parent
Layout.fillHeight: footerLayout.maximized
Layout.fillWidth: true
flow: width > height ? GridLayout.LeftToRight : GridLayout.TopToBottom
visible: footerLayout.maximized
GridLayout {
id: playerLayout
Item {
Layout.fillWidth: info.thumbnail
Layout.fillHeight: info.thumbnail
Image {
anchors.fill: parent
readonly property bool mobile: width > height
source: info.thumbnail
fillMode: Image.PreserveAspectFit
}
}
Item {
Layout.fillHeight: footerItem.maximized
Layout.fillWidth: true
Layout.fillHeight: true
flow: width > height ? GridLayout.LeftToRight : GridLayout.TopToBottom
visible: footerItem.maximized
Controls.ScrollView {
anchors.fill: parent
ListView {
Item {
Layout.fillWidth: info.thumbnail
Layout.fillHeight: info.thumbnail
Image {
anchors.fill: parent
id: playlistView
clip: true
Controls.BusyIndicator {
anchors.centerIn: parent
visible: UserPlaylistModel.loading || UserPlaylistModel.loading
}
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()
}
}
}
source: info.thumbnail
fillMode: Image.PreserveAspectFit
}
}
}
}
Kirigami.Separator {
Layout.fillWidth: true
}
RowLayout {
id: player
Layout.fillWidth: true
Layout.fillHeight: !footer.maximized
VideoInfoExtractor {
id: info
onSongChanged: audio.play()
videoId: UserPlaylistModel.currentVideoId
}
Audio {
id: audio
source: info.audioUrl
onStatusChanged: {
if (status === Audio.EndOfMedia) {
console.log("Song ended");
UserPlaylistModel.next();
}
}
}
Controls.ToolButton {
display: Controls.AbstractButton.IconOnly
Layout.preferredWidth: parent.height
Layout.fillHeight: true
enabled: info.audioUrl != ""
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()
}
Controls.ToolButton {
display: Controls.AbstractButton.IconOnly
Layout.preferredWidth: parent.height
Layout.fillHeight: true
enabled: UserPlaylistModel.canSkip
visible: !info.loading
icon.name: "media-skip-forward"
onClicked: UserPlaylistModel.next()
}
Controls.BusyIndicator {
Layout.fillHeight: true
visible: info.loading
}
ColumnLayout {
Layout.fillHeight: true
Layout.topMargin: Kirigami.Units.smallSpacing
Layout.bottomMargin: Kirigami.Units.smallSpacing
Kirigami.Heading {
level: 3
Item {
Layout.fillWidth: true
elide: Qt.ElideRight
text: info.title ? info.title : i18n("No media playing")
Layout.fillHeight: true
Controls.ScrollView {
anchors.fill: parent
ListView {
anchors.fill: parent
id: playlistView
clip: true
Controls.BusyIndicator {
anchors.centerIn: parent
visible: UserPlaylistModel.loading || UserPlaylistModel.loading
}
onCountChanged: {
if (count < 1) {
footerItem.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()
}
}
}
}
}
}
}
Kirigami.Separator {
Layout.fillWidth: true
}
RowLayout {
id: player
Layout.fillWidth: true
Layout.fillHeight: !footer.maximized
VideoInfoExtractor {
id: info
onSongChanged: audio.play()
videoId: UserPlaylistModel.currentVideoId
}
RowLayout{
Audio {
id: audio
Controls.Label{
visible: info.title
text: PlayerUtils.formatTimestamp(audio.position)
source: info.audioUrl
onStatusChanged: {
if (status === Audio.EndOfMedia) {
console.log("Song ended");
UserPlaylistModel.next();
}
}
}
Controls.ToolButton {
display: Controls.AbstractButton.IconOnly
Layout.preferredWidth: parent.height
Layout.fillHeight: true
enabled: info.audioUrl != ""
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()
}
Controls.ToolButton {
display: Controls.AbstractButton.IconOnly
Layout.preferredWidth: parent.height
Layout.fillHeight: true
enabled: UserPlaylistModel.canSkip
visible: !info.loading
icon.name: "media-skip-forward"
onClicked: UserPlaylistModel.next()
}
Controls.BusyIndicator {
Layout.fillHeight: true
visible: info.loading
}
ColumnLayout {
Layout.fillHeight: true
Layout.topMargin: Kirigami.Units.smallSpacing
Layout.bottomMargin: Kirigami.Units.smallSpacing
Kirigami.Heading {
level: 3
Layout.fillWidth: true
elide: Qt.ElideRight
text: info.title ? info.title : i18n("No media playing")
}
Controls.Slider {
Layout.fillWidth: true
from: 0
to: audio.duration
value: audio.position
enabled: audio.seekable
onMoved: {
console.log("Value:", value);
audio.seek(Math.floor(value));
RowLayout{
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 {
duration: 1000
}
}
}
Controls.Label{
visible: info.title
text: PlayerUtils.formatTimestamp(audio.duration)
}
}
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: footerItem.maximized ? "arrow-down" : "arrow-up"
onClicked: footerItem.maximized = !footerItem.maximized
}
}
Controls.ToolButton {
display: Controls.AbstractButton.IconOnly
Layout.preferredWidth: parent.height
text: i18n("Expand")
enabled: playlistView.count > 0
Layout.fillHeight: true
icon.name: footerLayout.maximized ? "arrow-down" : "arrow-up"
onClicked: footerLayout.maximized = !footerLayout.maximized
}
}
Behavior on height {
NumberAnimation {
}
}
}
+37 -4
View File
@@ -17,6 +17,27 @@ Kirigami.ScrollablePage {
ListView {
reuseItems: true
section.delegate: Kirigami.ListSectionHeader {
required property string section
text: {
switch (parseInt(section)) {
case SearchModel.Album:
return i18n("Albums")
case SearchModel.Artist:
return i18n("Artists")
case SearchModel.Playlist:
return i18n("Playlists")
case SearchModel.Song:
return i18n("Songs")
case SearchModel.Video:
return i18n("Videos")
}
return i18n("Unknown")
}
}
section.property: "type"
model: SearchModel {
id: searchModel
@@ -43,7 +64,15 @@ Kirigami.ScrollablePage {
}
onOpenVideo: (videoId, title) => {
askPlayVideoAudio(videoId, title)
videoPlayMessage.text = i18n("Video playback is not supported yet. Do you want to play only the audio of \"%1\"?", title)
videoPlayMessage.visible = true
videoPlayMessage.okAction = function() {
play(videoId)
videoPlayMessage.visible = false
}
videoPlayMessage.cancelAction = function() {
videoPlayMessage.visible = false
}
}
}
delegate: Kirigami.SwipeListItem {
@@ -86,13 +115,13 @@ Kirigami.ScrollablePage {
Kirigami.Action {
icon.name: "go-next"
text: i18n("Play next")
visible: delegateItem.type === SearchModel.Song
visible: delegateItem.type === SearchModel.Song || delegateItem.type == SearchModel.Video
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
visible: delegateItem.type === SearchModel.Song || delegateItem.type == SearchModel.Video
onTriggered: UserPlaylistModel.append(delegateItem.videoId, delegateItem.title, delegateItem.artists)
},
Kirigami.Action {
@@ -118,9 +147,13 @@ Kirigami.ScrollablePage {
text: i18n("Find music on YouTube Music")
helpfulAction: Kirigami.Action {
onTriggered: searchField.forceActiveFocus()
text: "Search"
text: i18n("Search")
icon.name: "search"
}
}
}
footer: ConfirmationMessage {
id: videoPlayMessage
}
}
+1 -8
View File
@@ -15,6 +15,7 @@ Kirigami.ApplicationWindow {
property alias searchField: searchField
header: Controls.Control {
visible: !footer.maximized
padding: Kirigami.Units.largeSpacing
background: Rectangle {
@@ -70,14 +71,6 @@ Kirigami.ApplicationWindow {
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
+1 -1
View File
@@ -8,7 +8,7 @@
int main() {
const auto ytm = YTMusic();
const auto results = ytm.search("Thomas Bangalter");
const auto results = ytm.search("Another one bites the dust");
std::cout << "Found " << results.size() << " results." << std::endl;
+1 -12
View File
@@ -11,7 +11,7 @@
#include "playlistutils.h"
PlaylistModel::PlaylistModel(QObject *parent)
: QAbstractListModel(parent)
: AbstractYTMusicModel(parent)
{
connect(this, &PlaylistModel::playlistIdChanged, this, [=] {
setLoading(true);
@@ -76,17 +76,6 @@ void PlaylistModel::setPlaylistId(const QString &playlistId)
Q_EMIT playlistIdChanged();
}
bool PlaylistModel::loading() const
{
return m_loading;
}
void PlaylistModel::setLoading(bool loading)
{
m_loading = loading;
Q_EMIT loadingChanged();
}
QUrl PlaylistModel::thumbnailUrl() const
{
if (m_playlist.thumbnails.empty()) {
+3 -7
View File
@@ -7,7 +7,9 @@
#include <QAbstractListModel>
#include <ytmusic.h>
class PlaylistModel : public QAbstractListModel
#include "abstractytmusicmodel.h"
class PlaylistModel : public AbstractYTMusicModel
{
Q_OBJECT
@@ -15,7 +17,6 @@ class PlaylistModel : public QAbstractListModel
Q_PROPERTY(QString playlistId READ playlistId WRITE setPlaylistId NOTIFY playlistIdChanged REQUIRED)
// output
Q_PROPERTY(bool loading READ loading WRITE setLoading NOTIFY loadingChanged)
Q_PROPERTY(QUrl thumbnailUrl READ thumbnailUrl NOTIFY thumbnailUrlChanged)
Q_PROPERTY(QString title READ title NOTIFY titleChanged)
@@ -36,10 +37,6 @@ public:
void setPlaylistId(const QString &playlistId);
Q_SIGNAL void playlistIdChanged();
bool loading() const;
void setLoading(bool loading);
Q_SIGNAL void loadingChanged();
QUrl thumbnailUrl() const;
Q_SIGNAL void thumbnailUrlChanged();
@@ -48,7 +45,6 @@ public:
private:
QString m_playlistId;
bool m_loading = false;
playlist::Playlist m_playlist {};
};
+1
View File
@@ -12,5 +12,6 @@ SPDX-License-Identifier: GPL-2.0-only OR GPL-3.0-only OR LicenseRef-KDE-Accepted
<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>
<file alias="ConfirmationMessage.qml">contents/ui/ConfirmationMessage.qml</file>
</qresource>
</RCC>
+1 -12
View File
@@ -5,7 +5,7 @@
#include "searchmodel.h"
SearchModel::SearchModel(QObject *parent)
: QAbstractListModel(parent)
: AbstractYTMusicModel(parent)
{
connect(this, &SearchModel::searchQueryChanged, this, [=] {
if (m_searchQuery.isEmpty()) {
@@ -146,17 +146,6 @@ void SearchModel::setSearchQuery(const QString &searchQuery)
Q_EMIT searchQueryChanged();
}
bool SearchModel::loading() const
{
return m_loading;
}
void SearchModel::setLoading(bool loading)
{
m_loading = loading;
Q_EMIT loadingChanged();
}
void SearchModel::triggerItem(int row)
{
std::visit([&](auto&& arg) {
+2 -7
View File
@@ -8,13 +8,13 @@
#include <QThread>
#include "asyncytmusic.h"
#include "abstractytmusicmodel.h"
class SearchModel : public QAbstractListModel
class SearchModel : public AbstractYTMusicModel
{
Q_OBJECT
Q_PROPERTY(QString searchQuery READ searchQuery WRITE setSearchQuery NOTIFY searchQueryChanged)
Q_PROPERTY(bool loading READ loading WRITE setLoading NOTIFY loadingChanged)
public:
enum Type {
@@ -44,10 +44,6 @@ public:
void setSearchQuery(const QString &searchQuery);
Q_SIGNAL void searchQueryChanged();
bool loading() const;
void setLoading(bool loading);
Q_SIGNAL void loadingChanged();
Q_INVOKABLE void triggerItem(int row);
Q_SIGNAL void openAlbum(const QString &browseId);
@@ -59,5 +55,4 @@ public:
private:
QString m_searchQuery;
std::vector<search::SearchResultItem> m_searchResults;
bool m_loading = false;
};
+1 -12
View File
@@ -13,7 +13,7 @@
#include "playlistutils.h"
UserPlaylistModel::UserPlaylistModel(QObject *parent)
: QAbstractListModel(parent)
: AbstractYTMusicModel(parent)
{
connect(this, &UserPlaylistModel::initialVideoIdChanged, this, [=] {
if (m_initialVideoId.isEmpty()) {
@@ -98,17 +98,6 @@ void UserPlaylistModel::setInitialVideoId(const QString &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(),
+3 -7
View File
@@ -7,7 +7,9 @@
#include <ytmusic.h>
class UserPlaylistModel : public QAbstractListModel
#include "abstractytmusicmodel.h"
class UserPlaylistModel : public AbstractYTMusicModel
{
Q_OBJECT
@@ -17,7 +19,6 @@ class UserPlaylistModel : public QAbstractListModel
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)
@@ -39,10 +40,6 @@ public:
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;
@@ -74,7 +71,6 @@ private:
QString m_initialVideoId;
QString m_playlistId;
QString m_currentVideoId;
bool m_loading = false;
bool m_shuffle = false;
watch::Playlist m_playlist;
+1 -1
View File
@@ -81,7 +81,7 @@ QString VideoInfoExtractor::title() const
QString VideoInfoExtractor::thumbnail() const
{
return QString::fromStdString(m_videoInfo.thumnnail);
return QString::fromStdString(m_videoInfo.thumbnail);
}
bool VideoInfoExtractor::loading() const
+51 -43
View File
@@ -13,9 +13,15 @@ namespace py = pybind11;
using namespace py::literals;
/// Useful for debugging
void pyPrintPretty(py::handle obj) {
auto json = py::module::import("json");
py::print(json.attr("dumps")(obj, "indent"_a=py::int_(4)));
}
#define UNEXPORT __attribute__ ((visibility("hidden")))
constexpr auto TESTED_YTMUSICAPI_VERSION = "0.17.3";
constexpr auto TESTED_YTMUSICAPI_VERSION = "0.19.4";
struct UNEXPORT YTMusicPrivate {
py::scoped_interpreter guard {};
@@ -47,7 +53,7 @@ struct UNEXPORT YTMusicPrivate {
py::object get_ytdl() {
// lazy initialization
if (ytdl.is_none()) {
ytdl = py::module::import("youtube_dl").attr("YoutubeDL")(py::dict());
ytdl = py::module::import("yt_dlp").attr("YoutubeDL")(py::dict());
}
return ytdl;
@@ -64,7 +70,7 @@ std::optional<T> optional_key(py::handle obj, const char *name) {
return std::nullopt;
}
return obj[name].cast<T>();
return obj[name].cast<std::optional<T>>();
}
meta::Thumbnail extract_thumbnail(py::handle thumbnail) {
@@ -82,28 +88,10 @@ meta::Artist extract_meta_artist(py::handle artist) {
};
};
album::Track extract_album_track(py::handle track) {
return {
track["index"].cast<std::string>(),
track["title"].cast<std::string>(),
track["artists"].cast<std::string>(),
track["videoId"].cast<std::optional<std::string>>(), // E rated songs don't have a videoId
track["lengthMs"].cast<std::optional<std::string>>(), //
track["likeStatus"].cast<std::optional<std::string>>()
};
}
video_info::Format extract_format(py::handle format) {
return {
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(py::handle track);
watch::Playlist::Track extract_watch_track(py::handle track);
album::Track extract_album_track(py::handle track);
video_info::Format extract_format(py::handle format);
template <typename T>
inline auto extract_py_list(py::handle obj) {
@@ -135,6 +123,27 @@ inline auto extract_py_list(py::handle obj) {
return output;
}
album::Track extract_album_track(py::handle track) {
return {
track["isExplicit"].cast<bool>(),
track["title"].cast<std::string>(),
extract_py_list<meta::Artist>(track["artists"]),
track["album"].cast<std::optional<std::string>>(),
track["videoId"].cast<std::optional<std::string>>(), // E rated songs don't have a videoId
track["duration"].cast<std::optional<std::string>>(), //
track["likeStatus"].cast<std::optional<std::string>>()
};
}
video_info::Format extract_format(py::handle format) {
return {
optional_key<int>(format, "quality"),
format["url"].cast<std::string>(),
format["vcodec"].cast<std::string>(),
format["acodec"].cast<std::string>()
};
}
meta::Album extract_meta_album(py::handle album) {
return meta::Album {
album["name"].cast<std::string>(),
@@ -280,7 +289,7 @@ std::optional<search::SearchResultItem> extract_search_result(py::handle result)
result["title"].cast<std::string>(),
result["type"].cast<std::string>(),
extract_py_list<meta::Artist>(result["artists"]),
result["year"].cast<std::string>(),
result["year"].cast<std::optional<std::string>>(),
result["isExplicit"].cast<bool>()
};
} else if (resultType == "playlist") {
@@ -299,7 +308,8 @@ std::optional<search::SearchResultItem> extract_search_result(py::handle result)
};
} else {
std::cerr << "Warning: Unsupported search result type found" << std::endl;
std::cerr << "It's called: " << resultType;
std::cerr << "It's called: " << resultType << std::endl;
pyPrintPretty(result);
return std::nullopt;
}
}
@@ -324,10 +334,11 @@ YTMusic::~YTMusic() = default;
std::vector<search::SearchResultItem> YTMusic::search(
const std::string &query,
const std::optional<std::string> &filter,
const std::optional<std::string> &scope,
const int limit,
const bool ignore_spelling) const
{
const auto results = d->get_ytmusic().attr("search")(query, filter, limit, ignore_spelling).cast<py::list>();
const auto results = d->get_ytmusic().attr("search")("query"_a=query, "filter"_a=filter, "scope"_a=scope, "limit"_a = limit, "ignore_spelling"_a = ignore_spelling).cast<py::list>();
std::vector<search::SearchResultItem> output;
for (const auto &result : results) {
@@ -343,7 +354,7 @@ artist::Artist YTMusic::get_artist(const std::string &channel_id) const
{
const auto artist = d->get_ytmusic().attr("get_artist")(channel_id);
return artist::Artist {
artist["description"].cast<std::optional<std::string>>(),
optional_key<std::string>(artist, "description"),
artist["views"].cast<std::optional<std::string>>(),
artist["name"].cast<std::string>(),
artist["channelId"].cast<std::string>(),
@@ -360,31 +371,28 @@ 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->get_ytmusic().attr("get_album")(browseId);
return {
album["title"].cast<std::string>(),
album["trackCount"].cast<std::string>(),
album["durationMs"].cast<std::string>(),
album["playlistId"].cast<std::string>(),
[&]() -> album::Album::ReleaseDate {
const auto date = album["releaseDate"];
return {
date["year"].cast<int>(),
date["month"].cast<int>(),
date["day"].cast<int>()
};
}(),
album["description"].cast<std::string>(),
album["trackCount"].cast<int>(),
album["duration"].cast<std::string>(),
album["audioPlaylistId"].cast<std::string>(),
album["year"].cast<std::string>(),
optional_key<std::string>(album, "description"),
extract_py_list<meta::Thumbnail>(album["thumbnails"]),
extract_py_list<album::Track>(album["tracks"])
extract_py_list<album::Track>(album["tracks"]),
extract_py_list<meta::Artist>(album["artists"])
};
}
song::Song YTMusic::get_song(const std::string &video_id) const
std::optional<song::Song> YTMusic::get_song(const std::string &video_id) const
{
const auto song = d->get_ytmusic().attr("get_song")(video_id);
return {
if (!song.cast<py::dict>().contains("videoId")) {
return std::nullopt;
}
return song::Song {
song["videoId"].cast<std::string>(),
song["title"].cast<std::string>(),
song["lengthSeconds"].cast<std::string>(),
+15 -12
View File
@@ -67,7 +67,7 @@ struct Album {
std::string title;
std::string type;
std::vector<meta::Artist> artists;
std::string year;
std::optional<std::string> year;
bool is_explicit;
};
@@ -122,7 +122,7 @@ struct Artist {
struct Single {
std::string title;
std::vector<meta::Thumbnail> thumnnails;
std::vector<meta::Thumbnail> thumbnails;
std::string year;
std::string browse_id;
};
@@ -143,11 +143,12 @@ struct Artist {
namespace album {
struct Track {
std::string index;
bool is_explicit;
std::string title;
std::string artists;
std::vector<meta::Artist> artists;
std::optional<std::string> album;
std::optional<std::string> video_id;
std::optional<std::string> length_ms;
std::optional<std::string> duration;
std::optional<std::string> like_status;
};
@@ -159,13 +160,14 @@ namespace album {
};
std::string title;
std::string track_count;
std::string duration_ms;
std::string playlist_id;
ReleaseDate release_date;
std::string description;
int track_count;
std::string duration;
std::string audio_playlist_id;
std::string year;
std::optional<std::string> description;
std::vector<meta::Thumbnail> thumbnails;
std::vector<Track> tracks;
std::vector<meta::Artist> artists;
};
}
@@ -240,7 +242,7 @@ struct VideoInfo {
std::string id;
std::string title;
std::vector<Format> formats;
std::string thumnnail;
std::string thumbnail;
// More, but not interesting for us right now
};
@@ -277,6 +279,7 @@ public:
std::vector<search::SearchResultItem> search(const std::string &query,
const std::optional<std::string> &filter = std::nullopt,
const std::optional<std::string> &scope = std::nullopt,
const int limit = 20,
const bool ignore_spelling = false) const;
@@ -287,7 +290,7 @@ public:
album::Album get_album(const std::string &browse_id) const;
/// https://ytmusicapi.readthedocs.io/en/latest/reference.html#ytmusicapi.YTMusic.get_song
song::Song get_song(const std::string &video_id) const;
std::optional<song::Song> get_song(const std::string &video_id) const;
/// https://ytmusicapi.readthedocs.io/en/latest/reference.html#ytmusicapi.YTMusic.get_playlist
playlist::Playlist get_playlist(const std::string &playlist_id, int limit = 100) const;