1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
#ifndef MALTRACKER_H
#define MALTRACKER_H
#include <QString>
#include "nwutils.h"
#include "onlinetracker.h"
namespace Mal {
enum UpdateWatchStatus {
watching = 1,
completed = 2,
onhold = 3,
dropped = 4,
plantowatch = 6
};
class UpdateItem {
public:
UpdateItem(const TvShow*);
static UpdateWatchStatus calculateWatchStatus(const TvShow::WatchStatus status);
void describe(nw::Describer& de);
QString toXml();
private:
int episode;
UpdateWatchStatus status; // int OR string. 1/watching, 2/completed, 3/onhold, 4/dropped, 6/plantowatch
short score; // 0 - 10
int downloaded_episodes;
int storage_type; // int (will be updated to accomodate strings soon) // yeah sure soon...
float storage_value; // wat
int times_rewatched;
int rewatch_value; // no idea, displayed as "High", "Low" on the website or something
QDate date_start; // date. mmddyyyy
QDate date_finish; // date. mmddyyyy
int priority; // 0 - 10 ? dont know didn't check
short enable_discussion; // int. 1=enable, 0=disable
short enable_rewatching; // int. 1=enable, 0=disable
QString comments; // free text field?
QString fansub_group;
QStringList tags; // string. tags separated by commas
};
class Tracker : public OnlineTracker
{
Q_OBJECT
public:
class Entry : public OnlineTracker::Entry {
public:
Entry(nw::Describer &de);
int series_animedb_id;
QString series_title;
QString series_synonyms;
int series_type;
int series_episodes;
int series_status;
QDate series_start; //2004-10-05
QDate series_end;
QString series_image;
QString my_id; // always 0 no idea what it does
int my_watched_episodes;
QDate my_start_date; // 0000-00-00
QDate my_finish_date; // 0000-00-00
int my_score;
TvShow::WatchStatus my_status;
int my_rewatching;
int my_rewatching_ep;
uint my_last_updated; // unix time int example: 1388944557
QStringList my_tags; // separated by ", "
virtual QDateTime lastUpdate() const { QDateTime t; t.setTime_t(my_last_updated); return t; }
virtual int remoteId() const { return series_animedb_id; }
virtual int watchedEpisodes() const { return my_watched_episodes; }
virtual int rewatchMarker() const { return my_rewatching_ep; }
virtual int rewatchCount() const { return my_rewatching; }
virtual int totalEpisodes() const { return series_episodes; }
virtual bool supportsRewatchMarker() const { return true; }
virtual TvShow::WatchStatus getStatusWouldSendIfSynced(TvShow::WatchStatus showStatus) const;
virtual TvShow::WatchStatus watchStatus() const { return my_status; }
void describe(nw::Describer& de);
static TvShow::WatchStatus restoreStatus(int malStatusId);
};
class EntryList : public OnlineTracker::EntryList {
public:
EntryList();
virtual ~EntryList();
EntryList(nw::Describer& de);
Entry* get(int remoteId);
QList<Entry*> items;
QString error; // should be empty
void describe(nw::Describer& de);
void updateShows(const QString trackerIdentifierKey, QList<TvShow*> shows);
const Entry* get(const QString trackerIdentifierKey, const TvShow* show) const;
};
explicit Tracker(const OnlineCredentials& credentials, OnlineCredentials::TimeLock& lock, QObject *parent = 0);
OnlineTracker::EntryList* fetchRemote();
const QString identifierKey() const;
static const QString IDENTIFIER_KEY;
/// This sounds like it makes 0 sense whatsoever,
/// but mal-api is a huge pice of shit and the only way we can get
/// infos about an entry by using it's id
/// is by taking them from the already watching list.
/// Oh fuck everything.
void updateTrackingUnrelatedMetaDataFromRemote(TvShow* show, const OnlineTracker::EntryList& e) const;
protected:
virtual UpdateResult updateinOnlineTrackerOrAdd(const TvShow* show, const QString& type) const;
signals:
public slots:
private:
CURL* curlTrackerUpdateClient(const char* url, CurlResult& userdata, UpdateItem& data) const;
};
}
#endif // MALTRACKER_H