File indexing completed on 2024-05-12 16:21:18

0001 // SPDX-FileCopyrightText: 2021 Jonah BrĂ¼chert <jbb@kaidan.im>
0002 //
0003 // SPDX-License-Identifier: GPL-2.0-only OR GPL-3.0-only OR LicenseRef-KDE-Accepted-GPL
0004 
0005 #pragma once
0006 
0007 #include <QObject>
0008 #include <QUrl>
0009 
0010 #include <ytmusic.h>
0011 
0012 class VideoInfoExtractor : public QObject
0013 {
0014     Q_OBJECT
0015 
0016     Q_PROPERTY(QString videoId READ videoId WRITE setVideoId NOTIFY videoIdChanged)
0017 
0018     Q_PROPERTY(QUrl audioUrl READ audioUrl NOTIFY songChanged)
0019     Q_PROPERTY(QString title READ title NOTIFY songChanged)
0020     Q_PROPERTY(QString artist READ artist NOTIFY songChanged) // may be empty if it is a video
0021     Q_PROPERTY(QString channel READ channel NOTIFY songChanged)
0022     Q_PROPERTY(QString thumbnail READ thumbnail NOTIFY songChanged)
0023     Q_PROPERTY(bool loading READ loading WRITE setLoading NOTIFY songChanged)
0024 
0025 public:
0026     explicit VideoInfoExtractor(QObject *parent = nullptr);
0027 
0028     QUrl audioUrl() const;
0029 
0030     QString videoId() const;
0031     void setVideoId(const QString &videoId);
0032     Q_SIGNAL void videoIdChanged();
0033 
0034     QString title() const;
0035 
0036     QString artist() const;
0037 
0038     QString channel() const;
0039 
0040     QString thumbnail() const;
0041 
0042     bool loading() const;
0043     void setLoading(bool loading);
0044     Q_SIGNAL void loadingChanged();
0045 
0046     Q_SIGNAL void songChanged();
0047 
0048 private:
0049     bool m_loading = false;
0050     QString m_videoId;
0051     video_info::VideoInfo m_videoInfo;
0052 };