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
15 changed files with 167 additions and 58 deletions

No files matched your search

+2 -2
View File
@@ -7,8 +7,8 @@
"sources": [
{
"type": "file",
"url": "https://files.pythonhosted.org/packages/12/67/a37eb6231ff26b4a4bc7cee2568d44e11ffeddb84a9b0798869a4392f3ce/youtube_dl-2021.5.16.tar.gz",
"sha256": "4e569cb0477428fd96ee6f7e7a6640b7c9416be626ed708ac4b8ada6c5a6ffbe"
"url": "https://files.pythonhosted.org/packages/c6/75/05979677d9abc76851d13d8db3951e39017ac223545adab6e8576fa0cbe7/youtube_dl-2021.6.6.tar.gz",
"sha256": "cb2d3ee002158ede783e97a82c95f3817594df54367ea6a77ce5ceea4772f0ab"
}
]
}
+2 -2
View File
@@ -7,8 +7,8 @@
"sources": [
{
"type": "file",
"url": "https://files.pythonhosted.org/packages/94/40/c396b5b212533716949a4d295f91a4c100d51ba95ea9e2d96b6b0517e5a5/urllib3-1.26.5.tar.gz",
"sha256": "a7acd0977125325f516bda9735fa7142b909a8d01e8b2e4c8108d0984e6e0098"
"url": "https://files.pythonhosted.org/packages/4f/5a/597ef5911cb8919efe4d86206aa8b2658616d676a7088f0825ca08bd7cb8/urllib3-1.26.6.tar.gz",
"sha256": "f57b4c16c62fa2760b7e3d97c35b255512fb6b59a259730f36ba32ce9f8e342f"
},
{
"type": "file",
+18
View File
@@ -11,14 +11,19 @@ SPDX-License-Identifier: CC0-1.0
<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>
@@ -28,14 +33,18 @@ SPDX-License-Identifier: CC0-1.0
<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>
@@ -47,14 +56,19 @@ SPDX-License-Identifier: CC0-1.0
<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>
@@ -81,14 +95,18 @@ SPDX-License-Identifier: CC0-1.0
<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>
+8
View File
@@ -4,12 +4,16 @@ 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
@@ -23,12 +27,16 @@ 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
+1 -1
View File
@@ -174,7 +174,7 @@ void ArtistModel::triggerItem(int row)
} 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));
Q_EMIT openVideo(QString::fromStdString(item.video_id), QString::fromStdString(item.title));
} else {
Q_UNREACHABLE();
}
+1 -1
View File
@@ -62,7 +62,7 @@ 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;
+1
View File
@@ -37,6 +37,7 @@ public:
if (!m_item) {
m_item = std::make_unique<T>();
}
Q_ASSERT(m_item);
return m_item;
}
+2 -2
View File
@@ -35,8 +35,8 @@ Kirigami.ScrollablePage {
play(videoId)
}
onOpenVideo: (videoId) => {
askPlayVideoAudio(videoId)
onOpenVideo: (videoId, title) => {
askPlayVideoAudio(videoId, title)
}
}
section.property: "type"
+2 -2
View File
@@ -196,7 +196,7 @@ ColumnLayout {
RowLayout{
Controls.Label{
visible: audio.duration > 0
visible: info.title
text: PlayerUtils.formatTimestamp(audio.position)
}
@@ -220,7 +220,7 @@ ColumnLayout {
}
Controls.Label{
visible: audio.duration > 0
visible: info.title
text: PlayerUtils.formatTimestamp(audio.duration)
}
+24 -13
View File
@@ -10,18 +10,9 @@ import org.kde.kirigami 2.14 as Kirigami
import org.kde.ytmusic 1.0
Kirigami.ScrollablePage {
title: i18n("Youtube Music")
property alias searchQuery: searchModel.searchQuery
header: Controls.Control {
padding: Kirigami.Units.largeSpacing
contentItem: Kirigami.SearchField {
delaySearch: true
selectByMouse: true
onAccepted: {
searchModel.searchQuery = text
}
}
}
title: searchQuery
ListView {
reuseItems: true
@@ -51,8 +42,8 @@ Kirigami.ScrollablePage {
play(videoId)
}
onOpenVideo: (videoId) => {
askPlayVideoAudio(videoId)
onOpenVideo: (videoId, title) => {
askPlayVideoAudio(videoId, title)
}
}
delegate: Kirigami.SwipeListItem {
@@ -62,6 +53,7 @@ Kirigami.ScrollablePage {
required property int type
required property string videoId
required property var artists
required property string radioPlaylistId
RowLayout {
Layout.fillHeight: true
@@ -102,6 +94,12 @@ Kirigami.ScrollablePage {
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)
}
]
@@ -111,5 +109,18 @@ Kirigami.ScrollablePage {
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"
}
}
}
}
+39 -2
View File
@@ -3,6 +3,8 @@
// SPDX-License-Identifier: GPL-2.0-only OR GPL-3.0-only OR LicenseRef-KDE-Accepted-GPL
import QtQuick 2.1
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
@@ -10,6 +12,41 @@ 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
@@ -33,8 +70,8 @@ Kirigami.ApplicationWindow {
UserPlaylistModel.playlistId = playlistId
}
function askPlayVideoAudio(videoId) {
showPassiveNotification(i18n("Video playback is not supported yet."),
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() {
+15 -2
View File
@@ -105,6 +105,18 @@ QVariant SearchModel::data(const QModelIndex &index, int role) const
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();
@@ -118,7 +130,8 @@ QHash<int, QByteArray> SearchModel::roleNames() const
{Title, "title"},
{Type, "type"},
{VideoId, "videoId"},
{Artists, "artists"}
{Artists, "artists"},
{RadioPlaylistId, "radioPlaylistId"},
};
}
@@ -157,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();
}
+3 -2
View File
@@ -30,7 +30,8 @@ public:
Title = Qt::UserRole + 1,
Type,
VideoId,
Artists
Artists,
RadioPlaylistId
};
explicit SearchModel(QObject *parent = nullptr);
@@ -53,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;
-1
View File
@@ -33,7 +33,6 @@ VideoInfoExtractor::VideoInfoExtractor(QObject *parent)
});
}
QUrl VideoInfoExtractor::audioUrl() const
{
if (m_videoInfo.formats.empty()) {
+49 -28
View File
@@ -19,7 +19,42 @@ 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();
};
@@ -277,17 +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);
// 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;
}
d->auth = auth;
d->user = user;
d->requests_session = requests_session;
d->proxies = proxies;
d->language = language;
}
YTMusic::~YTMusic() = default;
@@ -298,7 +327,7 @@ 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>();
const auto results = d->get_ytmusic().attr("search")(query, filter, limit, ignore_spelling).cast<py::list>();
std::vector<search::SearchResultItem> output;
for (const auto &result : results) {
@@ -312,7 +341,7 @@ std::vector<search::SearchResultItem> YTMusic::search(
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>>(),
@@ -330,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>(),
@@ -353,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>(),
@@ -385,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>(),
@@ -402,7 +431,7 @@ 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), [](py::handle album) {
@@ -422,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>(),
@@ -445,7 +466,7 @@ watch::Playlist YTMusic::get_watch_playlist(const std::optional<std::string> &vi
int limit,
const std::optional<std::string> &params) const
{
const auto playlist = d->ytmusic.attr("get_watch_playlist")("videoId"_a = videoId,
const auto playlist = d->get_ytmusic().attr("get_watch_playlist")("videoId"_a = videoId,
"playlistId"_a = playlistId,
"limit"_a = py::int_(limit),
"params"_a = params);