Version bump, TV show & poster fix

Version bump, fixed TV show HTML generation, fixed poster search (will re-try without language setting if none found)
This commit is contained in:
farfalleflickan 2023-01-02 12:27:49 +01:00
parent ea841fe9a0
commit 8ed17ed69b
No known key found for this signature in database
GPG Key ID: 6506CE3E020FAF59
4 changed files with 64 additions and 42 deletions

View File

@ -17,7 +17,7 @@
#include "main.h"
#define REPO_URL "https://github.com/farfalleflickan/cmyflix"
#define VERSION_STRING "0.2"
#define VERSION_STRING "0.21"
// GLOBAL VARIABLES
FILE *LOGFILE=NULL;

View File

@ -300,6 +300,12 @@ char *getMoviePoster(progConfig *conf, int tmdb_id) {
snprintf(posterURL, posterURLSize, "%s%s%d%s%s%s,%s", tmdbSite, tmdbM, tmdb_id, tmdbP, conf->TMDBapi, tmdbP_Opts, conf->prefImgLangM);
if (posterURL!=NULL) {
imgURL=getPoster(posterURL, conf, conf->prefImgWidthM, conf->prefImgRatioM, conf->prefImgLangM);
if (imgURL==NULL) {
printError("getMoviePoster error", true, HRED, "failed while using URL '%s';\nRetrying without language option...\n", posterURL);
posterURL[0]='\0';
snprintf(posterURL, posterURLSize, "%s%s%d%s%s", tmdbSite, tmdbM, tmdb_id, tmdbP, conf->TMDBapi);
imgURL=getPoster(posterURL, conf, conf->prefImgWidthM, conf->prefImgRatioM, NULL);
}
if (imgURL==NULL) {
printError("getMoviePoster error", true, HRED, "failed while using URL '%s';\n", posterURL);
} else {

View File

@ -495,8 +495,19 @@ char *getShowPoster(progConfig *conf, unsigned int tmdb_id) {
mallocMacro(posterURL, posterURLSize, "getShowPoster error");
posterURL[0]='\0';
snprintf(posterURL, posterURLSize, "%s%s%u%s%s%s,%s", tmdbSite, tmdbTV, tmdb_id, tmdbP, conf->TMDBapi, tmdbP_Opts, conf->prefImgLangTV);
if (posterURL!=NULL) {
imgURL=getPoster(posterURL, conf, conf->prefImgWidthTV, conf->prefImgRatioTV, conf->prefImgLangTV);
if (imgURL==NULL) {
printError("getShowPoster error", true, HRED, "failed while using URL '%s';\nRetrying without language option...\n", posterURL);
posterURL[0]='\0';
snprintf(posterURL, posterURLSize, "%s%s%u%s%s", tmdbSite, tmdbTV, tmdb_id, tmdbP, conf->TMDBapi);
imgURL=getPoster(posterURL, conf, conf->prefImgWidthTV, conf->prefImgRatioTV, NULL);
}
if (imgURL==NULL) {
printError("getShowPoster error", true, HRED, "failed while using URL '%s';\n", posterURL);
} else {
printInfo("getShowPoster info", true, "got poster for \"%d\", URL: \"%s\";\n", tmdb_id, imgURL);
if (imgURL!=NULL && conf->dTVImg) { // if image should actually be downloaded, otherwise will just link to imgURL
if (checkFolder(conf->dTVFolder, true)==0) {
@ -519,7 +530,11 @@ char *getShowPoster(progConfig *conf, unsigned int tmdb_id) {
tryFree(dlFileName);
}
}
}
tryFree(posterURL);
} else {
printError("getShowPoster error", false, HRED, "could not build URL request string, something went wrong...\n");
}
return imgURL;
}
@ -677,11 +692,6 @@ void *showHTML(void *threadArg) {
fatalError_abort("showHTML error", "showName==NULL; JSON was:\n%s\n--- END ---\n", cJSON_Print(myJSON));
}
char *numOfSeasonsStr=cJSON_GetStringValue(cJSON_GetObjectItem(myJSON, "Seasons"));
int myNumSeasons=0;
if (numOfSeasonsStr!=NULL) {
myNumSeasons=parseStrToInt(numOfSeasonsStr);
}
int uuid=thisThread->id;
cJSON *episodesArray=cJSON_GetObjectItem(myJSON, "Episodes");
cJSON *extrasArray=cJSON_GetObjectItem(myJSON, "Extras");
@ -689,7 +699,6 @@ void *showHTML(void *threadArg) {
fatalError_abort("showHTML error", " episodesArray or extrasArray were equal to NULL; JSON was:\n%s\n--- END ---\n ", cJSON_Print(myJSON));
}
printInfo("showHTML info", true, "building HTML for \"%s\";\n", showName);
cJSON *episode=NULL;
addData(this_show, SHOW_HTML_TOP);
@ -702,8 +711,14 @@ void *showHTML(void *threadArg) {
snprintf(tempStr, tempStrSize, SHOW_HTML_SEL, uuid);
addData(this_show, tempStr);
while (currSeason<myNumSeasons) {
currSeason++;
cJSON_ArrayForEach(episode, episodesArray) {
int this_seasonNum=0;
cJSON *jsonSeason=cJSON_GetObjectItem(episode, "Season");
if (jsonSeason!=NULL) {
this_seasonNum=parseStrToInt(cJSON_GetStringValue(jsonSeason));
}
if (this_seasonNum>currSeason) {
currSeason=this_seasonNum;
tempStrSize=strlen(SHOW_HTML_OPT_SEASON)+intSize(currSeason)+intSize(currSeason)+1;
tempStr=realloc(tempStr, tempStrSize);
if (tempStr==NULL) {
@ -712,6 +727,7 @@ void *showHTML(void *threadArg) {
snprintf(tempStr, tempStrSize, SHOW_HTML_OPT_SEASON, currSeason, currSeason);
addData(this_show, tempStr);
}
}
if (extrasArray!=NULL && cJSON_GetArraySize(extrasArray)>0) {
currSeason++;
tempStrSize=strlen(SHOW_HTML_OPT_EXTRAS)+intSize(currSeason)+1;
@ -801,7 +817,7 @@ void episodeHTML(fileList *this_show, progConfig *conf, cJSON *episode, int *cur
if (*currSeason>0) { // new season, so close prev season list
addData(this_show, "\n</ul>\n");
}
(*currSeason)++;
(*currSeason)=this_seasonNum;
tempStrSize=intSize(*uuid)+intSize(*currSeason)+strlen(SHOW_HTML_UL)+1;
tempStr=realloc(tempStr, tempStrSize);
if (tempStr==NULL) {

View File

@ -780,7 +780,7 @@ char *getPoster(const char *posterURL, progConfig *conf, int prefImgWidth, doubl
cJSON *lang=cJSON_DetachItemFromObject(item, "iso_639_1");
if ((width!=NULL && cJSON_GetNumberValue(width)==prefImgWidth) || (ratio!=NULL && cJSON_GetNumberValue(ratio)==prefImgRatio)) {
if (lang!=NULL && cJSON_GetStringValue(lang)!=NULL && strcmp(cJSON_GetStringValue(lang), prefImgLang)==0) {
if ((prefImgLang!=NULL && lang!=NULL && cJSON_GetStringValue(lang)!=NULL && strcmp(cJSON_GetStringValue(lang), prefImgLang)==0) || prefImgLang==NULL) {
cJSON *imgStr=cJSON_DetachItemFromObject(item, "file_path");
if (imgStr!=NULL && cJSON_GetStringValue(imgStr)!=NULL) {
size_t urlLen=strlen(tmdbImg)+strlen(cJSON_GetStringValue(imgStr))+1;
@ -805,7 +805,7 @@ char *getPoster(const char *posterURL, progConfig *conf, int prefImgWidth, doubl
cJSON_Delete(item);
}
if (imgURL==NULL) {
printError("getPoster warning", true, HYEL, "request error, URL: '%s';\nitem==NULL - json_posters was:\n", posterURL);
printError("getPoster warning", true, HYEL, "request error, URL: '%s';\nCould not find a poster - json_posters was:\n", posterURL);
char *tempStr=cJSON_Print(json_posters);
printError("", true, COLOR_RESET, tempStr);
printError("", true, HYEL, "\nEND;\n");