You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 

65 lines
2.1 KiB

  1. /*
  2. * This program is free software: you can redistribute it and/or modify
  3. it under the terms of the GNU General Public License as published by
  4. the Free Software Foundation, either version 3 of the License, or
  5. (at your option) any later version.
  6. This program is distributed in the hope that it will be useful,
  7. but WITHOUT ANY WARRANTY; without even the implied warranty of
  8. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  9. GNU General Public License for more details.
  10. You should have received a copy of the GNU General Public License
  11. along with this program. If not, see <https://www.gnu.org/licenses/>.
  12. *
  13. * [email protected] 2019
  14. */
  15. #ifndef CRUNCHYROLLAPI_H
  16. #define CRUNCHYROLLAPI_H
  17. #include <QVariant>
  18. #include <QFile>
  19. #include <QDir>
  20. #include <QDebug>
  21. #include <QJsonDocument>
  22. #include <QJsonArray>
  23. #include <QJsonObject>
  24. #include <QNetworkCookieJar>
  25. #include <QNetworkCookie>
  26. #include <QPair>
  27. #include <iostream>
  28. #include "customcookiejar.h"
  29. #include "models.h"
  30. #include "colors.h"
  31. #include "WebLoader/src/NetworkRequestLoader.h"
  32. class CrunchyrollAPI
  33. {
  34. public:
  35. CrunchyrollAPI();
  36. QString getRandomDeviceID() const;
  37. //Configuration
  38. void setLocale(QString locale);
  39. QString getLocale() const;
  40. void setSessionID(QString session);
  41. QString getSessionID() const;
  42. //API
  43. QPair<session_t,api_status_t> newSession(bool USproxy);
  44. QPair<user_t,api_status_t> doLogin(QString mail,QString pass);
  45. QPair<user_t,api_status_t> doProxyLogin(QString mail,QString pass);
  46. QPair<QVector<query_t>,api_status_t> searchMedia(QString query);
  47. QPair<QVector<collection_t>,api_status_t> getCollections(int seriesid);
  48. QPair<QVector<meta_episode_t>,api_status_t> getEpisodes(int SeriesOrCollectionID, bool useSeriesID);
  49. QPair<episode_t,api_status_t> getEpisode(int mediaID);
  50. QPair<QString,api_status_t> downloadM3U(episode_t episode);
  51. void printEpisodeDetails(episode_t episode);
  52. private:
  53. QString session;
  54. QString locale = "enUS";
  55. api_error_t checkAPIresponse(QJsonDocument doc);
  56. };
  57. #endif // CRUNCHYROLLAPI_H