youtube-api-wrappers.hpp 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596
  1. #pragma once
  2. #include "auth-youtube.hpp"
  3. #include <json11.hpp>
  4. #include <QString>
  5. struct ChannelDescription {
  6. QString id;
  7. QString title;
  8. QString country;
  9. QString language;
  10. };
  11. struct StreamDescription {
  12. QString id;
  13. QString name;
  14. QString title;
  15. QString description;
  16. };
  17. struct CategoryDescription {
  18. QString id;
  19. QString title;
  20. };
  21. struct BroadcastDescription {
  22. QString id;
  23. QString title;
  24. QString description;
  25. QString privacy;
  26. CategoryDescription category;
  27. QString latency;
  28. bool made_for_kids;
  29. bool auto_start;
  30. bool auto_stop;
  31. bool dvr;
  32. bool schedul_for_later;
  33. QString schedul_date_time;
  34. QString projection;
  35. };
  36. struct BindDescription {
  37. const QString id;
  38. const QString stream_name;
  39. };
  40. bool IsYouTubeService(const std::string &service);
  41. class YoutubeApiWrappers : public YoutubeAuth {
  42. Q_OBJECT
  43. bool TryInsertCommand(const char *url, const char *content_type,
  44. std::string request_type, const char *data,
  45. json11::Json &ret, long *error_code = nullptr);
  46. bool UpdateAccessToken();
  47. bool InsertCommand(const char *url, const char *content_type,
  48. std::string request_type, const char *data,
  49. json11::Json &ret);
  50. public:
  51. YoutubeApiWrappers(const Def &d);
  52. bool GetChannelDescription(ChannelDescription &channel_description);
  53. bool InsertBroadcast(BroadcastDescription &broadcast);
  54. bool InsertStream(StreamDescription &stream);
  55. bool BindStream(const QString broadcast_id, const QString stream_id);
  56. bool GetBroadcastsList(json11::Json &json_out, const QString &page,
  57. const QString &status);
  58. bool
  59. GetVideoCategoriesList(QVector<CategoryDescription> &category_list_out);
  60. bool SetVideoCategory(const QString &video_id,
  61. const QString &video_title,
  62. const QString &video_description,
  63. const QString &categorie_id);
  64. bool StartBroadcast(const QString &broadcast_id);
  65. bool StopBroadcast(const QString &broadcast_id);
  66. bool ResetBroadcast(const QString &broadcast_id);
  67. bool StartLatestBroadcast();
  68. bool StopLatestBroadcast();
  69. void SetBroadcastId(QString &broadcast_id);
  70. bool FindBroadcast(const QString &id, json11::Json &json_out);
  71. bool FindStream(const QString &id, json11::Json &json_out);
  72. QString GetLastError() { return lastErrorMessage; };
  73. bool GetTranslatedError(QString &error_message);
  74. private:
  75. QString broadcast_id;
  76. int lastError;
  77. QString lastErrorMessage;
  78. QString lastErrorReason;
  79. };