File indexing completed on 2025-01-26 04:44:15
0001 /*************************************************************************** 0002 Copyright (C) 2004-2009 Robby Stephenson <robby@periapsis.org> 0003 ***************************************************************************/ 0004 0005 /*************************************************************************** 0006 * * 0007 * This program is free software; you can redistribute it and/or * 0008 * modify it under the terms of the GNU General Public License as * 0009 * published by the Free Software Foundation; either version 2 of * 0010 * the License or (at your option) version 3 or any later version * 0011 * accepted by the membership of KDE e.V. (or its successor approved * 0012 * by the membership of KDE e.V.), which shall act as a proxy * 0013 * defined in Section 14 of version 3 of the license. * 0014 * * 0015 * This program is distributed in the hope that it will be useful, * 0016 * but WITHOUT ANY WARRANTY; without even the implied warranty of * 0017 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * 0018 * GNU General Public License for more details. * 0019 * * 0020 * You should have received a copy of the GNU General Public License * 0021 * along with this program. If not, see <http://www.gnu.org/licenses/>. * 0022 * * 0023 ***************************************************************************/ 0024 0025 #include "imdbfetcher.h" 0026 0027 namespace { 0028 static const uint IMDB_MAX_RESULTS = 20; 0029 static const int IMDB_MAX_PERSON_COUNT = 5; // limit number of directors, writers, etc, esp for TV series 0030 } 0031 0032 using Tellico::Fetch::IMDBFetcher; 0033 0034 QString IMDBFetcher::searchQuery() { 0035 static const auto query(QStringLiteral(R"( 0036 query Search($searchTerms: String!) { 0037 mainSearch(first: %1, options: {searchTerm: $searchTerms, isExactMatch: false, type: TITLE}) { 0038 edges { 0039 node { 0040 entity { 0041 ... on Title { 0042 id 0043 titleText { 0044 text 0045 } 0046 titleType { 0047 text 0048 } 0049 releaseYear { 0050 year 0051 endYear 0052 } 0053 } 0054 } 0055 } 0056 } 0057 } 0058 } 0059 )")); 0060 return query.arg(IMDB_MAX_RESULTS); 0061 } 0062 0063 QString IMDBFetcher::titleQuery() { 0064 static const auto query(QStringLiteral(R"( 0065 query TitleFull($id: ID!) { 0066 # __type(name: "Company") { 0067 # name 0068 # fields { 0069 # name 0070 # type { 0071 # name 0072 # kind 0073 # } 0074 # } 0075 # } 0076 0077 title(id: $id) { 0078 titleText { 0079 text 0080 } 0081 titleType { 0082 text 0083 } 0084 originalTitleText { 0085 text 0086 } 0087 canonicalUrl 0088 akas(first: 99) { 0089 edges { 0090 node { 0091 text 0092 } 0093 } 0094 } 0095 releaseYear { 0096 year 0097 } 0098 runtime { 0099 seconds 0100 } 0101 countriesOfOrigin { 0102 countries { 0103 text 0104 } 0105 } 0106 spokenLanguages { 0107 spokenLanguages { 0108 text 0109 } 0110 } 0111 ratingsSummary { 0112 aggregateRating 0113 } 0114 certificate { 0115 rating 0116 country { 0117 text 0118 } 0119 } 0120 plot { 0121 plotText { 0122 plainText 0123 } 0124 } 0125 genres { 0126 genres { 0127 text 0128 } 0129 } 0130 primaryImage { 0131 url 0132 width 0133 height 0134 } 0135 companyCredits(first: 99, filter: {categories: ["production"]}) { 0136 edges { 0137 node { 0138 category { 0139 text 0140 id 0141 } 0142 company { 0143 companyText { 0144 text 0145 } 0146 } 0147 } 0148 } 0149 } 0150 technicalSpecifications { 0151 colorations { 0152 items { 0153 text 0154 } 0155 } 0156 soundMixes { 0157 items { 0158 text 0159 } 0160 } 0161 aspectRatios { 0162 items { 0163 aspectRatio 0164 } 0165 } 0166 } 0167 cast: credits(first: 99, filter: {categories: ["cast"]}) { 0168 edges { 0169 node { 0170 name { 0171 nameText { 0172 text 0173 } 0174 } 0175 ... on Cast { 0176 characters { 0177 name 0178 } 0179 } 0180 } 0181 } 0182 } 0183 producers: credits(first: 99, filter: {categories: ["producer"]}) { 0184 edges { 0185 node { 0186 name { 0187 nameText { 0188 text 0189 } 0190 } 0191 } 0192 } 0193 } 0194 directors: credits(first: 99, filter: {categories: ["director"]}) { 0195 edges { 0196 node { 0197 name { 0198 nameText { 0199 text 0200 } 0201 } 0202 } 0203 } 0204 } 0205 writers: credits(first: 99, filter: {categories: ["writer"]}) { 0206 edges { 0207 node { 0208 name { 0209 nameText { 0210 text 0211 } 0212 } 0213 } 0214 } 0215 } 0216 composers: credits(first: 99, filter: {categories: ["composer"]}) { 0217 edges { 0218 node { 0219 name { 0220 nameText { 0221 text 0222 } 0223 } 0224 } 0225 } 0226 } 0227 principalProducers: principalCredits(filter: {categories: ["producer"]}) { 0228 ...Credits 0229 } 0230 principalDirectors: principalCredits(filter: {categories: ["director"]}) { 0231 ...Credits 0232 } 0233 } 0234 } 0235 fragment Credits on PrincipalCreditsForCategory { 0236 credits(limit: 99) { 0237 name { 0238 nameText { 0239 text 0240 } 0241 } 0242 } 0243 } 0244 )")); 0245 return query; 0246 } 0247 0248 QString IMDBFetcher::episodeQuery() { 0249 static const auto query(QStringLiteral(R"( 0250 query TitleFull($id: ID!) { 0251 title(id: $id) { 0252 titleText { 0253 text 0254 } 0255 titleType { 0256 text 0257 } 0258 originalTitleText { 0259 text 0260 } 0261 canonicalUrl 0262 akas(first: 9999) { 0263 edges { 0264 node { 0265 text 0266 } 0267 } 0268 } 0269 releaseYear { 0270 year 0271 } 0272 countriesOfOrigin { 0273 countries { 0274 text 0275 } 0276 } 0277 spokenLanguages { 0278 spokenLanguages { 0279 text 0280 } 0281 } 0282 ratingsSummary { 0283 aggregateRating 0284 } 0285 certificate { 0286 rating 0287 country { 0288 text 0289 } 0290 } 0291 plot { 0292 plotText { 0293 plainText 0294 } 0295 } 0296 genres { 0297 genres { 0298 text 0299 } 0300 } 0301 primaryImage { 0302 url 0303 width 0304 height 0305 } 0306 companyCredits(first: 99, filter: {categories: ["production"]}) { 0307 edges { 0308 node { 0309 category { 0310 text 0311 id 0312 } 0313 company { 0314 companyText { 0315 text 0316 } 0317 } 0318 } 0319 } 0320 } 0321 technicalSpecifications { 0322 colorations { 0323 items { 0324 text 0325 } 0326 } 0327 soundMixes { 0328 items { 0329 text 0330 } 0331 } 0332 aspectRatios { 0333 items { 0334 aspectRatio 0335 } 0336 } 0337 } 0338 cast: credits(first: 99, filter: {categories: ["cast"]}) { 0339 edges { 0340 node { 0341 name { 0342 nameText { 0343 text 0344 } 0345 } 0346 ... on Cast { 0347 characters { 0348 name 0349 } 0350 } 0351 } 0352 } 0353 } 0354 producers: credits(first: %1, filter: {categories: ["producer"]}) { 0355 edges { 0356 node { 0357 name { 0358 nameText { 0359 text 0360 } 0361 } 0362 } 0363 } 0364 } 0365 directors: credits(first: %1, filter: {categories: ["director"]}) { 0366 edges { 0367 node { 0368 name { 0369 nameText { 0370 text 0371 } 0372 } 0373 } 0374 } 0375 } 0376 writers: credits(first: %1, filter: {categories: ["writer"]}) { 0377 edges { 0378 node { 0379 name { 0380 nameText { 0381 text 0382 } 0383 } 0384 } 0385 } 0386 } 0387 composers: credits(first: %1, filter: {categories: ["composer"]}) { 0388 edges { 0389 node { 0390 name { 0391 nameText { 0392 text 0393 } 0394 } 0395 } 0396 } 0397 } 0398 principalProducers: principalCredits(filter: {categories: ["producer"]}) { 0399 ...Credits 0400 } 0401 principalDirectors: principalCredits(filter: {categories: ["director"]}) { 0402 ...Credits 0403 } 0404 episodes { 0405 episodes(first: 999) { 0406 edges { 0407 node { 0408 # Get the names of the episodes 0409 titleText { 0410 text 0411 } 0412 series { 0413 displayableEpisodeNumber { 0414 displayableSeason { 0415 text 0416 } 0417 episodeNumber { 0418 text 0419 } 0420 } 0421 } 0422 } 0423 } 0424 } 0425 } 0426 } 0427 } 0428 fragment Credits on PrincipalCreditsForCategory { 0429 credits(limit: %1) { 0430 name { 0431 nameText { 0432 text 0433 } 0434 } 0435 } 0436 } 0437 )")); 0438 return query.arg(IMDB_MAX_PERSON_COUNT); 0439 }