This repository has been archived by the owner on May 18, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 4
/
imageserver.c
217 lines (203 loc) · 6.47 KB
/
imageserver.c
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
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
#include "imageserver.h"
using namespace std;
cImageServer::cImageServer(cTVScraperDB *db, cOverRides *overrides) {
this->db = db;
this->overrides = overrides;
}
cImageServer::~cImageServer() {
}
scrapType cImageServer::GetScrapType(const cEvent *event) {
scrapType type = scrapNone;
string title = (event->Title())?event->Title():"";
type = overrides->Type(title);
if (type != scrapNone)
return type;
int duration = event->Duration() / 60;
if ((duration > 9) && (duration <= 75)) {
type = scrapSeries;
} else if (duration > 75) {
type = scrapMovie;
}
return type;
}
int cImageServer::GetID(int eventID, scrapType type, bool isRecording) {
int id = 0;
if (type == scrapSeries) {
id = db->GetSeriesID(eventID, isRecording);
} else if (type == scrapMovie) {
id = db->GetMovieID(eventID, isRecording);
}
return id;
}
cTvMedia cImageServer::GetPosterOrBanner(int id, scrapType type) {
cTvMedia media;
media.path = "";
media.width = 0;
media.height = 0;
if (type == scrapSeries) {
stringstream path;
path << config.GetBaseDir() << "/series/" << id << "/banner.jpg";
media.path = path.str();
media.width = 758;
media.height = 140;
} else if (type == scrapMovie) {
stringstream path;
path << config.GetBaseDir() << "/movies/" << id << "_poster.jpg";
media.path = path.str();
media.width = 500;
media.height = 750;
}
return media;
}
cTvMedia cImageServer::GetPoster(int id, scrapType type) {
cTvMedia media;
media.path = "";
media.width = 0;
media.height = 0;
if (type == scrapSeries) {
stringstream path;
path << config.GetBaseDir() << "/series/" << id << "/poster_0.jpg";
string filePoster = path.str();
if (FileExists(filePoster)) {
media.path = filePoster;
media.width = 680;
media.height = 1000;
}
} else if (type == scrapMovie) {
stringstream path;
path << config.GetBaseDir() << "/movies/" << id << "_poster.jpg";
string filePoster = path.str();
if (FileExists(filePoster)) {
media.path = path.str();
media.width = 500;
media.height = 750;
}
}
return media;
}
cTvMedia cImageServer::GetBanner(int id) {
cTvMedia media;
media.path = "";
media.width = 0;
media.height = 0;
stringstream path;
path << config.GetBaseDir() << "/series/" << id << "/banner.jpg";
string fileBanner = path.str();
if (FileExists(fileBanner)) {
media.path = fileBanner;
media.width = 758;
media.height = 140;
}
return media;
}
vector<cTvMedia> cImageServer::GetPosters(int id, scrapType type) {
vector<cTvMedia> posters;
if (type == scrapSeries) {
for (int i=0; i<3; i++) {
stringstream path;
path << config.GetBaseDir() << "/series/" << id << "/poster_" << i << ".jpg";
string filePoster = path.str();
if (FileExists(filePoster)) {
cTvMedia media;
media.path = filePoster;
media.width = 680;
media.height = 1000;
posters.push_back(media);
} else
break;
}
} else if (type == scrapMovie) {
stringstream path;
path << config.GetBaseDir() << "/movies/" << id << "_poster.jpg";
string filePoster = path.str();
if (FileExists(filePoster)) {
cTvMedia media;
media.path = path.str();
media.width = 500;
media.height = 750;
posters.push_back(media);
}
}
return posters;
}
vector<cTvMedia> cImageServer::GetSeriesFanarts(int id) {
vector<cTvMedia> fanart;
for (int i=0; i<3; i++) {
stringstream path;
path << config.GetBaseDir() << "/series/" << id << "/fanart_" << i << ".jpg";
string fileFanart = path.str();
if (FileExists(fileFanart)) {
cTvMedia media;
media.path = fileFanart;
media.width = 1920;
media.height = 1080;
fanart.push_back(media);
} else
break;
}
return fanart;
}
cTvMedia cImageServer::GetMovieFanart(int id) {
cTvMedia fanart;
stringstream path;
path << config.GetBaseDir() << "/movies/" << id << "_backdrop.jpg";
string fileFanart = path.str();
if (FileExists(fileFanart)) {
fanart.path = fileFanart;
fanart.width = 1280;
fanart.height = 720;
}
return fanart;
}
vector<cActor> cImageServer::GetActors(int id, scrapType type) {
vector<cActor> actors;
if (type == scrapSeries) {
vector<vector<string> > actorsDB = db->GetActorsSeries(id);
int numActors = actorsDB.size();
for (int i=0; i < numActors; i++) {
vector<string> row = actorsDB[i];
if (row.size() == 3) {
cActor actor;
actor.name = row[0];
actor.role = row[1];
cTvMedia thumb;
stringstream thumbPath;
thumbPath << config.GetBaseDir() << "/series/" << id << "/" << row[2];
thumb.path = thumbPath.str();
thumb.width = 300;
thumb.height = 450;
actor.actorThumb = thumb;
actors.push_back(actor);
}
}
} else if (type == scrapMovie) {
vector<vector<string> > actorsDB = db->GetActorsMovie(id);
int numActors = actorsDB.size();
for (int i=0; i < numActors; i++) {
vector<string> row = actorsDB[i];
if (row.size() == 3) {
cActor actor;
actor.name = row[1];
actor.role = row[2];
stringstream thumbPath;
thumbPath << config.GetBaseDir() << "/movies/actors/actor_" << row[0] << ".jpg";
cTvMedia thumb;
thumb.path = thumbPath.str();
thumb.width = 421;
thumb.height = 632;
actor.actorThumb = thumb;
actors.push_back(actor);
}
}
}
return actors;
}
string cImageServer::GetDescription(int id, scrapType type) {
string description;
if (type == scrapSeries) {
description = db->GetDescriptionSeries(id);
} else if (type == scrapMovie) {
description = db->GetDescriptionMovie(id);
}
return description;
}