mirror of
https://projects.vdr-developer.org/git/vdr-plugin-scraper2vdr.git
synced 2023-10-19 17:58:31 +02:00
Version 0.1.2
This commit is contained in:
parent
30008b3000
commit
ca71c83e5d
11
HISTORY
11
HISTORY
@ -14,3 +14,14 @@ Version 0.1.0
|
|||||||
- fixed bug that scraped events are not displayed randomly
|
- fixed bug that scraped events are not displayed randomly
|
||||||
|
|
||||||
Version 0.1.1
|
Version 0.1.1
|
||||||
|
|
||||||
|
- update of db api
|
||||||
|
- prepare statements only once
|
||||||
|
- added statement statistic
|
||||||
|
- minor changes
|
||||||
|
- changed mail loop timing
|
||||||
|
- added path detection for libmysql
|
||||||
|
- fixed epgd state detection
|
||||||
|
- added cppcheck to Makefile
|
||||||
|
|
||||||
|
Version 0.1.2
|
||||||
|
13
Makefile
13
Makefile
@ -25,7 +25,7 @@ TMPDIR ?= /tmp
|
|||||||
### The compiler options:
|
### The compiler options:
|
||||||
|
|
||||||
export CFLAGS = $(call PKGCFG,cflags)
|
export CFLAGS = $(call PKGCFG,cflags)
|
||||||
export CXXFLAGS = $(call PKGCFG,cxxflags)
|
export CXXFLAGS = $(call PKGCFG,cxxflags) -Wno-unused-result -Wunused-value -Wunused-variable -Wreturn-type -Wuninitialized -Wsign-compare
|
||||||
|
|
||||||
### The version number of VDR's plugin API:
|
### The version number of VDR's plugin API:
|
||||||
|
|
||||||
@ -35,7 +35,7 @@ APIVERSION = $(call PKGCFG,apiversion)
|
|||||||
|
|
||||||
-include $(PLGCFG)
|
-include $(PLGCFG)
|
||||||
|
|
||||||
LIBS = -lmysqlclient_r -luuid
|
LIBS = $(shell mysql_config --libs_r) -luuid
|
||||||
|
|
||||||
### The name of the distribution archive:
|
### The name of the distribution archive:
|
||||||
|
|
||||||
@ -48,9 +48,9 @@ SOFILE = libvdr-$(PLUGIN).so
|
|||||||
|
|
||||||
### Includes and Defines (add further entries here):
|
### Includes and Defines (add further entries here):
|
||||||
|
|
||||||
INCLUDES +=
|
INCLUDES += $(shell mysql_config --include)
|
||||||
|
|
||||||
DEFINES += -DPLUGIN_NAME_I18N='"$(PLUGIN)"'
|
DEFINES += -DPLUGIN_NAME_I18N='"$(PLUGIN)"' -DLOG_PREFIX='"$(PLUGIN): "'
|
||||||
DEFINES += -DVDR_PLUGIN -DUSEUUID
|
DEFINES += -DVDR_PLUGIN -DUSEUUID
|
||||||
|
|
||||||
ifeq ($(IMAGELIB), imagemagick)
|
ifeq ($(IMAGELIB), imagemagick)
|
||||||
@ -129,4 +129,7 @@ dist: $(I18Npo) clean
|
|||||||
|
|
||||||
clean:
|
clean:
|
||||||
@-rm -f $(PODIR)/*.mo $(PODIR)/*.pot
|
@-rm -f $(PODIR)/*.mo $(PODIR)/*.pot
|
||||||
@-rm -f $(OBJS) $(DEPFILE) *.so *.tgz core* *~
|
@-rm -f $(OBJS) $(DEPFILE) *.so *.tgz core* *~ lib/*~
|
||||||
|
|
||||||
|
cppchk:
|
||||||
|
cppcheck --template="{file}:{line}:{severity}:{message}" --quiet --force *.c *.h lib/*.c lib/*.h
|
||||||
|
11
lib/Makefile
11
lib/Makefile
@ -1,7 +1,14 @@
|
|||||||
|
|
||||||
|
BASELIBS = -lrt -lz -lmysqlclient -lcurl -luuid
|
||||||
|
BASELIBS += $(shell mysql_config --libs)
|
||||||
|
|
||||||
|
CFLAGS += $(shell mysql_config --include)
|
||||||
|
|
||||||
all:
|
all:
|
||||||
g++ -ggdb -DPLGDIR='"."' test.c common.c config.c db.c tabledef.c -lrt -lz -lmysqlclient -o t
|
g++ -ggdb -DPLGDIR='"."' $(CFLAGS) test.c dbdict.c common.c config.c db.c tabledef.c $(BASELIBS) -o t
|
||||||
|
|
||||||
|
demo: demo.c
|
||||||
|
g++ -ggdb -DUSEUUID -DPLGDIR='"."' $(CFLAGS) demo.c common.c db.c tabledef.c config.c $(BASELIBS) -o demo
|
||||||
|
|
||||||
clean:
|
clean:
|
||||||
rm -f *.o *.a *~ core
|
rm -f *.o *.a *~ core demo
|
||||||
|
426
lib/common.c
426
lib/common.c
@ -6,6 +6,7 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
#include <sys/stat.h>
|
#include <sys/stat.h>
|
||||||
|
#include <sys/time.h>
|
||||||
|
|
||||||
#ifdef USEUUID
|
#ifdef USEUUID
|
||||||
# include <uuid/uuid.h>
|
# include <uuid/uuid.h>
|
||||||
@ -17,6 +18,7 @@
|
|||||||
#include <syslog.h>
|
#include <syslog.h>
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
#include <zlib.h>
|
#include <zlib.h>
|
||||||
|
#include <errno.h>
|
||||||
|
|
||||||
#ifdef USELIBARCHIVE
|
#ifdef USELIBARCHIVE
|
||||||
# include <archive.h>
|
# include <archive.h>
|
||||||
@ -54,7 +56,7 @@ void tell(int eloquence, const char* format, ...)
|
|||||||
va_start(ap, format);
|
va_start(ap, format);
|
||||||
|
|
||||||
#ifdef VDR_PLUGIN
|
#ifdef VDR_PLUGIN
|
||||||
snprintf(t, sizeBuffer, "scraper2vdr: ");
|
snprintf(t, sizeBuffer, LOG_PREFIX);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
vsnprintf(t+strlen(t), sizeBuffer-strlen(t), format, ap);
|
vsnprintf(t+strlen(t), sizeBuffer-strlen(t), format, ap);
|
||||||
@ -62,10 +64,18 @@ void tell(int eloquence, const char* format, ...)
|
|||||||
if (EPG2VDRConfig.logstdout)
|
if (EPG2VDRConfig.logstdout)
|
||||||
{
|
{
|
||||||
char buf[50+TB];
|
char buf[50+TB];
|
||||||
time_t now;
|
timeval tp;
|
||||||
time(&now);
|
|
||||||
strftime(buf, 50, "%y.%m.%d %H:%M:%S", localtime(&now));
|
gettimeofday(&tp, 0);
|
||||||
|
|
||||||
|
tm* tm = localtime(&tp.tv_sec);
|
||||||
|
|
||||||
|
sprintf(buf,"%2.2d:%2.2d:%2.2d,%3.3ld ",
|
||||||
|
tm->tm_hour, tm->tm_min, tm->tm_sec,
|
||||||
|
tp.tv_usec / 1000);
|
||||||
|
|
||||||
printf("%s %s\n", buf, t);
|
printf("%s %s\n", buf, t);
|
||||||
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
syslog(LOG_ERR, "%s", t);
|
syslog(LOG_ERR, "%s", t);
|
||||||
@ -73,6 +83,36 @@ void tell(int eloquence, const char* format, ...)
|
|||||||
va_end(ap);
|
va_end(ap);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//***************************************************************************
|
||||||
|
// Save Realloc
|
||||||
|
//***************************************************************************
|
||||||
|
|
||||||
|
char* srealloc(void* ptr, size_t size)
|
||||||
|
{
|
||||||
|
void* n = realloc(ptr, size);
|
||||||
|
|
||||||
|
if (!n)
|
||||||
|
{
|
||||||
|
free(ptr);
|
||||||
|
ptr = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
return (char*)n;
|
||||||
|
}
|
||||||
|
|
||||||
|
//***************************************************************************
|
||||||
|
// us now
|
||||||
|
//***************************************************************************
|
||||||
|
|
||||||
|
double usNow()
|
||||||
|
{
|
||||||
|
struct timeval tp;
|
||||||
|
|
||||||
|
gettimeofday(&tp, 0);
|
||||||
|
|
||||||
|
return tp.tv_sec * 1000000.0 + tp.tv_usec;
|
||||||
|
}
|
||||||
|
|
||||||
//***************************************************************************
|
//***************************************************************************
|
||||||
// Host ID
|
// Host ID
|
||||||
//***************************************************************************
|
//***************************************************************************
|
||||||
@ -121,6 +161,38 @@ void toUpper(std::string& str)
|
|||||||
free(dest);
|
free(dest);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//***************************************************************************
|
||||||
|
// To Case (UTF-8 save)
|
||||||
|
//***************************************************************************
|
||||||
|
|
||||||
|
const char* toCase(Case cs, char* str)
|
||||||
|
{
|
||||||
|
char* s = str;
|
||||||
|
int lenSrc = strlen(str);
|
||||||
|
|
||||||
|
int csSrc; // size of character
|
||||||
|
|
||||||
|
for (int ps = 0; ps < lenSrc; ps += csSrc)
|
||||||
|
{
|
||||||
|
csSrc = max(mblen(&s[ps], lenSrc-ps), 1);
|
||||||
|
|
||||||
|
if (csSrc == 1)
|
||||||
|
s[ps] = cs == cUpper ? toupper(s[ps]) : tolower(s[ps]);
|
||||||
|
else if (csSrc == 2 && s[ps] == (char)0xc3 && s[ps+1] >= (char)0xa0)
|
||||||
|
{
|
||||||
|
s[ps] = s[ps];
|
||||||
|
s[ps+1] = cs == cUpper ? toupper(s[ps+1]) : tolower(s[ps+1]);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
for (int i = 0; i < csSrc; i++)
|
||||||
|
s[ps+i] = s[ps+i];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return str;
|
||||||
|
}
|
||||||
|
|
||||||
void removeChars(std::string& str, const char* ignore)
|
void removeChars(std::string& str, const char* ignore)
|
||||||
{
|
{
|
||||||
const char* s = str.c_str();
|
const char* s = str.c_str();
|
||||||
@ -329,6 +401,86 @@ const char* c2s(char c, char* buf)
|
|||||||
return buf;
|
return buf;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//***************************************************************************
|
||||||
|
// Store To File
|
||||||
|
//***************************************************************************
|
||||||
|
|
||||||
|
int storeToFile(const char* filename, const char* data, int size)
|
||||||
|
{
|
||||||
|
FILE* fout;
|
||||||
|
|
||||||
|
if ((fout = fopen(filename, "w+")))
|
||||||
|
{
|
||||||
|
fwrite(data, sizeof(char), size, fout);
|
||||||
|
fclose(fout);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
tell(0, "Error, can't store '%s' to filesystem '%s'", filename, strerror(errno));
|
||||||
|
return fail;
|
||||||
|
}
|
||||||
|
|
||||||
|
return success;
|
||||||
|
}
|
||||||
|
|
||||||
|
//***************************************************************************
|
||||||
|
// Load From File
|
||||||
|
//***************************************************************************
|
||||||
|
|
||||||
|
int loadFromFile(const char* infile, MemoryStruct* data)
|
||||||
|
{
|
||||||
|
FILE* fin;
|
||||||
|
struct stat sb;
|
||||||
|
|
||||||
|
data->clear();
|
||||||
|
|
||||||
|
if (!fileExists(infile))
|
||||||
|
{
|
||||||
|
tell(0, "File '%s' not found'", infile);
|
||||||
|
return fail;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (stat(infile, &sb) < 0)
|
||||||
|
{
|
||||||
|
tell(0, "Can't get info of '%s', error was '%s'", infile, strerror(errno));
|
||||||
|
return fail;
|
||||||
|
}
|
||||||
|
|
||||||
|
if ((fin = fopen(infile, "r")))
|
||||||
|
{
|
||||||
|
const char* sfx = suffixOf(infile);
|
||||||
|
|
||||||
|
data->size = sb.st_size;
|
||||||
|
data->modTime = sb.st_mtime;
|
||||||
|
data->memory = (char*)malloc(data->size);
|
||||||
|
fread(data->memory, sizeof(char), data->size, fin);
|
||||||
|
fclose(fin);
|
||||||
|
sprintf(data->tag, "%ld", data->size);
|
||||||
|
|
||||||
|
if (strcmp(sfx, "gz") == 0)
|
||||||
|
sprintf(data->contentEncoding, "gzip");
|
||||||
|
|
||||||
|
if (strcmp(sfx, "js") == 0)
|
||||||
|
sprintf(data->contentType, "application/javascript");
|
||||||
|
|
||||||
|
else if (strcmp(sfx, "png") == 0 || strcmp(sfx, "jpg") == 0 || strcmp(sfx, "gif") == 0)
|
||||||
|
sprintf(data->contentType, "image/%s", sfx);
|
||||||
|
|
||||||
|
else if (strcmp(sfx, "ico") == 0)
|
||||||
|
strcpy(data->contentType, "image/x-icon");
|
||||||
|
|
||||||
|
else
|
||||||
|
sprintf(data->contentType, "text/%s", sfx);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
tell(0, "Error, can't open '%s' for reading, error was '%s'", infile, strerror(errno));
|
||||||
|
return fail;
|
||||||
|
}
|
||||||
|
|
||||||
|
return success;
|
||||||
|
}
|
||||||
|
|
||||||
//***************************************************************************
|
//***************************************************************************
|
||||||
// TOOLS
|
// TOOLS
|
||||||
//***************************************************************************
|
//***************************************************************************
|
||||||
@ -338,6 +490,33 @@ int isEmpty(const char* str)
|
|||||||
return !str || !*str;
|
return !str || !*str;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const char* notNull(const char* str)
|
||||||
|
{
|
||||||
|
if (!str)
|
||||||
|
return "<null>";
|
||||||
|
|
||||||
|
return str;
|
||||||
|
}
|
||||||
|
|
||||||
|
int isZero(const char* str)
|
||||||
|
{
|
||||||
|
const char* p = str;
|
||||||
|
|
||||||
|
while (p && *p)
|
||||||
|
{
|
||||||
|
if (*p != '0')
|
||||||
|
return no;
|
||||||
|
|
||||||
|
p++;
|
||||||
|
}
|
||||||
|
|
||||||
|
return yes;
|
||||||
|
}
|
||||||
|
|
||||||
|
//***************************************************************************
|
||||||
|
//
|
||||||
|
//***************************************************************************
|
||||||
|
|
||||||
char* sstrcpy(char* dest, const char* src, int max)
|
char* sstrcpy(char* dest, const char* src, int max)
|
||||||
{
|
{
|
||||||
if (!dest || !src)
|
if (!dest || !src)
|
||||||
@ -356,11 +535,21 @@ int isLink(const char* path)
|
|||||||
if (lstat(path, &sb) == 0)
|
if (lstat(path, &sb) == 0)
|
||||||
return S_ISLNK(sb.st_mode);
|
return S_ISLNK(sb.st_mode);
|
||||||
|
|
||||||
tell(0, "Error: Detecting state for '%s' failed, error was '%m'", path);
|
tell(0, "Error: Detecting state for '%s' failed, error was '%s'", path, strerror(errno));
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const char* suffixOf(const char* path)
|
||||||
|
{
|
||||||
|
const char* p;
|
||||||
|
|
||||||
|
if (path && (p = strrchr(path, '.')))
|
||||||
|
return p+1;
|
||||||
|
|
||||||
|
return "";
|
||||||
|
}
|
||||||
|
|
||||||
int fileSize(const char* path)
|
int fileSize(const char* path)
|
||||||
{
|
{
|
||||||
struct stat sb;
|
struct stat sb;
|
||||||
@ -368,9 +557,21 @@ int fileSize(const char* path)
|
|||||||
if (lstat(path, &sb) == 0)
|
if (lstat(path, &sb) == 0)
|
||||||
return sb.st_size;
|
return sb.st_size;
|
||||||
|
|
||||||
tell(0, "Error: Detecting state for '%s' failed, error was '%m'", path);
|
tell(0, "Error: Detecting state for '%s' failed, error was '%s'", path, strerror(errno));
|
||||||
|
|
||||||
return false;
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
time_t fileModTime(const char* path)
|
||||||
|
{
|
||||||
|
struct stat sb;
|
||||||
|
|
||||||
|
if (lstat(path, &sb) == 0)
|
||||||
|
return sb.st_mtime;
|
||||||
|
|
||||||
|
tell(0, "Error: Detecting state for '%s' failed, error was '%s'", path, strerror(errno));
|
||||||
|
|
||||||
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -390,7 +591,7 @@ int createLink(const char* link, const char* dest, int force)
|
|||||||
|
|
||||||
if (symlink(dest, link) != 0)
|
if (symlink(dest, link) != 0)
|
||||||
{
|
{
|
||||||
tell(0, "Failed to create symlink '%s', error was '%m'", link);
|
tell(0, "Failed to create symlink '%s', error was '%s'", link, strerror(errno));
|
||||||
return fail;
|
return fail;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -408,7 +609,7 @@ int removeFile(const char* filename)
|
|||||||
|
|
||||||
if (unlink(filename) != 0)
|
if (unlink(filename) != 0)
|
||||||
{
|
{
|
||||||
tell(0, "Can't remove file '%s', '%m'", filename);
|
tell(0, "Can't remove file '%s', '%s'", filename, strerror(errno));
|
||||||
|
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
@ -432,7 +633,7 @@ int chkDir(const char* path)
|
|||||||
|
|
||||||
if (mkdir(path, ACCESSPERMS) == -1)
|
if (mkdir(path, ACCESSPERMS) == -1)
|
||||||
{
|
{
|
||||||
tell(0, "Can't create directory '%m'");
|
tell(0, "Can't create directory '%s'", strerror(errno));
|
||||||
return fail;
|
return fail;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -541,6 +742,63 @@ int gunzip(MemoryStruct* zippedData, MemoryStruct* unzippedData)
|
|||||||
return success;
|
return success;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//***************************************************************************
|
||||||
|
// gzip
|
||||||
|
//***************************************************************************
|
||||||
|
|
||||||
|
int _gzip(Bytef* dest, uLongf* destLen, const Bytef* source, uLong sourceLen)
|
||||||
|
{
|
||||||
|
z_stream stream;
|
||||||
|
int res;
|
||||||
|
|
||||||
|
stream.next_in = (Bytef *)source;
|
||||||
|
stream.avail_in = (uInt)sourceLen;
|
||||||
|
stream.next_out = dest;
|
||||||
|
stream.avail_out = (uInt)*destLen;
|
||||||
|
if ((uLong)stream.avail_out != *destLen) return Z_BUF_ERROR;
|
||||||
|
|
||||||
|
stream.zalloc = (alloc_func)0;
|
||||||
|
stream.zfree = (free_func)0;
|
||||||
|
stream.opaque = (voidpf)0;
|
||||||
|
|
||||||
|
if ((res = deflateInit2(&stream, Z_DEFAULT_COMPRESSION, Z_DEFLATED, 15 + 16, 8, Z_DEFAULT_STRATEGY)) != Z_OK)
|
||||||
|
return res;
|
||||||
|
|
||||||
|
res = deflate(&stream, Z_FINISH);
|
||||||
|
|
||||||
|
if (res != Z_STREAM_END)
|
||||||
|
{
|
||||||
|
deflateEnd(&stream);
|
||||||
|
return res == Z_OK ? Z_BUF_ERROR : res;
|
||||||
|
}
|
||||||
|
|
||||||
|
*destLen = stream.total_out;
|
||||||
|
res = deflateEnd(&stream);
|
||||||
|
|
||||||
|
return res;
|
||||||
|
}
|
||||||
|
|
||||||
|
int gzip(MemoryStruct* data, MemoryStruct* zippedData)
|
||||||
|
{
|
||||||
|
int res;
|
||||||
|
uLong sizeMax = compressBound(data->size) + 512;
|
||||||
|
|
||||||
|
zippedData->clear();
|
||||||
|
zippedData->memory = (char*)malloc(sizeMax);
|
||||||
|
|
||||||
|
if ((res = _gzip((Bytef*)zippedData->memory, &sizeMax, (Bytef*)data->memory, data->size)) != Z_OK)
|
||||||
|
{
|
||||||
|
tellZipError(res, " during compression", "");
|
||||||
|
return fail;
|
||||||
|
}
|
||||||
|
|
||||||
|
zippedData->copyAttributes(data);
|
||||||
|
zippedData->size = sizeMax;
|
||||||
|
sprintf(zippedData->contentEncoding, "gzip");
|
||||||
|
|
||||||
|
return success;
|
||||||
|
}
|
||||||
|
|
||||||
//*************************************************************************
|
//*************************************************************************
|
||||||
// tellZipError
|
// tellZipError
|
||||||
//*************************************************************************
|
//*************************************************************************
|
||||||
@ -554,11 +812,11 @@ void tellZipError(int errorCode, const char* op, const char* msg)
|
|||||||
{
|
{
|
||||||
case Z_OK: return;
|
case Z_OK: return;
|
||||||
case Z_STREAM_END: return;
|
case Z_STREAM_END: return;
|
||||||
case Z_MEM_ERROR: tell(0, "Error: Not enough memory to unzip file%s!\n", op); return;
|
case Z_MEM_ERROR: tell(0, "Error: Not enough memory to zip/unzip file%s!\n", op); return;
|
||||||
case Z_BUF_ERROR: tell(0, "Error: Couldn't unzip data due to output buffer size problem%s!\n", op); return;
|
case Z_BUF_ERROR: tell(0, "Error: Couldn't zip/unzip data due to output buffer size problem%s!\n", op); return;
|
||||||
case Z_DATA_ERROR: tell(0, "Error: Zipped input data corrupted%s! Details: %s\n", op, msg); return;
|
case Z_DATA_ERROR: tell(0, "Error: Zipped input data corrupted%s! Details: %s\n", op, msg); return;
|
||||||
case Z_STREAM_ERROR: tell(0, "Error: Invalid stream structure%s. Details: %s\n", op, msg); return;
|
case Z_STREAM_ERROR: tell(0, "Error: Invalid stream structure%s. Details: %s\n", op, msg); return;
|
||||||
default: tell(0, "Error: Couldn't unzip data for unknown reason (%6d)%s!\n", errorCode, op); return;
|
default: tell(0, "Error: Couldn't zip/unzip data for unknown reason (%6d)%s!\n", errorCode, op); return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -659,7 +917,7 @@ int unzip(const char* file, const char* filter, char*& buffer, int& size, char*
|
|||||||
|
|
||||||
if (r != ARCHIVE_OK)
|
if (r != ARCHIVE_OK)
|
||||||
{
|
{
|
||||||
tell(0, "Error: Open '%s' failed - %m", file);
|
tell(0, "Error: Open '%s' failed - %s", file, strerror(errno));
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -720,13 +978,13 @@ LogDuration::LogDuration(const char* aMessage, int aLogLevel)
|
|||||||
|
|
||||||
LogDuration::~LogDuration()
|
LogDuration::~LogDuration()
|
||||||
{
|
{
|
||||||
tell(logLevel, "duration '%s' was (%dms)",
|
tell(logLevel, "duration '%s' was (%ldms)",
|
||||||
message, cTimeMs::Now() - durationStart);
|
message, cTimeMs::Now() - durationStart);
|
||||||
}
|
}
|
||||||
|
|
||||||
void LogDuration::show(const char* label)
|
void LogDuration::show(const char* label)
|
||||||
{
|
{
|
||||||
tell(logLevel, "elapsed '%s' at '%s' was (%dms)",
|
tell(logLevel, "elapsed '%s' at '%s' was (%ldms)",
|
||||||
message, label, cTimeMs::Now() - durationStart);
|
message, label, cTimeMs::Now() - durationStart);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -785,7 +1043,7 @@ int createMd5OfFile(const char* path, const char* name, md5* md5)
|
|||||||
|
|
||||||
if (!(f = fopen(file, "r")))
|
if (!(f = fopen(file, "r")))
|
||||||
{
|
{
|
||||||
tell(0, "Fatal: Can't access '%s'; %m", file);
|
tell(0, "Fatal: Can't access '%s'; %s", file, strerror(errno));
|
||||||
free(file);
|
free(file);
|
||||||
return fail;
|
return fail;
|
||||||
}
|
}
|
||||||
@ -810,3 +1068,137 @@ int createMd5OfFile(const char* path, const char* name, md5* md5)
|
|||||||
}
|
}
|
||||||
|
|
||||||
#endif // USEMD5
|
#endif // USEMD5
|
||||||
|
|
||||||
|
//***************************************************************************
|
||||||
|
// Url Unescape
|
||||||
|
//***************************************************************************
|
||||||
|
/*
|
||||||
|
* The buffer pointed to by @dst must be at least strlen(@src) bytes.
|
||||||
|
* Decoding stops at the first character from @src that decodes to null.
|
||||||
|
|
||||||
|
* Path normalization will remove redundant slashes and slash+dot sequences,
|
||||||
|
* as well as removing path components when slash+dot+dot is found. It will
|
||||||
|
* keep the root slash (if one was present) and will stop normalization
|
||||||
|
* at the first questionmark found (so query parameters won't be normalized).
|
||||||
|
*
|
||||||
|
* @param dst destination buffer
|
||||||
|
* @param src source buffer
|
||||||
|
* @param normalize perform path normalization if nonzero
|
||||||
|
* @return number of valid characters in @dst
|
||||||
|
*/
|
||||||
|
|
||||||
|
int urlUnescape(char* dst, const char* src, int normalize)
|
||||||
|
{
|
||||||
|
// CURL* curl;
|
||||||
|
// int resultSize;
|
||||||
|
|
||||||
|
// if (curl_global_init(CURL_GLOBAL_ALL) != 0)
|
||||||
|
// {
|
||||||
|
// tell(0, "Error, something went wrong with curl_global_init()");
|
||||||
|
|
||||||
|
// return fail;
|
||||||
|
// }
|
||||||
|
|
||||||
|
// curl = curl_easy_init();
|
||||||
|
|
||||||
|
// if (!curl)
|
||||||
|
// {
|
||||||
|
// tell(0, "Error, unable to get handle from curl_easy_init()");
|
||||||
|
|
||||||
|
// return fail;
|
||||||
|
// }
|
||||||
|
|
||||||
|
// dst = curl_easy_unescape(curl, src, strlen(src), &resultSize);
|
||||||
|
|
||||||
|
// tell(0, " [%.40s]", src);
|
||||||
|
|
||||||
|
// tell(0, "res size %d [%.40s]", resultSize, dst);
|
||||||
|
// return resultSize;
|
||||||
|
|
||||||
|
char* org_dst = dst;
|
||||||
|
int slash_dot_dot = 0;
|
||||||
|
char ch, a, b;
|
||||||
|
|
||||||
|
a = 0;
|
||||||
|
|
||||||
|
do {
|
||||||
|
ch = *src++;
|
||||||
|
|
||||||
|
if (ch == '%' && isxdigit(a = src[0]) && isxdigit(b = src[1]))
|
||||||
|
{
|
||||||
|
if (a < 'A')
|
||||||
|
a -= '0';
|
||||||
|
else if
|
||||||
|
(a < 'a') a -= 'A' - 10;
|
||||||
|
else
|
||||||
|
a -= 'a' - 10;
|
||||||
|
|
||||||
|
if (b < 'A')
|
||||||
|
b -= '0';
|
||||||
|
else if (b < 'a')
|
||||||
|
b -= 'A' - 10;
|
||||||
|
else
|
||||||
|
b -= 'a' - 10;
|
||||||
|
|
||||||
|
ch = 16 * a + b;
|
||||||
|
src += 2;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (normalize)
|
||||||
|
{
|
||||||
|
switch (ch)
|
||||||
|
{
|
||||||
|
case '/': // compress consecutive slashes and remove slash-dot
|
||||||
|
if (slash_dot_dot < 3)
|
||||||
|
{
|
||||||
|
|
||||||
|
dst -= slash_dot_dot;
|
||||||
|
slash_dot_dot = 1;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
// fall-through
|
||||||
|
|
||||||
|
case '?': // at start of query, stop normalizing
|
||||||
|
if (ch == '?')
|
||||||
|
normalize = 0;
|
||||||
|
|
||||||
|
// fall-through
|
||||||
|
|
||||||
|
case '\0': // remove trailing slash-dot-(dot)
|
||||||
|
if (slash_dot_dot > 1)
|
||||||
|
{
|
||||||
|
dst -= slash_dot_dot;
|
||||||
|
|
||||||
|
// remove parent directory if it was two dots
|
||||||
|
|
||||||
|
if (slash_dot_dot == 3)
|
||||||
|
while (dst > org_dst && *--dst != '/')
|
||||||
|
; // empty body
|
||||||
|
slash_dot_dot = (ch == '/') ? 1 : 0;
|
||||||
|
|
||||||
|
// keep the root slash if any
|
||||||
|
|
||||||
|
if (!slash_dot_dot && dst == org_dst && *dst == '/')
|
||||||
|
++dst;
|
||||||
|
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
|
||||||
|
case '.':
|
||||||
|
if (slash_dot_dot == 1 || slash_dot_dot == 2)
|
||||||
|
{
|
||||||
|
++slash_dot_dot;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
// fall-through
|
||||||
|
|
||||||
|
default:
|
||||||
|
slash_dot_dot = 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
*dst++ = ch;
|
||||||
|
} while(ch);
|
||||||
|
|
||||||
|
return (dst - org_dst) - 1;
|
||||||
|
}
|
||||||
|
116
lib/common.h
116
lib/common.h
@ -10,6 +10,7 @@
|
|||||||
|
|
||||||
#include <stdint.h> // uint_64_t
|
#include <stdint.h> // uint_64_t
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
|
#include <string.h>
|
||||||
#include <string>
|
#include <string>
|
||||||
|
|
||||||
#include <openssl/md5.h> // MD5_*
|
#include <openssl/md5.h> // MD5_*
|
||||||
@ -25,7 +26,7 @@
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
//***************************************************************************
|
//***************************************************************************
|
||||||
//
|
// Misc
|
||||||
//***************************************************************************
|
//***************************************************************************
|
||||||
|
|
||||||
#ifndef VDR_PLUGIN
|
#ifndef VDR_PLUGIN
|
||||||
@ -56,49 +57,106 @@ enum Misc
|
|||||||
tmeSecondsPerDay = 24 * tmeSecondsPerHour
|
tmeSecondsPerDay = 24 * tmeSecondsPerHour
|
||||||
};
|
};
|
||||||
|
|
||||||
|
enum Case
|
||||||
|
{
|
||||||
|
cUpper,
|
||||||
|
cLower
|
||||||
|
};
|
||||||
|
|
||||||
|
const char* toCase(Case cs, char* str);
|
||||||
|
|
||||||
//***************************************************************************
|
//***************************************************************************
|
||||||
// Tell
|
// Tell
|
||||||
//***************************************************************************
|
//***************************************************************************
|
||||||
|
|
||||||
void tell(int eloquence, const char* format, ...);
|
void __attribute__ ((format(printf, 2, 3))) tell(int eloquence, const char* format, ...);
|
||||||
|
|
||||||
//***************************************************************************
|
//***************************************************************************
|
||||||
// MemoryStruct for curl callbacks
|
//
|
||||||
|
//***************************************************************************
|
||||||
|
|
||||||
|
char* srealloc(void* ptr, size_t size);
|
||||||
|
|
||||||
|
//***************************************************************************
|
||||||
|
// MemoryStruct
|
||||||
//***************************************************************************
|
//***************************************************************************
|
||||||
|
|
||||||
struct MemoryStruct
|
struct MemoryStruct
|
||||||
{
|
{
|
||||||
MemoryStruct() { memory = 0; clear(); }
|
public:
|
||||||
~MemoryStruct() { clear(); }
|
|
||||||
|
|
||||||
// data
|
MemoryStruct() { expireAt = time(0); memory = 0; clear(); }
|
||||||
|
MemoryStruct(const MemoryStruct* o)
|
||||||
|
{
|
||||||
|
size = o->size;
|
||||||
|
memory = (char*)malloc(size);
|
||||||
|
memcpy(memory, o->memory, size);
|
||||||
|
|
||||||
char* memory;
|
copyAttributes(o);
|
||||||
size_t size;
|
}
|
||||||
|
|
||||||
|
void copyAttributes(const MemoryStruct* o)
|
||||||
|
{
|
||||||
|
strcpy(tag, o->tag);
|
||||||
|
strcpy(name, o->name);
|
||||||
|
strcpy(contentType, o->contentType);
|
||||||
|
strcpy(contentEncoding, o->contentEncoding);
|
||||||
|
strcpy(mimeType, o->mimeType);
|
||||||
|
headerOnly = o->headerOnly;
|
||||||
|
modTime = o->modTime;
|
||||||
|
expireAt = o->expireAt;
|
||||||
|
}
|
||||||
|
|
||||||
|
~MemoryStruct() { clear(); }
|
||||||
|
|
||||||
|
int append(const char* buf, int len)
|
||||||
|
{
|
||||||
|
memory = srealloc(memory, size+len);
|
||||||
|
memcpy(memory+size, buf, len);
|
||||||
|
size += len;
|
||||||
|
|
||||||
// tag attribute
|
return success;
|
||||||
|
}
|
||||||
|
|
||||||
char tag[100]; // the tag to be compared
|
// data
|
||||||
char name[100]; // content name (filename)
|
|
||||||
int headerOnly;
|
char* memory;
|
||||||
|
size_t size;
|
||||||
int isEmpty() { return memory == 0; }
|
|
||||||
|
// tag attribute
|
||||||
void clear()
|
|
||||||
{
|
char tag[100]; // the tag to be compared
|
||||||
free(memory);
|
char name[100]; // content name (filename)
|
||||||
memory = 0;
|
char contentType[100]; // e.g. text/html
|
||||||
size = 0;
|
char mimeType[100]; //
|
||||||
*tag = 0;
|
char contentEncoding[100]; //
|
||||||
*name = 0;
|
int headerOnly;
|
||||||
headerOnly = no;
|
time_t modTime;
|
||||||
}
|
time_t expireAt;
|
||||||
|
|
||||||
|
int isEmpty() { return memory == 0; }
|
||||||
|
|
||||||
|
void clear()
|
||||||
|
{
|
||||||
|
free(memory);
|
||||||
|
memory = 0;
|
||||||
|
size = 0;
|
||||||
|
*tag = 0;
|
||||||
|
*name = 0;
|
||||||
|
*contentType = 0;
|
||||||
|
*contentEncoding = 0;
|
||||||
|
*mimeType = 0;
|
||||||
|
modTime = time(0);
|
||||||
|
// !!!! expireAt = time(0);
|
||||||
|
headerOnly = no;
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
//***************************************************************************
|
//***************************************************************************
|
||||||
// Tools
|
// Tools
|
||||||
//***************************************************************************
|
//***************************************************************************
|
||||||
|
|
||||||
|
double usNow();
|
||||||
unsigned int getHostId();
|
unsigned int getHostId();
|
||||||
const char* getHostName();
|
const char* getHostName();
|
||||||
const char* getFirstIp();
|
const char* getFirstIp();
|
||||||
@ -120,14 +178,23 @@ std::string num2Str(int num);
|
|||||||
std::string l2pTime(time_t t);
|
std::string l2pTime(time_t t);
|
||||||
std::string ms2Dur(uint64_t t);
|
std::string ms2Dur(uint64_t t);
|
||||||
const char* c2s(char c, char* buf);
|
const char* c2s(char c, char* buf);
|
||||||
|
int urlUnescape(char* dst, const char* src, int normalize = yes);
|
||||||
|
|
||||||
|
int storeToFile(const char* filename, const char* data, int size);
|
||||||
|
int loadFromFile(const char* infile, MemoryStruct* data);
|
||||||
|
|
||||||
int fileExists(const char* path);
|
int fileExists(const char* path);
|
||||||
int fileSize(const char* path);
|
int fileSize(const char* path);
|
||||||
|
time_t fileModTime(const char* path);
|
||||||
int createLink(const char* link, const char* dest, int force);
|
int createLink(const char* link, const char* dest, int force);
|
||||||
int isLink(const char* path);
|
int isLink(const char* path);
|
||||||
|
const char* suffixOf(const char* path);
|
||||||
int isEmpty(const char* str);
|
int isEmpty(const char* str);
|
||||||
|
const char* notNull(const char* str);
|
||||||
|
int isZero(const char* str);
|
||||||
int removeFile(const char* filename);
|
int removeFile(const char* filename);
|
||||||
int chkDir(const char* path);
|
int chkDir(const char* path);
|
||||||
|
int downloadFile(const char* url, int& size, MemoryStruct* data, int timeout = 30, const char* userAgent = "libcurl-agent/1.0");
|
||||||
|
|
||||||
#ifdef USELIBXML
|
#ifdef USELIBXML
|
||||||
xsltStylesheetPtr loadXSLT(const char* name, const char* path, int utf8);
|
xsltStylesheetPtr loadXSLT(const char* name, const char* path, int utf8);
|
||||||
@ -145,6 +212,7 @@ int chkDir(const char* path);
|
|||||||
//***************************************************************************
|
//***************************************************************************
|
||||||
|
|
||||||
int gunzip(MemoryStruct* zippedData, MemoryStruct* unzippedData);
|
int gunzip(MemoryStruct* zippedData, MemoryStruct* unzippedData);
|
||||||
|
int gzip(MemoryStruct* data, MemoryStruct* zippedData);
|
||||||
void tellZipError(int errorCode, const char* op, const char* msg);
|
void tellZipError(int errorCode, const char* op, const char* msg);
|
||||||
|
|
||||||
#ifdef USELIBARCHIVE
|
#ifdef USELIBARCHIVE
|
||||||
|
@ -44,10 +44,13 @@ cEPG2VDRConfig::cEPG2VDRConfig(void)
|
|||||||
scheduleBoot = no;
|
scheduleBoot = no;
|
||||||
#else
|
#else
|
||||||
sstrcpy(cachePath, "/var/cache/epgd", sizeof(cachePath));
|
sstrcpy(cachePath, "/var/cache/epgd", sizeof(cachePath));
|
||||||
|
sstrcpy(httpPath, "/var/epgd/www", sizeof(httpPath));
|
||||||
sstrcpy(pluginPath, PLGDIR, sizeof(pluginPath));
|
sstrcpy(pluginPath, PLGDIR, sizeof(pluginPath));
|
||||||
sstrcpy(epgView, "eventsview.sql", sizeof(epgView));
|
sstrcpy(epgView, "eventsview.sql", sizeof(epgView));
|
||||||
|
sstrcpy(theTvDBView, "thetvdbview.sql", sizeof(epgView));
|
||||||
updateThreshold = 200;
|
updateThreshold = 200;
|
||||||
maintanance = no;
|
maintanance = no;
|
||||||
|
httpPort = 9999;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
sstrcpy(dbHost, "localhost", sizeof(dbHost));
|
sstrcpy(dbHost, "localhost", sizeof(dbHost));
|
||||||
@ -60,4 +63,7 @@ cEPG2VDRConfig::cEPG2VDRConfig(void)
|
|||||||
loglevel = 1;
|
loglevel = 1;
|
||||||
|
|
||||||
uuid[0] = 0;
|
uuid[0] = 0;
|
||||||
|
|
||||||
|
scrapEpg = yes;
|
||||||
|
scrapRecordings = yes;
|
||||||
}
|
}
|
||||||
|
@ -47,10 +47,13 @@ struct cEPG2VDRConfig
|
|||||||
int scheduleBoot;
|
int scheduleBoot;
|
||||||
#else
|
#else
|
||||||
char cachePath[256+TB];
|
char cachePath[256+TB];
|
||||||
|
char httpPath[256+TB];
|
||||||
char pluginPath[256+TB];
|
char pluginPath[256+TB];
|
||||||
char epgView[100+TB];
|
char epgView[100+TB];
|
||||||
|
char theTvDBView[100+TB];
|
||||||
int updateThreshold;
|
int updateThreshold;
|
||||||
int maintanance;
|
int maintanance;
|
||||||
|
int httpPort;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
char dbHost[100+TB];
|
char dbHost[100+TB];
|
||||||
@ -66,6 +69,10 @@ struct cEPG2VDRConfig
|
|||||||
int mainmenuFullupdate;
|
int mainmenuFullupdate;
|
||||||
int masterMode;
|
int masterMode;
|
||||||
char uuid[sizeUuid+TB];
|
char uuid[sizeUuid+TB];
|
||||||
|
|
||||||
|
int scrapEpg;
|
||||||
|
int scrapRecordings;
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
extern cEPG2VDRConfig EPG2VDRConfig;
|
extern cEPG2VDRConfig EPG2VDRConfig;
|
||||||
|
122
lib/db.c
122
lib/db.c
@ -7,7 +7,7 @@
|
|||||||
|
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
|
|
||||||
#include <mysql/errmsg.h>
|
#include <errmsg.h>
|
||||||
|
|
||||||
#include "db.h"
|
#include "db.h"
|
||||||
|
|
||||||
@ -17,6 +17,8 @@
|
|||||||
// DB Statement
|
// DB Statement
|
||||||
//***************************************************************************
|
//***************************************************************************
|
||||||
|
|
||||||
|
int cDbStatement::explain = no;
|
||||||
|
|
||||||
cDbStatement::cDbStatement(cDbTable* aTable)
|
cDbStatement::cDbStatement(cDbTable* aTable)
|
||||||
{
|
{
|
||||||
table = aTable;
|
table = aTable;
|
||||||
@ -30,6 +32,14 @@ cDbStatement::cDbStatement(cDbTable* aTable)
|
|||||||
affected = 0;
|
affected = 0;
|
||||||
metaResult = 0;
|
metaResult = 0;
|
||||||
bindPrefix = 0;
|
bindPrefix = 0;
|
||||||
|
firstExec = yes;
|
||||||
|
|
||||||
|
callsPeriod = 0;
|
||||||
|
callsTotal = 0;
|
||||||
|
duration = 0;
|
||||||
|
|
||||||
|
if (connection)
|
||||||
|
connection->statements.append(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
cDbStatement::cDbStatement(cDbConnection* aConnection, const char* stmt)
|
cDbStatement::cDbStatement(cDbConnection* aConnection, const char* stmt)
|
||||||
@ -45,6 +55,22 @@ cDbStatement::cDbStatement(cDbConnection* aConnection, const char* stmt)
|
|||||||
affected = 0;
|
affected = 0;
|
||||||
metaResult = 0;
|
metaResult = 0;
|
||||||
bindPrefix = 0;
|
bindPrefix = 0;
|
||||||
|
firstExec = yes;
|
||||||
|
|
||||||
|
callsPeriod = 0;
|
||||||
|
callsTotal = 0;
|
||||||
|
duration = 0;
|
||||||
|
|
||||||
|
if (connection)
|
||||||
|
connection->statements.append(this);
|
||||||
|
}
|
||||||
|
|
||||||
|
cDbStatement::~cDbStatement()
|
||||||
|
{
|
||||||
|
if (connection)
|
||||||
|
connection->statements.remove(this);
|
||||||
|
|
||||||
|
clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
//***************************************************************************
|
//***************************************************************************
|
||||||
@ -61,11 +87,43 @@ int cDbStatement::execute(int noResult)
|
|||||||
if (!stmt)
|
if (!stmt)
|
||||||
return connection->errorSql(connection, "execute(missing statement)");
|
return connection->errorSql(connection, "execute(missing statement)");
|
||||||
|
|
||||||
|
// if (explain && firstExec)
|
||||||
|
// {
|
||||||
|
// firstExec = no;
|
||||||
|
|
||||||
|
// if (strstr(stmtTxt.c_str(), "select "))
|
||||||
|
// {
|
||||||
|
// MYSQL_RES* result;
|
||||||
|
// MYSQL_ROW row;
|
||||||
|
// string q = "explain " + stmtTxt;
|
||||||
|
|
||||||
|
// if (connection->query(q.c_str()) != success)
|
||||||
|
// connection->errorSql(connection, "explain ", 0);
|
||||||
|
// else if ((result = mysql_store_result(connection->getMySql())))
|
||||||
|
// {
|
||||||
|
// while ((row = mysql_fetch_row(result)))
|
||||||
|
// {
|
||||||
|
// tell(0, "EXPLAIN: %s) %s %s %s %s %s %s %s %s %s",
|
||||||
|
// row[0], row[1], row[2], row[3],
|
||||||
|
// row[4], row[5], row[6], row[7], row[8], row[9]);
|
||||||
|
// }
|
||||||
|
|
||||||
|
// mysql_free_result(result);
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
|
||||||
// tell(0, "execute %d [%s]", stmt, stmtTxt.c_str());
|
// tell(0, "execute %d [%s]", stmt, stmtTxt.c_str());
|
||||||
|
|
||||||
|
long start = usNow();
|
||||||
|
|
||||||
if (mysql_stmt_execute(stmt))
|
if (mysql_stmt_execute(stmt))
|
||||||
return connection->errorSql(connection, "execute(stmt_execute)", stmt, stmtTxt.c_str());
|
return connection->errorSql(connection, "execute(stmt_execute)", stmt, stmtTxt.c_str());
|
||||||
|
|
||||||
|
duration += usNow() - start;
|
||||||
|
callsPeriod++;
|
||||||
|
callsTotal++;
|
||||||
|
|
||||||
// out binding - if needed
|
// out binding - if needed
|
||||||
|
|
||||||
if (outCount && !noResult)
|
if (outCount && !noResult)
|
||||||
@ -270,7 +328,7 @@ int cDbStatement::appendBinding(cDbValue* value, BindType bt)
|
|||||||
if (!bindings)
|
if (!bindings)
|
||||||
*bindings = (MYSQL_BIND*)malloc(count * sizeof(MYSQL_BIND));
|
*bindings = (MYSQL_BIND*)malloc(count * sizeof(MYSQL_BIND));
|
||||||
else
|
else
|
||||||
*bindings = (MYSQL_BIND*)realloc(*bindings, count * sizeof(MYSQL_BIND));
|
*bindings = (MYSQL_BIND*)srealloc(*bindings, count * sizeof(MYSQL_BIND));
|
||||||
|
|
||||||
newBinding = &((*bindings)[count-1]);
|
newBinding = &((*bindings)[count-1]);
|
||||||
|
|
||||||
@ -360,6 +418,22 @@ int cDbStatement::prepare()
|
|||||||
return success;
|
return success;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//***************************************************************************
|
||||||
|
// Show Statistic
|
||||||
|
//***************************************************************************
|
||||||
|
|
||||||
|
void cDbStatement::showStat()
|
||||||
|
{
|
||||||
|
if (callsPeriod)
|
||||||
|
{
|
||||||
|
tell(0, "calls %4ld in %6.2fms; total %4ld [%s]",
|
||||||
|
callsPeriod, duration/1000, callsTotal, stmtTxt.c_str());
|
||||||
|
|
||||||
|
callsPeriod = 0;
|
||||||
|
duration = 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
//***************************************************************************
|
//***************************************************************************
|
||||||
// cDbService
|
// cDbService
|
||||||
//***************************************************************************
|
//***************************************************************************
|
||||||
@ -382,6 +456,50 @@ const char* cDbService::toString(FieldFormat t)
|
|||||||
return formats[t];
|
return formats[t];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const char* cDbService::dictFormats[] =
|
||||||
|
{
|
||||||
|
"int",
|
||||||
|
"uint",
|
||||||
|
"ascii",
|
||||||
|
"text",
|
||||||
|
"mlob",
|
||||||
|
"float",
|
||||||
|
"datetime",
|
||||||
|
|
||||||
|
0
|
||||||
|
};
|
||||||
|
|
||||||
|
cDbService::FieldFormat cDbService::toDictFormat(const char* format)
|
||||||
|
{
|
||||||
|
for (int i = 0; i < ffCount; i++)
|
||||||
|
if (strcasecmp(dictFormats[i], format) == 0)
|
||||||
|
return (FieldFormat)i;
|
||||||
|
|
||||||
|
return ffUnknown;
|
||||||
|
}
|
||||||
|
|
||||||
|
const char* cDbService::types[] =
|
||||||
|
{
|
||||||
|
"data",
|
||||||
|
"primary",
|
||||||
|
"meta",
|
||||||
|
"calc",
|
||||||
|
"autoinc",
|
||||||
|
|
||||||
|
0
|
||||||
|
};
|
||||||
|
|
||||||
|
cDbService::FieldType cDbService::toType(const char* type)
|
||||||
|
{
|
||||||
|
// #TODO !!!
|
||||||
|
|
||||||
|
for (int i = 0; i < 3; i++)
|
||||||
|
if (strcasecmp(types[i], type) == 0)
|
||||||
|
return (FieldType)i;
|
||||||
|
|
||||||
|
return ftUnknown;
|
||||||
|
}
|
||||||
|
|
||||||
//***************************************************************************
|
//***************************************************************************
|
||||||
// Class cDbTable
|
// Class cDbTable
|
||||||
//***************************************************************************
|
//***************************************************************************
|
||||||
|
72
lib/db.h
72
lib/db.h
@ -13,11 +13,11 @@
|
|||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <stdarg.h>
|
#include <stdarg.h>
|
||||||
#include <errno.h>
|
#include <errno.h>
|
||||||
|
|
||||||
#include <sstream>
|
|
||||||
|
|
||||||
#include <mysql/mysql.h>
|
#include <mysql/mysql.h>
|
||||||
|
|
||||||
|
#include <list>
|
||||||
|
#include <sstream>
|
||||||
|
|
||||||
#include "common.h"
|
#include "common.h"
|
||||||
|
|
||||||
class cDbTable;
|
class cDbTable;
|
||||||
@ -40,6 +40,8 @@ class cDbService
|
|||||||
|
|
||||||
enum FieldFormat
|
enum FieldFormat
|
||||||
{
|
{
|
||||||
|
ffUnknown = na,
|
||||||
|
|
||||||
ffInt,
|
ffInt,
|
||||||
ffUInt,
|
ffUInt,
|
||||||
ffAscii, // -> VARCHAR
|
ffAscii, // -> VARCHAR
|
||||||
@ -52,6 +54,8 @@ class cDbService
|
|||||||
|
|
||||||
enum FieldType
|
enum FieldType
|
||||||
{
|
{
|
||||||
|
ftUnknown = na,
|
||||||
|
|
||||||
ftData = 1,
|
ftData = 1,
|
||||||
ftPrimary = 2,
|
ftPrimary = 2,
|
||||||
ftMeta = 4,
|
ftMeta = 4,
|
||||||
@ -90,7 +94,12 @@ class cDbService
|
|||||||
};
|
};
|
||||||
|
|
||||||
static const char* toString(FieldFormat t);
|
static const char* toString(FieldFormat t);
|
||||||
|
static FieldFormat toDictFormat(const char* format);
|
||||||
static const char* formats[];
|
static const char* formats[];
|
||||||
|
static const char* dictFormats[];
|
||||||
|
|
||||||
|
static FieldType toType(const char* type);
|
||||||
|
static const char* types[];
|
||||||
};
|
};
|
||||||
|
|
||||||
typedef cDbService cDBS;
|
typedef cDbService cDBS;
|
||||||
@ -374,8 +383,7 @@ class cDbStatement : public cDbService
|
|||||||
|
|
||||||
cDbStatement(cDbTable* aTable);
|
cDbStatement(cDbTable* aTable);
|
||||||
cDbStatement(cDbConnection* aConnection, const char* stmt = "");
|
cDbStatement(cDbConnection* aConnection, const char* stmt = "");
|
||||||
|
virtual ~cDbStatement();
|
||||||
virtual ~cDbStatement() { clear(); }
|
|
||||||
|
|
||||||
int execute(int noResult = no);
|
int execute(int noResult = no);
|
||||||
int find();
|
int find();
|
||||||
@ -404,6 +412,12 @@ class cDbStatement : public cDbService
|
|||||||
int getResultCount();
|
int getResultCount();
|
||||||
const char* asText() { return stmtTxt.c_str(); }
|
const char* asText() { return stmtTxt.c_str(); }
|
||||||
|
|
||||||
|
void showStat();
|
||||||
|
|
||||||
|
// data
|
||||||
|
|
||||||
|
static int explain; // debug explain
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
||||||
void clear();
|
void clear();
|
||||||
@ -415,11 +429,49 @@ class cDbStatement : public cDbService
|
|||||||
cDbConnection* connection;
|
cDbConnection* connection;
|
||||||
cDbTable* table;
|
cDbTable* table;
|
||||||
int inCount;
|
int inCount;
|
||||||
MYSQL_BIND* inBind; // to db
|
MYSQL_BIND* inBind; // to db
|
||||||
int outCount;
|
int outCount;
|
||||||
MYSQL_BIND* outBind; // from db (result)
|
MYSQL_BIND* outBind; // from db (result)
|
||||||
MYSQL_RES* metaResult;
|
MYSQL_RES* metaResult;
|
||||||
const char* bindPrefix;
|
const char* bindPrefix;
|
||||||
|
int firstExec; // debug explain
|
||||||
|
|
||||||
|
unsigned long callsPeriod;
|
||||||
|
unsigned long callsTotal;
|
||||||
|
double duration;
|
||||||
|
};
|
||||||
|
|
||||||
|
//***************************************************************************
|
||||||
|
// cDbStatements
|
||||||
|
//***************************************************************************
|
||||||
|
|
||||||
|
class cDbStatements
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
|
||||||
|
cDbStatements() { statisticPeriod = time(0); }
|
||||||
|
~cDbStatements() {};
|
||||||
|
|
||||||
|
void append(cDbStatement* s) { statements.push_back(s); }
|
||||||
|
void remove(cDbStatement* s) { statements.remove(s); }
|
||||||
|
|
||||||
|
void showStat()
|
||||||
|
{
|
||||||
|
tell(0, "Statement statistic of last %ld seconds:", statisticPeriod);
|
||||||
|
|
||||||
|
for (std::list<cDbStatement*>::iterator it = statements.begin() ; it != statements.end(); ++it)
|
||||||
|
{
|
||||||
|
if (*it)
|
||||||
|
(*it)->showStat();
|
||||||
|
}
|
||||||
|
|
||||||
|
statisticPeriod = time(0);
|
||||||
|
}
|
||||||
|
|
||||||
|
private:
|
||||||
|
|
||||||
|
time_t statisticPeriod;
|
||||||
|
std::list<cDbStatement*> statements;
|
||||||
};
|
};
|
||||||
|
|
||||||
//***************************************************************************
|
//***************************************************************************
|
||||||
@ -628,7 +680,7 @@ class cDbConnection
|
|||||||
{
|
{
|
||||||
nread += res;
|
nread += res;
|
||||||
size += 1000;
|
size += 1000;
|
||||||
buffer = (char*)realloc(buffer, size+1);
|
buffer = srealloc(buffer, size+1);
|
||||||
}
|
}
|
||||||
|
|
||||||
fclose(f);
|
fclose(f);
|
||||||
@ -704,6 +756,8 @@ class cDbConnection
|
|||||||
|
|
||||||
int errorSql(cDbConnection* mysql, const char* prefix, MYSQL_STMT* stmt = 0, const char* stmtTxt = 0);
|
int errorSql(cDbConnection* mysql, const char* prefix, MYSQL_STMT* stmt = 0, const char* stmtTxt = 0);
|
||||||
|
|
||||||
|
void showStat() { statements.showStat(); }
|
||||||
|
|
||||||
static int init()
|
static int init()
|
||||||
{
|
{
|
||||||
if (mysql_library_init(0, 0, 0))
|
if (mysql_library_init(0, 0, 0))
|
||||||
@ -729,6 +783,8 @@ class cDbConnection
|
|||||||
|
|
||||||
MYSQL* mysql;
|
MYSQL* mysql;
|
||||||
|
|
||||||
|
cDbStatements statements; // all statements of this connection
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
||||||
int initialized;
|
int initialized;
|
||||||
|
@ -19,8 +19,8 @@ const char* cEpgdState::states[] =
|
|||||||
|
|
||||||
"busy (events)",
|
"busy (events)",
|
||||||
"busy (match)",
|
"busy (match)",
|
||||||
"busy (images)",
|
|
||||||
"busy (scraping)",
|
"busy (scraping)",
|
||||||
|
"busy (images)",
|
||||||
|
|
||||||
0
|
0
|
||||||
};
|
};
|
||||||
|
@ -26,14 +26,17 @@ class cEpgdState
|
|||||||
esStandby,
|
esStandby,
|
||||||
esStopped,
|
esStopped,
|
||||||
|
|
||||||
|
// handler pause on this states!
|
||||||
|
|
||||||
esBusy,
|
esBusy,
|
||||||
esBusyEvents = esBusy,
|
esBusyEvents = esBusy,
|
||||||
esBusyMatch,
|
esBusyMatch,
|
||||||
|
esBusyScraping,
|
||||||
|
|
||||||
|
// handler don't pause on this states!
|
||||||
|
|
||||||
esBusyImages,
|
esBusyImages,
|
||||||
|
|
||||||
esBusyScraping,
|
|
||||||
|
|
||||||
esCount
|
esCount
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -78,6 +81,7 @@ class cUpdateState
|
|||||||
|
|
||||||
static const char* getDeletable() { return "'A','L','P','R','I'"; }
|
static const char* getDeletable() { return "'A','L','P','R','I'"; }
|
||||||
static const char* getNeeded() { return "'A','L','P','C','D','R'"; }
|
static const char* getNeeded() { return "'A','L','P','C','D','R'"; }
|
||||||
|
static const char* getVisible() { return "'A','L','P'"; }
|
||||||
|
|
||||||
// checks fpr c++ code
|
// checks fpr c++ code
|
||||||
|
|
||||||
|
258
moviedbmovie.c
258
moviedbmovie.c
@ -1,130 +1,130 @@
|
|||||||
#define __STL_CONFIG_H
|
#define __STL_CONFIG_H
|
||||||
#include "lib/common.h"
|
#include "lib/common.h"
|
||||||
#include "moviedbmovie.h"
|
#include "moviedbmovie.h"
|
||||||
|
|
||||||
using namespace std;
|
using namespace std;
|
||||||
|
|
||||||
cMovieDbMovie::cMovieDbMovie(void) {
|
cMovieDbMovie::cMovieDbMovie(void) {
|
||||||
title = "";
|
title = "";
|
||||||
originalTitle = "";
|
originalTitle = "";
|
||||||
tagline = "";
|
tagline = "";
|
||||||
overview = "";
|
overview = "";
|
||||||
adult = false;
|
adult = false;
|
||||||
collectionID = 0;
|
collectionID = 0;
|
||||||
collectionName = "";
|
collectionName = "";
|
||||||
budget = 0;
|
budget = 0;
|
||||||
revenue = 0;
|
revenue = 0;
|
||||||
genres = "";
|
genres = "";
|
||||||
homepage = "";
|
homepage = "";
|
||||||
imdbid = "";
|
imdbid = "";
|
||||||
releaseDate = "";
|
releaseDate = "";
|
||||||
runtime = 0;
|
runtime = 0;
|
||||||
popularity = 0.0;
|
popularity = 0.0;
|
||||||
voteAverage = 0.0;
|
voteAverage = 0.0;
|
||||||
}
|
}
|
||||||
|
|
||||||
cMovieDbMovie::~cMovieDbMovie() {
|
cMovieDbMovie::~cMovieDbMovie() {
|
||||||
for (map<int, cMovieActor*>::iterator it = actors.begin(); it != actors.end(); it++) {
|
for (map<int, cMovieActor*>::iterator it = actors.begin(); it != actors.end(); it++) {
|
||||||
cMovieActor *a = (cMovieActor*)it->second;
|
cMovieActor *a = (cMovieActor*)it->second;
|
||||||
delete a;
|
delete a;
|
||||||
}
|
}
|
||||||
for (map<int, cMovieMedia*>::iterator it = medias.begin(); it != medias.end(); it++) {
|
for (map<int, cMovieMedia*>::iterator it = medias.begin(); it != medias.end(); it++) {
|
||||||
cMovieMedia *m = (cMovieMedia*)it->second;
|
cMovieMedia *m = (cMovieMedia*)it->second;
|
||||||
delete m;
|
delete m;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void cMovieDbMovie::InsertMedia(cMovieMedia *media) {
|
void cMovieDbMovie::InsertMedia(cMovieMedia *media) {
|
||||||
medias.insert(pair<int, cMovieMedia*>(media->mediaType, media));
|
medias.insert(pair<int, cMovieMedia*>(media->mediaType, media));
|
||||||
}
|
}
|
||||||
|
|
||||||
void cMovieDbMovie::InsertActor(cMovieActor *actor) {
|
void cMovieDbMovie::InsertActor(cMovieActor *actor) {
|
||||||
cMovieMedia *m = new cMovieMedia();
|
cMovieMedia *m = new cMovieMedia();
|
||||||
actor->actorThumb = m;
|
actor->actorThumb = m;
|
||||||
actors.insert(pair<int, cMovieActor*>(actor->id, actor));
|
actors.insert(pair<int, cMovieActor*>(actor->id, actor));
|
||||||
}
|
}
|
||||||
|
|
||||||
vector<int> cMovieDbMovie::GetActorIDs(void) {
|
vector<int> cMovieDbMovie::GetActorIDs(void) {
|
||||||
vector<int> IDs;
|
vector<int> IDs;
|
||||||
for (map<int, cMovieActor*>::iterator it = actors.begin(); it != actors.end(); it++) {
|
for (map<int, cMovieActor*>::iterator it = actors.begin(); it != actors.end(); it++) {
|
||||||
cMovieActor *a = it->second;
|
cMovieActor *a = it->second;
|
||||||
IDs.push_back(a->id);
|
IDs.push_back(a->id);
|
||||||
}
|
}
|
||||||
return IDs;
|
return IDs;
|
||||||
}
|
}
|
||||||
|
|
||||||
void cMovieDbMovie::SetActorThumbSize(int actorId, int imgWidth, int imgHeight) {
|
void cMovieDbMovie::SetActorThumbSize(int actorId, int imgWidth, int imgHeight) {
|
||||||
map<int, cMovieActor*>::iterator hit = actors.find(actorId);
|
map<int, cMovieActor*>::iterator hit = actors.find(actorId);
|
||||||
if (hit != actors.end()) {
|
if (hit != actors.end()) {
|
||||||
cMovieActor *a = hit->second;
|
cMovieActor *a = hit->second;
|
||||||
if (!a->actorThumb)
|
if (!a->actorThumb)
|
||||||
return;
|
return;
|
||||||
cMovieMedia *thumb = a->actorThumb;
|
cMovieMedia *thumb = a->actorThumb;
|
||||||
thumb->width = imgWidth;
|
thumb->width = imgWidth;
|
||||||
thumb->height = imgHeight;
|
thumb->height = imgHeight;
|
||||||
thumb->mediaType = mmActorThumb;
|
thumb->mediaType = mmActorThumb;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void cMovieDbMovie::SetActorPath(int actorId, string path) {
|
void cMovieDbMovie::SetActorPath(int actorId, string path) {
|
||||||
map<int, cMovieActor*>::iterator hit = actors.find(actorId);
|
map<int, cMovieActor*>::iterator hit = actors.find(actorId);
|
||||||
if (hit != actors.end()) {
|
if (hit != actors.end()) {
|
||||||
cMovieActor *a = hit->second;
|
cMovieActor *a = hit->second;
|
||||||
if (!a->actorThumb)
|
if (!a->actorThumb)
|
||||||
return;
|
return;
|
||||||
a->actorThumb->path = path;
|
a->actorThumb->path = path;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
bool cMovieDbMovie::GetMedia(mediaMovies mediatype, cTvMedia *p) {
|
bool cMovieDbMovie::GetMedia(mediaMovies mediatype, cTvMedia *p) {
|
||||||
map<int, cMovieMedia*>::iterator hit = medias.find(mediatype);
|
map<int, cMovieMedia*>::iterator hit = medias.find(mediatype);
|
||||||
if (hit == medias.end())
|
if (hit == medias.end())
|
||||||
return false;
|
return false;
|
||||||
cMovieMedia *pStored = hit->second;
|
cMovieMedia *pStored = hit->second;
|
||||||
p->path = pStored->path;
|
p->path = pStored->path;
|
||||||
p->width = pStored->width;
|
p->width = pStored->width;
|
||||||
p->height = pStored->height;
|
p->height = pStored->height;
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
void cMovieDbMovie::GetActors(vector<cActor> *a) {
|
void cMovieDbMovie::GetActors(vector<cActor> *a) {
|
||||||
for (map<int, cMovieActor*>::iterator it = actors.begin(); it != actors.end(); it++) {
|
for (map<int, cMovieActor*>::iterator it = actors.begin(); it != actors.end(); it++) {
|
||||||
cMovieActor *aStored = it->second;
|
cMovieActor *aStored = it->second;
|
||||||
cActor act;
|
cActor act;
|
||||||
act.name = aStored->name;
|
act.name = aStored->name;
|
||||||
act.role = aStored->role;
|
act.role = aStored->role;
|
||||||
if (aStored->actorThumb) {
|
if (aStored->actorThumb) {
|
||||||
act.actorThumb.width = aStored->actorThumb->width;
|
act.actorThumb.width = aStored->actorThumb->width;
|
||||||
act.actorThumb.height = aStored->actorThumb->height;
|
act.actorThumb.height = aStored->actorThumb->height;
|
||||||
act.actorThumb.path = aStored->actorThumb->path;
|
act.actorThumb.path = aStored->actorThumb->path;
|
||||||
}
|
}
|
||||||
a->push_back(act);
|
a->push_back(act);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void cMovieDbMovie::Dump(void) {
|
void cMovieDbMovie::Dump(void) {
|
||||||
tell(0, "--------------------------- Movie Info ----------------------------------");
|
tell(0, "--------------------------- Movie Info ----------------------------------");
|
||||||
tell(0, "title %s, ID: %d", title.c_str(), id);
|
tell(0, "title %s, ID: %d", title.c_str(), id);
|
||||||
tell(0, "Orig. Title: %s", originalTitle.c_str());
|
tell(0, "Orig. Title: %s", originalTitle.c_str());
|
||||||
tell(0, "Tagline: %s", tagline.c_str());
|
tell(0, "Tagline: %s", tagline.c_str());
|
||||||
tell(0, "Overview: %s", overview.c_str());
|
tell(0, "Overview: %s", overview.c_str());
|
||||||
tell(0, "Collection: %s", collectionName.c_str());
|
tell(0, "Collection: %s", collectionName.c_str());
|
||||||
tell(0, "Genre: %s", genres.c_str());
|
tell(0, "Genre: %s", genres.c_str());
|
||||||
tell(0, "Popularity: %f", popularity);
|
tell(0, "Popularity: %f", popularity);
|
||||||
tell(0, "--------------------------- Actors ----------------------------------");
|
tell(0, "--------------------------- Actors ----------------------------------");
|
||||||
for (map<int, cMovieActor*>::iterator it = actors.begin(); it != actors.end(); it++) {
|
for (map<int, cMovieActor*>::iterator it = actors.begin(); it != actors.end(); it++) {
|
||||||
cMovieActor *a = it->second;
|
cMovieActor *a = it->second;
|
||||||
tell(0, "Actor %d, Name: %s, Role %s", a->id, a->name.c_str(), a->role.c_str());
|
tell(0, "Actor %d, Name: %s, Role %s", a->id, a->name.c_str(), a->role.c_str());
|
||||||
if (a->actorThumb) {
|
if (a->actorThumb) {
|
||||||
tell(0, "thmbWidth %d, thmbHeight %d", a->actorThumb->width, a->actorThumb->height);
|
tell(0, "thmbWidth %d, thmbHeight %d", a->actorThumb->width, a->actorThumb->height);
|
||||||
tell(0, "Path %s", a->actorThumb->path.c_str());
|
tell(0, "Path %s", a->actorThumb->path.c_str());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
tell(0, "--------------------------- Media ----------------------------------");
|
tell(0, "--------------------------- Media ----------------------------------");
|
||||||
for (map<int, cMovieMedia*>::iterator it = medias.begin(); it != medias.end(); it++) {
|
for (map<int, cMovieMedia*>::iterator it = medias.begin(); it != medias.end(); it++) {
|
||||||
cMovieMedia *m = it->second;
|
cMovieMedia *m = it->second;
|
||||||
tell(0, "Media %d", m->mediaType);
|
tell(0, "Media %d", m->mediaType);
|
||||||
tell(0, "width %d, height %d", m->width, m->height);
|
tell(0, "width %d, height %d", m->width, m->height);
|
||||||
tell(0, "Path %s", m->path.c_str());
|
tell(0, "Path %s", m->path.c_str());
|
||||||
}
|
}
|
||||||
}
|
}
|
196
moviedbmovie.h
196
moviedbmovie.h
@ -1,98 +1,98 @@
|
|||||||
#ifndef __TVSCRAPER_MOVIEDBMOVIE_H
|
#ifndef __TVSCRAPER_MOVIEDBMOVIE_H
|
||||||
#define __TVSCRAPER_MOVIEDBMOVIE_H
|
#define __TVSCRAPER_MOVIEDBMOVIE_H
|
||||||
|
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
#include <string>
|
#include <string>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
#include <map>
|
#include <map>
|
||||||
#include <set>
|
#include <set>
|
||||||
#include <utility>
|
#include <utility>
|
||||||
#include <algorithm>
|
#include <algorithm>
|
||||||
#include "services.h"
|
#include "services.h"
|
||||||
|
|
||||||
using namespace std;
|
using namespace std;
|
||||||
|
|
||||||
enum mediaMovies {
|
enum mediaMovies {
|
||||||
mmPoster,
|
mmPoster,
|
||||||
mmFanart,
|
mmFanart,
|
||||||
mmCollectionPoster,
|
mmCollectionPoster,
|
||||||
mmCollectionFanart,
|
mmCollectionFanart,
|
||||||
mmActorThumb,
|
mmActorThumb,
|
||||||
mmPosterThumb,
|
mmPosterThumb,
|
||||||
};
|
};
|
||||||
|
|
||||||
// --- cMovieMedia -------------------------------------------------------------
|
// --- cMovieMedia -------------------------------------------------------------
|
||||||
class cMovieMedia {
|
class cMovieMedia {
|
||||||
public:
|
public:
|
||||||
cMovieMedia(void) {
|
cMovieMedia(void) {
|
||||||
path = "";
|
path = "";
|
||||||
mediaType = mmPoster;
|
mediaType = mmPoster;
|
||||||
width = 0;
|
width = 0;
|
||||||
height = 0;
|
height = 0;
|
||||||
};
|
};
|
||||||
~cMovieMedia(void) {
|
~cMovieMedia(void) {
|
||||||
};
|
};
|
||||||
string path;
|
string path;
|
||||||
int mediaType;
|
int mediaType;
|
||||||
int width;
|
int width;
|
||||||
int height;
|
int height;
|
||||||
};
|
};
|
||||||
|
|
||||||
// --- cMovieActor -------------------------------------------------------------
|
// --- cMovieActor -------------------------------------------------------------
|
||||||
class cMovieActor {
|
class cMovieActor {
|
||||||
public:
|
public:
|
||||||
cMovieActor(void) {
|
cMovieActor(void) {
|
||||||
id = 0;
|
id = 0;
|
||||||
name = "";
|
name = "";
|
||||||
role = "";
|
role = "";
|
||||||
actorThumb = NULL;
|
actorThumb = NULL;
|
||||||
};
|
};
|
||||||
~cMovieActor(void) {
|
~cMovieActor(void) {
|
||||||
if (actorThumb)
|
if (actorThumb)
|
||||||
delete actorThumb;
|
delete actorThumb;
|
||||||
};
|
};
|
||||||
int id;
|
int id;
|
||||||
string name;
|
string name;
|
||||||
string role;
|
string role;
|
||||||
cMovieMedia *actorThumb;
|
cMovieMedia *actorThumb;
|
||||||
};
|
};
|
||||||
|
|
||||||
// --- cMovieDbMovie -------------------------------------------------------------
|
// --- cMovieDbMovie -------------------------------------------------------------
|
||||||
|
|
||||||
class cMovieDbMovie {
|
class cMovieDbMovie {
|
||||||
private:
|
private:
|
||||||
map<int, cMovieActor*> actors;
|
map<int, cMovieActor*> actors;
|
||||||
map<int, cMovieMedia*> medias;
|
map<int, cMovieMedia*> medias;
|
||||||
public:
|
public:
|
||||||
cMovieDbMovie(void);
|
cMovieDbMovie(void);
|
||||||
virtual ~cMovieDbMovie(void);
|
virtual ~cMovieDbMovie(void);
|
||||||
int id;
|
int id;
|
||||||
string title;
|
string title;
|
||||||
string originalTitle;
|
string originalTitle;
|
||||||
string tagline;
|
string tagline;
|
||||||
string overview;
|
string overview;
|
||||||
bool adult;
|
bool adult;
|
||||||
int collectionID;
|
int collectionID;
|
||||||
string collectionName;
|
string collectionName;
|
||||||
int budget;
|
int budget;
|
||||||
int revenue;
|
int revenue;
|
||||||
string genres;
|
string genres;
|
||||||
string homepage;
|
string homepage;
|
||||||
string imdbid;
|
string imdbid;
|
||||||
string releaseDate;
|
string releaseDate;
|
||||||
int runtime;
|
int runtime;
|
||||||
float popularity;
|
float popularity;
|
||||||
float voteAverage;
|
float voteAverage;
|
||||||
void InsertActor(cMovieActor *actor);
|
void InsertActor(cMovieActor *actor);
|
||||||
void InsertMedia(cMovieMedia *media);
|
void InsertMedia(cMovieMedia *media);
|
||||||
vector<int> GetActorIDs(void);
|
vector<int> GetActorIDs(void);
|
||||||
void SetActorThumbSize(int actorId, int imgWidth, int imgHeight);
|
void SetActorThumbSize(int actorId, int imgWidth, int imgHeight);
|
||||||
void SetActorPath(int actorId, string path);
|
void SetActorPath(int actorId, string path);
|
||||||
//Getter for Serivice Calls
|
//Getter for Serivice Calls
|
||||||
bool GetMedia(mediaMovies mediatype, cTvMedia *p);
|
bool GetMedia(mediaMovies mediatype, cTvMedia *p);
|
||||||
void GetActors(vector<cActor> *a);
|
void GetActors(vector<cActor> *a);
|
||||||
void Dump();
|
void Dump();
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
#endif //__TVSCRAPER_TVDBSERIES_H
|
#endif //__TVSCRAPER_TVDBSERIES_H
|
||||||
|
114
scraper2vdr.h
114
scraper2vdr.h
@ -1,57 +1,57 @@
|
|||||||
#ifndef __SCRAPER2VDR_H
|
#ifndef __SCRAPER2VDR_H
|
||||||
#define __SCRAPER2VDR_H
|
#define __SCRAPER2VDR_H
|
||||||
|
|
||||||
#include <getopt.h>
|
#include <getopt.h>
|
||||||
#include <vdr/plugin.h>
|
#include <vdr/plugin.h>
|
||||||
#include "lib/common.h"
|
#include "lib/common.h"
|
||||||
#include "config.h"
|
#include "config.h"
|
||||||
#include "setup.h"
|
#include "setup.h"
|
||||||
#include "scrapmanager.h"
|
#include "scrapmanager.h"
|
||||||
#include "update.h"
|
#include "update.h"
|
||||||
#include "services.h"
|
#include "services.h"
|
||||||
|
|
||||||
//***************************************************************************
|
//***************************************************************************
|
||||||
// Constants
|
// Constants
|
||||||
//***************************************************************************
|
//***************************************************************************
|
||||||
static const char *VERSION = "0.1.1";
|
static const char *VERSION = "0.1.2";
|
||||||
static const char *DESCRIPTION = "'scraper2vdr' plugin";
|
static const char *DESCRIPTION = "'scraper2vdr' plugin";
|
||||||
static const char *MAINMENUENTRY = "Scraper2Vdr";
|
static const char *MAINMENUENTRY = "Scraper2Vdr";
|
||||||
|
|
||||||
//***************************************************************************
|
//***************************************************************************
|
||||||
// Globals
|
// Globals
|
||||||
//***************************************************************************
|
//***************************************************************************
|
||||||
cScraper2VdrConfig config;
|
cScraper2VdrConfig config;
|
||||||
|
|
||||||
//***************************************************************************
|
//***************************************************************************
|
||||||
// cPluginScraper2vdr
|
// cPluginScraper2vdr
|
||||||
//***************************************************************************
|
//***************************************************************************
|
||||||
|
|
||||||
class cPluginScraper2vdr : public cPlugin {
|
class cPluginScraper2vdr : public cPlugin {
|
||||||
private:
|
private:
|
||||||
cScrapManager *scrapManager;
|
cScrapManager *scrapManager;
|
||||||
cUpdate *update;
|
cUpdate *update;
|
||||||
public:
|
public:
|
||||||
cPluginScraper2vdr(void);
|
cPluginScraper2vdr(void);
|
||||||
virtual ~cPluginScraper2vdr();
|
virtual ~cPluginScraper2vdr();
|
||||||
virtual const char *Version(void) { return VERSION; }
|
virtual const char *Version(void) { return VERSION; }
|
||||||
virtual const char *Description(void) { return DESCRIPTION; }
|
virtual const char *Description(void) { return DESCRIPTION; }
|
||||||
virtual const char *CommandLineHelp(void);
|
virtual const char *CommandLineHelp(void);
|
||||||
virtual bool ProcessArgs(int argc, char *argv[]);
|
virtual bool ProcessArgs(int argc, char *argv[]);
|
||||||
virtual bool Initialize(void);
|
virtual bool Initialize(void);
|
||||||
virtual bool Start(void);
|
virtual bool Start(void);
|
||||||
virtual void Stop(void);
|
virtual void Stop(void);
|
||||||
virtual void Housekeeping(void);
|
virtual void Housekeeping(void);
|
||||||
virtual void MainThreadHook(void);
|
virtual void MainThreadHook(void);
|
||||||
virtual cString Active(void);
|
virtual cString Active(void);
|
||||||
virtual time_t WakeupTime(void);
|
virtual time_t WakeupTime(void);
|
||||||
virtual const char *MainMenuEntry(void) { return (config.mainMenuEntry)?MAINMENUENTRY:NULL; }
|
virtual const char *MainMenuEntry(void) { return (config.mainMenuEntry)?MAINMENUENTRY:NULL; }
|
||||||
virtual cOsdObject *MainMenuAction(void);
|
virtual cOsdObject *MainMenuAction(void);
|
||||||
virtual cMenuSetupPage *SetupMenu(void);
|
virtual cMenuSetupPage *SetupMenu(void);
|
||||||
virtual bool SetupParse(const char *Name, const char *Value);
|
virtual bool SetupParse(const char *Name, const char *Value);
|
||||||
virtual bool Service(const char *Id, void *Data = NULL);
|
virtual bool Service(const char *Id, void *Data = NULL);
|
||||||
virtual const char **SVDRPHelpPages(void);
|
virtual const char **SVDRPHelpPages(void);
|
||||||
virtual cString SVDRPCommand(const char *Command, const char *Option, int &ReplyCode);
|
virtual cString SVDRPCommand(const char *Command, const char *Option, int &ReplyCode);
|
||||||
};
|
};
|
||||||
|
|
||||||
//***************************************************************************
|
//***************************************************************************
|
||||||
#endif // __SCRAPER2VDR_H
|
#endif // __SCRAPER2VDR_H
|
||||||
|
1164
scrapmanager.c
1164
scrapmanager.c
File diff suppressed because it is too large
Load Diff
162
scrapmanager.h
162
scrapmanager.h
@ -1,81 +1,81 @@
|
|||||||
#ifndef __SCRAPMANAGER_H
|
#ifndef __SCRAPMANAGER_H
|
||||||
#define __SCRAPMANAGER_H
|
#define __SCRAPMANAGER_H
|
||||||
|
|
||||||
#include <vector>
|
#include <vector>
|
||||||
#include <map>
|
#include <map>
|
||||||
#include <set>
|
#include <set>
|
||||||
#include <utility>
|
#include <utility>
|
||||||
#include <algorithm>
|
#include <algorithm>
|
||||||
|
|
||||||
#include "lib/common.h"
|
#include "lib/common.h"
|
||||||
#include "lib/db.h"
|
#include "lib/db.h"
|
||||||
#include "lib/tabledef.h"
|
#include "lib/tabledef.h"
|
||||||
|
|
||||||
#include "services.h"
|
#include "services.h"
|
||||||
#include "tvdbseries.h"
|
#include "tvdbseries.h"
|
||||||
#include "moviedbmovie.h"
|
#include "moviedbmovie.h"
|
||||||
|
|
||||||
using namespace std;
|
using namespace std;
|
||||||
|
|
||||||
struct sEventsKey {
|
struct sEventsKey {
|
||||||
int eventId;
|
int eventId;
|
||||||
string channelId;
|
string channelId;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct sEventsValue {
|
struct sEventsValue {
|
||||||
int seriesId;
|
int seriesId;
|
||||||
int episodeId;
|
int episodeId;
|
||||||
int movieId;
|
int movieId;
|
||||||
bool isNew;
|
bool isNew;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct sRecordingsKey {
|
struct sRecordingsKey {
|
||||||
int recStart;
|
int recStart;
|
||||||
string recPath;
|
string recPath;
|
||||||
};
|
};
|
||||||
|
|
||||||
class cScrapManager {
|
class cScrapManager {
|
||||||
private:
|
private:
|
||||||
map<sEventsKey, sEventsValue> events;
|
map<sEventsKey, sEventsValue> events;
|
||||||
map<sEventsKey, sEventsValue>::iterator eventsIterator;
|
map<sEventsKey, sEventsValue>::iterator eventsIterator;
|
||||||
map<sRecordingsKey, sEventsValue> recordings;
|
map<sRecordingsKey, sEventsValue> recordings;
|
||||||
map<sRecordingsKey, sEventsValue>::iterator recIterator;
|
map<sRecordingsKey, sEventsValue>::iterator recIterator;
|
||||||
map<int, cTVDBSeries*> series;
|
map<int, cTVDBSeries*> series;
|
||||||
map<int, cMovieDbMovie*> movies;
|
map<int, cMovieDbMovie*> movies;
|
||||||
public:
|
public:
|
||||||
cScrapManager(void);
|
cScrapManager(void);
|
||||||
virtual ~cScrapManager(void);
|
virtual ~cScrapManager(void);
|
||||||
//Series and Movies Handling
|
//Series and Movies Handling
|
||||||
void AddEvent(int eventId, string channelId, int seriesId, int episodeId, int movieId);
|
void AddEvent(int eventId, string channelId, int seriesId, int episodeId, int movieId);
|
||||||
void InitIterator(bool isRec);
|
void InitIterator(bool isRec);
|
||||||
int GetNumSeries(void) { return series.size(); };
|
int GetNumSeries(void) { return series.size(); };
|
||||||
int GetNumMovies(void) { return movies.size(); };
|
int GetNumMovies(void) { return movies.size(); };
|
||||||
sEventsValue GetEventInformation(int eventId, string channelId);
|
sEventsValue GetEventInformation(int eventId, string channelId);
|
||||||
bool GetNextSeries(bool isRec, int &seriesId, int &episodeId);
|
bool GetNextSeries(bool isRec, int &seriesId, int &episodeId);
|
||||||
bool GetNextMovie(bool isRec, int &movieId);
|
bool GetNextMovie(bool isRec, int &movieId);
|
||||||
cTVDBSeries *GetSeries(int seriesId);
|
cTVDBSeries *GetSeries(int seriesId);
|
||||||
cMovieDbMovie *GetMovie(int movieId);
|
cMovieDbMovie *GetMovie(int movieId);
|
||||||
cTVDBSeries *AddSeries(cTableSeries* tSeries);
|
cTVDBSeries *AddSeries(cTableSeries* tSeries);
|
||||||
cMovieDbMovie *AddMovie(cTableMovies* tMovies);
|
cMovieDbMovie *AddMovie(cTableMovies* tMovies);
|
||||||
void AddSeriesEpisode(cTVDBSeries *series, cTableSeriesEpisode* tEpisodes);
|
void AddSeriesEpisode(cTVDBSeries *series, cTableSeriesEpisode* tEpisodes);
|
||||||
void AddSeriesActor(cTVDBSeries *series, cTableSeriesActor* tActors);
|
void AddSeriesActor(cTVDBSeries *series, cTableSeriesActor* tActors);
|
||||||
void AddMovieActor(cMovieDbMovie *movie, cTableMovieActor* tActor, string role);
|
void AddMovieActor(cMovieDbMovie *movie, cTableMovieActor* tActor, string role);
|
||||||
void AddMovieMedia(cMovieDbMovie *movie, cTableMovieMedia* tMovieMedia, string path);
|
void AddMovieMedia(cMovieDbMovie *movie, cTableMovieMedia* tMovieMedia, string path);
|
||||||
//Recording Handling
|
//Recording Handling
|
||||||
bool AddRecording(int recStart, string recPath, int seriesId, int episodeId, int movieId);
|
bool AddRecording(int recStart, string recPath, int seriesId, int episodeId, int movieId);
|
||||||
bool RecordingExists(int recStart, string recPath);
|
bool RecordingExists(int recStart, string recPath);
|
||||||
bool SeriesInUse(int seriesId);
|
bool SeriesInUse(int seriesId);
|
||||||
bool MovieInUse(int movieId);
|
bool MovieInUse(int movieId);
|
||||||
//Debug
|
//Debug
|
||||||
void DumpSeries(void);
|
void DumpSeries(void);
|
||||||
void DumpMovies(void);
|
void DumpMovies(void);
|
||||||
void DumpRecordings(void);
|
void DumpRecordings(void);
|
||||||
//Service Calls
|
//Service Calls
|
||||||
bool GetEventType(ScraperGetEventType *call);
|
bool GetEventType(ScraperGetEventType *call);
|
||||||
bool GetSeries(cSeries *series);
|
bool GetSeries(cSeries *series);
|
||||||
bool GetMovie(cMovie *movie);
|
bool GetMovie(cMovie *movie);
|
||||||
bool GetPosterBanner(ScraperGetPosterBanner *call);
|
bool GetPosterBanner(ScraperGetPosterBanner *call);
|
||||||
bool GetPoster(ScraperGetPoster *call);
|
bool GetPoster(ScraperGetPoster *call);
|
||||||
bool GetPosterThumb(ScraperGetPosterThumb *call);
|
bool GetPosterThumb(ScraperGetPosterThumb *call);
|
||||||
};
|
};
|
||||||
#endif //__SCRAPMANAGER_H
|
#endif //__SCRAPMANAGER_H
|
||||||
|
386
services.h
386
services.h
@ -1,194 +1,194 @@
|
|||||||
#ifndef __SCRAPER2VDRSERVICES_H
|
#ifndef __SCRAPER2VDRSERVICES_H
|
||||||
#define __SCRAPER2VDRSERVICES_H
|
#define __SCRAPER2VDRSERVICES_H
|
||||||
|
|
||||||
#include <vdr/epg.h>
|
#include <vdr/epg.h>
|
||||||
#include <vdr/recording.h>
|
#include <vdr/recording.h>
|
||||||
|
|
||||||
enum tvType {
|
enum tvType {
|
||||||
tSeries,
|
tSeries,
|
||||||
tMovie,
|
tMovie,
|
||||||
tNone,
|
tNone,
|
||||||
};
|
};
|
||||||
|
|
||||||
/*********************************************************************
|
/*********************************************************************
|
||||||
* Helper Structures
|
* Helper Structures
|
||||||
*********************************************************************/
|
*********************************************************************/
|
||||||
class cTvMedia {
|
class cTvMedia {
|
||||||
public:
|
public:
|
||||||
cTvMedia(void) {
|
cTvMedia(void) {
|
||||||
path = "";
|
path = "";
|
||||||
width = height = 0;
|
width = height = 0;
|
||||||
};
|
};
|
||||||
std::string path;
|
std::string path;
|
||||||
int width;
|
int width;
|
||||||
int height;
|
int height;
|
||||||
};
|
};
|
||||||
|
|
||||||
class cEpisode {
|
class cEpisode {
|
||||||
public:
|
public:
|
||||||
cEpisode(void) {
|
cEpisode(void) {
|
||||||
number = 0;
|
number = 0;
|
||||||
season = 0;
|
season = 0;
|
||||||
name = "";
|
name = "";
|
||||||
firstAired = "";
|
firstAired = "";
|
||||||
guestStars = "";
|
guestStars = "";
|
||||||
overview = "";
|
overview = "";
|
||||||
rating = 0.0;
|
rating = 0.0;
|
||||||
};
|
};
|
||||||
int number;
|
int number;
|
||||||
int season;
|
int season;
|
||||||
std::string name;
|
std::string name;
|
||||||
std::string firstAired;
|
std::string firstAired;
|
||||||
std::string guestStars;
|
std::string guestStars;
|
||||||
std::string overview;
|
std::string overview;
|
||||||
float rating;
|
float rating;
|
||||||
cTvMedia episodeImage;
|
cTvMedia episodeImage;
|
||||||
};
|
};
|
||||||
|
|
||||||
class cActor {
|
class cActor {
|
||||||
public:
|
public:
|
||||||
cActor(void) {
|
cActor(void) {
|
||||||
name = "";
|
name = "";
|
||||||
role = "";
|
role = "";
|
||||||
};
|
};
|
||||||
std::string name;
|
std::string name;
|
||||||
std::string role;
|
std::string role;
|
||||||
cTvMedia actorThumb;
|
cTvMedia actorThumb;
|
||||||
};
|
};
|
||||||
|
|
||||||
/*********************************************************************
|
/*********************************************************************
|
||||||
* Data Structures for Service Calls
|
* Data Structures for Service Calls
|
||||||
*********************************************************************/
|
*********************************************************************/
|
||||||
|
|
||||||
// Data structure for service "GetEventType"
|
// Data structure for service "GetEventType"
|
||||||
class ScraperGetEventType {
|
class ScraperGetEventType {
|
||||||
public:
|
public:
|
||||||
ScraperGetEventType(void) {
|
ScraperGetEventType(void) {
|
||||||
event = NULL;
|
event = NULL;
|
||||||
recording = NULL;
|
recording = NULL;
|
||||||
type = tNone;
|
type = tNone;
|
||||||
movieId = 0;
|
movieId = 0;
|
||||||
seriesId = 0;
|
seriesId = 0;
|
||||||
episodeId = 0;
|
episodeId = 0;
|
||||||
};
|
};
|
||||||
// in
|
// in
|
||||||
const cEvent *event; // check type for this event
|
const cEvent *event; // check type for this event
|
||||||
const cRecording *recording; // or for this recording
|
const cRecording *recording; // or for this recording
|
||||||
//out
|
//out
|
||||||
tvType type; //typeSeries or typeMovie
|
tvType type; //typeSeries or typeMovie
|
||||||
int movieId;
|
int movieId;
|
||||||
int seriesId;
|
int seriesId;
|
||||||
int episodeId;
|
int episodeId;
|
||||||
};
|
};
|
||||||
|
|
||||||
//Data structure for full series and episode information
|
//Data structure for full series and episode information
|
||||||
class cMovie {
|
class cMovie {
|
||||||
public:
|
public:
|
||||||
cMovie(void) {
|
cMovie(void) {
|
||||||
title = "";
|
title = "";
|
||||||
originalTitle = "";
|
originalTitle = "";
|
||||||
tagline = "";
|
tagline = "";
|
||||||
overview = "";
|
overview = "";
|
||||||
adult = false;
|
adult = false;
|
||||||
collectionName = "";
|
collectionName = "";
|
||||||
budget = 0;
|
budget = 0;
|
||||||
revenue = 0;
|
revenue = 0;
|
||||||
genres = "";
|
genres = "";
|
||||||
homepage = "";
|
homepage = "";
|
||||||
releaseDate = "";
|
releaseDate = "";
|
||||||
runtime = 0;
|
runtime = 0;
|
||||||
popularity = 0.0;
|
popularity = 0.0;
|
||||||
voteAverage = 0.0;
|
voteAverage = 0.0;
|
||||||
};
|
};
|
||||||
//IN
|
//IN
|
||||||
int movieId; // movieId fetched from ScraperGetEventType
|
int movieId; // movieId fetched from ScraperGetEventType
|
||||||
//OUT
|
//OUT
|
||||||
std::string title;
|
std::string title;
|
||||||
std::string originalTitle;
|
std::string originalTitle;
|
||||||
std::string tagline;
|
std::string tagline;
|
||||||
std::string overview;
|
std::string overview;
|
||||||
bool adult;
|
bool adult;
|
||||||
std::string collectionName;
|
std::string collectionName;
|
||||||
int budget;
|
int budget;
|
||||||
int revenue;
|
int revenue;
|
||||||
std::string genres;
|
std::string genres;
|
||||||
std::string homepage;
|
std::string homepage;
|
||||||
std::string releaseDate;
|
std::string releaseDate;
|
||||||
int runtime;
|
int runtime;
|
||||||
float popularity;
|
float popularity;
|
||||||
float voteAverage;
|
float voteAverage;
|
||||||
cTvMedia poster;
|
cTvMedia poster;
|
||||||
cTvMedia fanart;
|
cTvMedia fanart;
|
||||||
cTvMedia collectionPoster;
|
cTvMedia collectionPoster;
|
||||||
cTvMedia collectionFanart;
|
cTvMedia collectionFanart;
|
||||||
std::vector<cActor> actors;
|
std::vector<cActor> actors;
|
||||||
};
|
};
|
||||||
|
|
||||||
//Data structure for full series and episode information
|
//Data structure for full series and episode information
|
||||||
class cSeries {
|
class cSeries {
|
||||||
public:
|
public:
|
||||||
cSeries(void) {
|
cSeries(void) {
|
||||||
seriesId = 0;
|
seriesId = 0;
|
||||||
episodeId = 0;
|
episodeId = 0;
|
||||||
name = "";
|
name = "";
|
||||||
overview = "";
|
overview = "";
|
||||||
firstAired = "";
|
firstAired = "";
|
||||||
network = "";
|
network = "";
|
||||||
genre = "";
|
genre = "";
|
||||||
rating = 0.0;
|
rating = 0.0;
|
||||||
status = "";
|
status = "";
|
||||||
};
|
};
|
||||||
//IN
|
//IN
|
||||||
int seriesId; // seriesId fetched from ScraperGetEventType
|
int seriesId; // seriesId fetched from ScraperGetEventType
|
||||||
int episodeId; // episodeId fetched from ScraperGetEventType
|
int episodeId; // episodeId fetched from ScraperGetEventType
|
||||||
//OUT
|
//OUT
|
||||||
std::string name;
|
std::string name;
|
||||||
std::string overview;
|
std::string overview;
|
||||||
std::string firstAired;
|
std::string firstAired;
|
||||||
std::string network;
|
std::string network;
|
||||||
std::string genre;
|
std::string genre;
|
||||||
float rating;
|
float rating;
|
||||||
std::string status;
|
std::string status;
|
||||||
cEpisode episode;
|
cEpisode episode;
|
||||||
std::vector<cActor> actors;
|
std::vector<cActor> actors;
|
||||||
std::vector<cTvMedia> posters;
|
std::vector<cTvMedia> posters;
|
||||||
std::vector<cTvMedia> banners;
|
std::vector<cTvMedia> banners;
|
||||||
std::vector<cTvMedia> fanarts;
|
std::vector<cTvMedia> fanarts;
|
||||||
cTvMedia seasonPoster;
|
cTvMedia seasonPoster;
|
||||||
};
|
};
|
||||||
|
|
||||||
// Data structure for service "GetPosterBanner"
|
// Data structure for service "GetPosterBanner"
|
||||||
class ScraperGetPosterBanner {
|
class ScraperGetPosterBanner {
|
||||||
public:
|
public:
|
||||||
ScraperGetPosterBanner(void) {
|
ScraperGetPosterBanner(void) {
|
||||||
type = tNone;
|
type = tNone;
|
||||||
};
|
};
|
||||||
// in
|
// in
|
||||||
const cEvent *event; // check type for this event
|
const cEvent *event; // check type for this event
|
||||||
//out
|
//out
|
||||||
tvType type; //typeSeries or typeMovie
|
tvType type; //typeSeries or typeMovie
|
||||||
cTvMedia poster;
|
cTvMedia poster;
|
||||||
cTvMedia banner;
|
cTvMedia banner;
|
||||||
};
|
};
|
||||||
|
|
||||||
// Data structure for service "GetPoster"
|
// Data structure for service "GetPoster"
|
||||||
class ScraperGetPoster {
|
class ScraperGetPoster {
|
||||||
public:
|
public:
|
||||||
// in
|
// in
|
||||||
const cEvent *event; // check type for this event
|
const cEvent *event; // check type for this event
|
||||||
const cRecording *recording; // or for this recording
|
const cRecording *recording; // or for this recording
|
||||||
//out
|
//out
|
||||||
cTvMedia poster;
|
cTvMedia poster;
|
||||||
};
|
};
|
||||||
|
|
||||||
// Data structure for service "GetPosterThumb"
|
// Data structure for service "GetPosterThumb"
|
||||||
class ScraperGetPosterThumb {
|
class ScraperGetPosterThumb {
|
||||||
public:
|
public:
|
||||||
// in
|
// in
|
||||||
const cEvent *event; // check type for this event
|
const cEvent *event; // check type for this event
|
||||||
const cRecording *recording; // or for this recording
|
const cRecording *recording; // or for this recording
|
||||||
//out
|
//out
|
||||||
cTvMedia poster;
|
cTvMedia poster;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif //__SCRAPER2VDRSERVICES_H
|
#endif //__SCRAPER2VDRSERVICES_H
|
7
setup.c
7
setup.c
@ -1,3 +1,6 @@
|
|||||||
|
|
||||||
|
#include "lib/config.h"
|
||||||
|
|
||||||
#include "setup.h"
|
#include "setup.h"
|
||||||
|
|
||||||
extern cScraper2VdrConfig config;
|
extern cScraper2VdrConfig config;
|
||||||
@ -39,7 +42,7 @@ void cScraper2VdrSetup::Setup(void) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
eOSState cScraper2VdrSetup::ProcessKey(eKeys Key) {
|
eOSState cScraper2VdrSetup::ProcessKey(eKeys Key) {
|
||||||
bool hadSubMenu = HasSubMenu();
|
// bool hadSubMenu = HasSubMenu();
|
||||||
eOSState state = cMenuSetupPage::ProcessKey(Key);
|
eOSState state = cMenuSetupPage::ProcessKey(Key);
|
||||||
if (Key == kOk) {
|
if (Key == kOk) {
|
||||||
tmpConfig.mysqlHost = host;
|
tmpConfig.mysqlHost = host;
|
||||||
@ -77,4 +80,6 @@ void cScraper2VdrSetup::Store(void) {
|
|||||||
SetupStore("mysqlDBUser", tmpConfig.mysqlDBUser.c_str());
|
SetupStore("mysqlDBUser", tmpConfig.mysqlDBUser.c_str());
|
||||||
SetupStore("mysqlDBPass", tmpConfig.mysqlDBPass.c_str());
|
SetupStore("mysqlDBPass", tmpConfig.mysqlDBPass.c_str());
|
||||||
SetupStore("debug", tmpConfig.debug);
|
SetupStore("debug", tmpConfig.debug);
|
||||||
|
|
||||||
|
EPG2VDRConfig.loglevel = tmpConfig.debug ? 2 : 1;
|
||||||
}
|
}
|
||||||
|
358
tools.c
358
tools.c
@ -1,179 +1,179 @@
|
|||||||
#include <sys/stat.h>
|
#include <sys/stat.h>
|
||||||
#include <sys/types.h>
|
#include <sys/types.h>
|
||||||
#include <sys/vfs.h>
|
#include <sys/vfs.h>
|
||||||
#include <dirent.h>
|
#include <dirent.h>
|
||||||
#include <fstream>
|
#include <fstream>
|
||||||
#include <algorithm>
|
#include <algorithm>
|
||||||
#include <functional>
|
#include <functional>
|
||||||
#include <cctype>
|
#include <cctype>
|
||||||
#include <locale>
|
#include <locale>
|
||||||
#include <Magick++.h>
|
#include <Magick++.h>
|
||||||
#include <vdr/plugin.h>
|
#include <vdr/plugin.h>
|
||||||
#include "lib/common.h"
|
#include "lib/common.h"
|
||||||
#include "tools.h"
|
#include "tools.h"
|
||||||
|
|
||||||
using namespace std;
|
using namespace std;
|
||||||
using namespace Magick;
|
using namespace Magick;
|
||||||
|
|
||||||
bool CreateDirectory(string dir) {
|
bool CreateDirectory(string dir) {
|
||||||
mkdir(dir.c_str(), 0775);
|
mkdir(dir.c_str(), 0775);
|
||||||
//check if successfull
|
//check if successfull
|
||||||
DIR *pDir;
|
DIR *pDir;
|
||||||
bool exists = false;
|
bool exists = false;
|
||||||
pDir = opendir(dir.c_str());
|
pDir = opendir(dir.c_str());
|
||||||
if (pDir != NULL) {
|
if (pDir != NULL) {
|
||||||
exists = true;
|
exists = true;
|
||||||
closedir(pDir);
|
closedir(pDir);
|
||||||
}
|
}
|
||||||
return exists;
|
return exists;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool FileExists(string filename, bool isImage) {
|
bool FileExists(string filename, bool isImage) {
|
||||||
ifstream ifile(filename.c_str());
|
ifstream ifile(filename.c_str());
|
||||||
if (ifile) {
|
if (ifile) {
|
||||||
//a valid image should be larger then 500 bytes
|
//a valid image should be larger then 500 bytes
|
||||||
ifile.seekg (0, ifile.end);
|
ifile.seekg (0, ifile.end);
|
||||||
int length = ifile.tellg();
|
int length = ifile.tellg();
|
||||||
int minimumLength = isImage ? 500 : 1;
|
int minimumLength = isImage ? 500 : 1;
|
||||||
if (length > minimumLength)
|
if (length > minimumLength)
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool CheckDirExists(const char* dirName) {
|
bool CheckDirExists(const char* dirName) {
|
||||||
struct statfs statfsbuf;
|
struct statfs statfsbuf;
|
||||||
if (statfs(dirName,&statfsbuf)==-1) return false;
|
if (statfs(dirName,&statfsbuf)==-1) return false;
|
||||||
if ((statfsbuf.f_type!=0x01021994) && (statfsbuf.f_type!=0x28cd3d45)) return false;
|
if ((statfsbuf.f_type!=0x01021994) && (statfsbuf.f_type!=0x28cd3d45)) return false;
|
||||||
if (access(dirName,R_OK|W_OK)==-1) return false;
|
if (access(dirName,R_OK|W_OK)==-1) return false;
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void DeleteFile(string filename) {
|
void DeleteFile(string filename) {
|
||||||
remove(filename.c_str());
|
remove(filename.c_str());
|
||||||
}
|
}
|
||||||
|
|
||||||
void DeleteDirectory(string dirname) {
|
void DeleteDirectory(string dirname) {
|
||||||
DIR *dir;
|
DIR *dir;
|
||||||
struct dirent *entry;
|
struct dirent *entry;
|
||||||
if ((dir = opendir (dirname.c_str())) != NULL) {
|
if ((dir = opendir (dirname.c_str())) != NULL) {
|
||||||
while ((entry = readdir (dir)) != NULL) {
|
while ((entry = readdir (dir)) != NULL) {
|
||||||
string file = entry->d_name;
|
string file = entry->d_name;
|
||||||
if (!file.compare("."))
|
if (!file.compare("."))
|
||||||
continue;
|
continue;
|
||||||
if (!file.compare(".."))
|
if (!file.compare(".."))
|
||||||
continue;
|
continue;
|
||||||
string delFile = dirname + "/" + file;
|
string delFile = dirname + "/" + file;
|
||||||
DeleteFile(delFile);
|
DeleteFile(delFile);
|
||||||
}
|
}
|
||||||
closedir (dir);
|
closedir (dir);
|
||||||
}
|
}
|
||||||
rmdir(dirname.c_str());
|
rmdir(dirname.c_str());
|
||||||
}
|
}
|
||||||
|
|
||||||
string TwoFoldersHigher(string folder) {
|
string TwoFoldersHigher(string folder) {
|
||||||
unsigned found = folder.find_last_of("/");
|
unsigned found = folder.find_last_of("/");
|
||||||
if (found != string::npos) {
|
if (found != string::npos) {
|
||||||
string firstDirRemoved = folder.substr(0,found);
|
string firstDirRemoved = folder.substr(0,found);
|
||||||
unsigned found2 = firstDirRemoved.find_last_of("/");
|
unsigned found2 = firstDirRemoved.find_last_of("/");
|
||||||
if (found2 != string::npos) {
|
if (found2 != string::npos) {
|
||||||
return firstDirRemoved.substr(0,found2);
|
return firstDirRemoved.substr(0,found2);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return "";
|
return "";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// trim from start
|
// trim from start
|
||||||
string <rim(string &s) {
|
string <rim(string &s) {
|
||||||
s.erase(s.begin(), find_if(s.begin(), s.end(), not1(ptr_fun<int, int>(isspace))));
|
s.erase(s.begin(), find_if(s.begin(), s.end(), not1(ptr_fun<int, int>(isspace))));
|
||||||
return s;
|
return s;
|
||||||
}
|
}
|
||||||
|
|
||||||
// trim from end
|
// trim from end
|
||||||
string &rtrim(string &s) {
|
string &rtrim(string &s) {
|
||||||
s.erase(find_if(s.rbegin(), s.rend(), not1(ptr_fun<int, int>(isspace))).base(), s.end());
|
s.erase(find_if(s.rbegin(), s.rend(), not1(ptr_fun<int, int>(isspace))).base(), s.end());
|
||||||
return s;
|
return s;
|
||||||
}
|
}
|
||||||
|
|
||||||
// trim from both ends
|
// trim from both ends
|
||||||
string &trim(string &s) {
|
string &trim(string &s) {
|
||||||
return ltrim(rtrim(s));
|
return ltrim(rtrim(s));
|
||||||
}
|
}
|
||||||
|
|
||||||
void toLower(string &s) {
|
void toLower(string &s) {
|
||||||
transform(s.begin(), s.end(), s.begin(), ::tolower);
|
transform(s.begin(), s.end(), s.begin(), ::tolower);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool isNumber(const string& s) {
|
bool isNumber(const string& s) {
|
||||||
string::const_iterator it = s.begin();
|
string::const_iterator it = s.begin();
|
||||||
while (it != s.end() && isdigit(*it)) ++it;
|
while (it != s.end() && isdigit(*it)) ++it;
|
||||||
return !s.empty() && it == s.end();
|
return !s.empty() && it == s.end();
|
||||||
}
|
}
|
||||||
|
|
||||||
string replaceString(string content, string search, string repl) {
|
string replaceString(string content, string search, string repl) {
|
||||||
size_t pos = 0;
|
size_t pos = 0;
|
||||||
while((pos = content.find(search, pos)) != std::string::npos) {
|
while((pos = content.find(search, pos)) != std::string::npos) {
|
||||||
if (pos > 3 && pos < content.size() - 2) {
|
if (pos > 3 && pos < content.size() - 2) {
|
||||||
content.replace(pos, search.length(), repl);
|
content.replace(pos, search.length(), repl);
|
||||||
} else {
|
} else {
|
||||||
content.replace(pos, search.length(), "");
|
content.replace(pos, search.length(), "");
|
||||||
}
|
}
|
||||||
pos += repl.length();
|
pos += repl.length();
|
||||||
}
|
}
|
||||||
return content;
|
return content;
|
||||||
}
|
}
|
||||||
|
|
||||||
string getRecPath(const cRecording *rec) {
|
string getRecPath(const cRecording *rec) {
|
||||||
if (!rec)
|
if (!rec)
|
||||||
return "";
|
return "";
|
||||||
string recPath = rec->FileName();
|
string recPath = rec->FileName();
|
||||||
if (recPath.size() > 200)
|
if (recPath.size() > 200)
|
||||||
recPath = recPath.substr(0, 199);
|
recPath = recPath.substr(0, 199);
|
||||||
return recPath;
|
return recPath;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/****************************************************************************************
|
/****************************************************************************************
|
||||||
* SPLTSTRING
|
* SPLTSTRING
|
||||||
****************************************************************************************/
|
****************************************************************************************/
|
||||||
// split: receives a char delimiter; returns a vector of strings
|
// split: receives a char delimiter; returns a vector of strings
|
||||||
// By default ignores repeated delimiters, unless argument rep == 1.
|
// By default ignores repeated delimiters, unless argument rep == 1.
|
||||||
vector<string>& splitstring::split(char delim, int rep) {
|
vector<string>& splitstring::split(char delim, int rep) {
|
||||||
if (!flds.empty()) flds.clear(); // empty vector if necessary
|
if (!flds.empty()) flds.clear(); // empty vector if necessary
|
||||||
string work = data();
|
string work = data();
|
||||||
string buf = "";
|
string buf = "";
|
||||||
int i = 0;
|
unsigned int i = 0;
|
||||||
while (i < work.length()) {
|
while (i < work.length()) {
|
||||||
if (work[i] != delim)
|
if (work[i] != delim)
|
||||||
buf += work[i];
|
buf += work[i];
|
||||||
else if (rep == 1) {
|
else if (rep == 1) {
|
||||||
flds.push_back(buf);
|
flds.push_back(buf);
|
||||||
buf = "";
|
buf = "";
|
||||||
} else if (buf.length() > 0) {
|
} else if (buf.length() > 0) {
|
||||||
flds.push_back(buf);
|
flds.push_back(buf);
|
||||||
buf = "";
|
buf = "";
|
||||||
}
|
}
|
||||||
i++;
|
i++;
|
||||||
}
|
}
|
||||||
if (!buf.empty())
|
if (!buf.empty())
|
||||||
flds.push_back(buf);
|
flds.push_back(buf);
|
||||||
return flds;
|
return flds;
|
||||||
}
|
}
|
||||||
|
|
||||||
void CreateThumbnail(string sourcePath, string destPath, int origWidth, int origHeight, int shrinkFactor) {
|
void CreateThumbnail(string sourcePath, string destPath, int origWidth, int origHeight, int shrinkFactor) {
|
||||||
if (sourcePath.size() < 5 || destPath.size() < 5 || shrinkFactor < 2)
|
if (sourcePath.size() < 5 || destPath.size() < 5 || shrinkFactor < 2)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
int thumbWidth = origWidth / shrinkFactor;
|
int thumbWidth = origWidth / shrinkFactor;
|
||||||
int thumbHeight = origHeight / shrinkFactor;
|
int thumbHeight = origHeight / shrinkFactor;
|
||||||
|
|
||||||
InitializeMagick(NULL);
|
InitializeMagick(NULL);
|
||||||
Image buffer;
|
Image buffer;
|
||||||
try {
|
try {
|
||||||
buffer.read(sourcePath.c_str());
|
buffer.read(sourcePath.c_str());
|
||||||
buffer.sample(Geometry(thumbWidth, thumbHeight));
|
buffer.sample(Geometry(thumbWidth, thumbHeight));
|
||||||
buffer.write(destPath.c_str());
|
buffer.write(destPath.c_str());
|
||||||
} catch( ... ) {}
|
} catch( ... ) {}
|
||||||
}
|
}
|
||||||
|
62
tools.h
62
tools.h
@ -1,32 +1,32 @@
|
|||||||
#include <vector>
|
#include <vector>
|
||||||
#include <string>
|
#include <string>
|
||||||
|
|
||||||
using namespace std;
|
using namespace std;
|
||||||
|
|
||||||
//Filesystem Functions
|
//Filesystem Functions
|
||||||
bool CreateDirectory(string dir);
|
bool CreateDirectory(string dir);
|
||||||
bool FileExists(string filename, bool isImage = true);
|
bool FileExists(string filename, bool isImage = true);
|
||||||
bool CheckDirExists(const char* dirName);
|
bool CheckDirExists(const char* dirName);
|
||||||
void DeleteFile(string filename);
|
void DeleteFile(string filename);
|
||||||
void DeleteDirectory(string dirname);
|
void DeleteDirectory(string dirname);
|
||||||
string TwoFoldersHigher(string folder);
|
string TwoFoldersHigher(string folder);
|
||||||
|
|
||||||
//String Functions
|
//String Functions
|
||||||
string <rim(string &s);
|
string <rim(string &s);
|
||||||
string &rtrim(string &s);
|
string &rtrim(string &s);
|
||||||
string &trim(string &s);
|
string &trim(string &s);
|
||||||
void toLower(string &s);
|
void toLower(string &s);
|
||||||
bool isNumber(const string& s);
|
bool isNumber(const string& s);
|
||||||
string replaceString(string content, string search, string repl);
|
string replaceString(string content, string search, string repl);
|
||||||
|
|
||||||
string getRecPath(const cRecording *rec);
|
string getRecPath(const cRecording *rec);
|
||||||
|
|
||||||
class splitstring : public string {
|
class splitstring : public string {
|
||||||
vector<string> flds;
|
vector<string> flds;
|
||||||
public:
|
public:
|
||||||
splitstring(const char *s) : string(s) { };
|
splitstring(const char *s) : string(s) { };
|
||||||
vector<string>& split(char delim, int rep=0);
|
vector<string>& split(char delim, int rep=0);
|
||||||
};
|
};
|
||||||
|
|
||||||
//Image Functions
|
//Image Functions
|
||||||
void CreateThumbnail(string sourcePath, string destPath, int origWidth, int origHeight, int shrinkFactor);
|
void CreateThumbnail(string sourcePath, string destPath, int origWidth, int origHeight, int shrinkFactor);
|
578
tvdbseries.c
578
tvdbseries.c
@ -1,289 +1,289 @@
|
|||||||
#define __STL_CONFIG_H
|
#define __STL_CONFIG_H
|
||||||
#include "lib/common.h"
|
#include "lib/common.h"
|
||||||
#include "tvdbseries.h"
|
#include "tvdbseries.h"
|
||||||
|
|
||||||
using namespace std;
|
using namespace std;
|
||||||
|
|
||||||
cTVDBSeries::cTVDBSeries(void) {
|
cTVDBSeries::cTVDBSeries(void) {
|
||||||
id = 0;
|
id = 0;
|
||||||
name = "";
|
name = "";
|
||||||
overview = "";
|
overview = "";
|
||||||
firstAired = "";
|
firstAired = "";
|
||||||
network = "";
|
network = "";
|
||||||
genre = "";
|
genre = "";
|
||||||
rating = 0.0;
|
rating = 0.0;
|
||||||
status = "";
|
status = "";
|
||||||
posterThumb = NULL;
|
posterThumb = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
cTVDBSeries::~cTVDBSeries() {
|
cTVDBSeries::~cTVDBSeries() {
|
||||||
for (map<int, cTVDBActor*>::iterator it = actors.begin(); it != actors.end(); it++) {
|
for (map<int, cTVDBActor*>::iterator it = actors.begin(); it != actors.end(); it++) {
|
||||||
cTVDBActor *a = (cTVDBActor*)it->second;
|
cTVDBActor *a = (cTVDBActor*)it->second;
|
||||||
delete a;
|
delete a;
|
||||||
}
|
}
|
||||||
for (map<int, cTVDBEpisode*>::iterator it = episodes.begin(); it != episodes.end(); it++) {
|
for (map<int, cTVDBEpisode*>::iterator it = episodes.begin(); it != episodes.end(); it++) {
|
||||||
cTVDBEpisode *e = (cTVDBEpisode*)it->second;
|
cTVDBEpisode *e = (cTVDBEpisode*)it->second;
|
||||||
delete e;
|
delete e;
|
||||||
}
|
}
|
||||||
for (vector<cTVDBMedia*>::iterator it = posters.begin(); it != posters.end(); it++) {
|
for (vector<cTVDBMedia*>::iterator it = posters.begin(); it != posters.end(); it++) {
|
||||||
cTVDBMedia *p = *it;
|
cTVDBMedia *p = *it;
|
||||||
delete p;
|
delete p;
|
||||||
}
|
}
|
||||||
for (vector<cTVDBMedia*>::iterator it = banners.begin(); it != banners.end(); it++) {
|
for (vector<cTVDBMedia*>::iterator it = banners.begin(); it != banners.end(); it++) {
|
||||||
cTVDBMedia *b = *it;
|
cTVDBMedia *b = *it;
|
||||||
delete b;
|
delete b;
|
||||||
}
|
}
|
||||||
for (vector<cTVDBMedia*>::iterator it = fanart.begin(); it != fanart.end(); it++) {
|
for (vector<cTVDBMedia*>::iterator it = fanart.begin(); it != fanart.end(); it++) {
|
||||||
cTVDBMedia *f = *it;
|
cTVDBMedia *f = *it;
|
||||||
delete f;
|
delete f;
|
||||||
}
|
}
|
||||||
for (map<int, cTVDBMedia*>::iterator it = seasonPosters.begin(); it != seasonPosters.end(); it++) {
|
for (map<int, cTVDBMedia*>::iterator it = seasonPosters.begin(); it != seasonPosters.end(); it++) {
|
||||||
cTVDBMedia *s = (cTVDBMedia*)it->second;
|
cTVDBMedia *s = (cTVDBMedia*)it->second;
|
||||||
delete s;
|
delete s;
|
||||||
}
|
}
|
||||||
for (map<int, cTVDBMedia*>::iterator it = seasonPosterThumbs.begin(); it != seasonPosterThumbs.end(); it++) {
|
for (map<int, cTVDBMedia*>::iterator it = seasonPosterThumbs.begin(); it != seasonPosterThumbs.end(); it++) {
|
||||||
cTVDBMedia *s = (cTVDBMedia*)it->second;
|
cTVDBMedia *s = (cTVDBMedia*)it->second;
|
||||||
delete s;
|
delete s;
|
||||||
}
|
}
|
||||||
if (posterThumb)
|
if (posterThumb)
|
||||||
delete posterThumb;
|
delete posterThumb;
|
||||||
}
|
}
|
||||||
|
|
||||||
void cTVDBSeries::InsertEpisode(cTVDBEpisode *episode) {
|
void cTVDBSeries::InsertEpisode(cTVDBEpisode *episode) {
|
||||||
map<int, cTVDBEpisode*>::iterator hit = episodes.find(episode->id);
|
map<int, cTVDBEpisode*>::iterator hit = episodes.find(episode->id);
|
||||||
if (hit != episodes.end())
|
if (hit != episodes.end())
|
||||||
delete episode;
|
delete episode;
|
||||||
else
|
else
|
||||||
episodes.insert(pair<int, cTVDBEpisode*>(episode->id, episode));
|
episodes.insert(pair<int, cTVDBEpisode*>(episode->id, episode));
|
||||||
}
|
}
|
||||||
|
|
||||||
void cTVDBSeries::InsertEpisodeImage(int episodeId, int width, int height, string path) {
|
void cTVDBSeries::InsertEpisodeImage(int episodeId, int width, int height, string path) {
|
||||||
map<int, cTVDBEpisode*>::iterator hit = episodes.find(episodeId);
|
map<int, cTVDBEpisode*>::iterator hit = episodes.find(episodeId);
|
||||||
if (hit != episodes.end()) {
|
if (hit != episodes.end()) {
|
||||||
cTVDBEpisode *e = hit->second;
|
cTVDBEpisode *e = hit->second;
|
||||||
cTVDBMedia *m = new cTVDBMedia();
|
cTVDBMedia *m = new cTVDBMedia();
|
||||||
m->width = width;
|
m->width = width;
|
||||||
m->height = height;
|
m->height = height;
|
||||||
m->path = path;
|
m->path = path;
|
||||||
m->mediaType = msEpisodePic;
|
m->mediaType = msEpisodePic;
|
||||||
e->episodeImage = m;
|
e->episodeImage = m;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void cTVDBSeries::InsertActor(cTVDBActor *actor) {
|
void cTVDBSeries::InsertActor(cTVDBActor *actor) {
|
||||||
actors.insert(pair<int, cTVDBActor*>(actor->id, actor));
|
actors.insert(pair<int, cTVDBActor*>(actor->id, actor));
|
||||||
}
|
}
|
||||||
|
|
||||||
void cTVDBSeries::InsertActorThumb(int actorId, int imgWidth, int imgHeight, string path) {
|
void cTVDBSeries::InsertActorThumb(int actorId, int imgWidth, int imgHeight, string path) {
|
||||||
map<int, cTVDBActor*>::iterator hit = actors.find(actorId);
|
map<int, cTVDBActor*>::iterator hit = actors.find(actorId);
|
||||||
if (hit != actors.end()) {
|
if (hit != actors.end()) {
|
||||||
cTVDBActor *a = hit->second;
|
cTVDBActor *a = hit->second;
|
||||||
cTVDBMedia *m = new cTVDBMedia();
|
cTVDBMedia *m = new cTVDBMedia();
|
||||||
m->width = imgWidth;
|
m->width = imgWidth;
|
||||||
m->height = imgHeight;
|
m->height = imgHeight;
|
||||||
m->path = path;
|
m->path = path;
|
||||||
m->mediaType = msActorThumb;
|
m->mediaType = msActorThumb;
|
||||||
a->actorThumb = m;
|
a->actorThumb = m;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void cTVDBSeries::InsertMedia(int mediaType, int imgWidth, int imgHeight, string path, int season) {
|
void cTVDBSeries::InsertMedia(int mediaType, int imgWidth, int imgHeight, string path, int season) {
|
||||||
cTVDBMedia *media = new cTVDBMedia();
|
cTVDBMedia *media = new cTVDBMedia();
|
||||||
media->width = imgWidth;
|
media->width = imgWidth;
|
||||||
media->height = imgHeight;
|
media->height = imgHeight;
|
||||||
media->path = path;
|
media->path = path;
|
||||||
media->mediaType = mediaType;
|
media->mediaType = mediaType;
|
||||||
switch (mediaType) {
|
switch (mediaType) {
|
||||||
case msPoster1:
|
case msPoster1:
|
||||||
case msPoster2:
|
case msPoster2:
|
||||||
case msPoster3:
|
case msPoster3:
|
||||||
posters.push_back(media);
|
posters.push_back(media);
|
||||||
break;
|
break;
|
||||||
case msFanart1:
|
case msFanart1:
|
||||||
case msFanart2:
|
case msFanart2:
|
||||||
case msFanart3:
|
case msFanart3:
|
||||||
fanart.push_back(media);
|
fanart.push_back(media);
|
||||||
break;
|
break;
|
||||||
case msBanner1:
|
case msBanner1:
|
||||||
case msBanner2:
|
case msBanner2:
|
||||||
case msBanner3:
|
case msBanner3:
|
||||||
banners.push_back(media);
|
banners.push_back(media);
|
||||||
case msSeasonPoster:
|
case msSeasonPoster:
|
||||||
seasonPosters.insert(pair<int, cTVDBMedia*>(season, media));
|
seasonPosters.insert(pair<int, cTVDBMedia*>(season, media));
|
||||||
break;
|
break;
|
||||||
case msPosterThumb:
|
case msPosterThumb:
|
||||||
posterThumb = media;
|
posterThumb = media;
|
||||||
break;
|
break;
|
||||||
case msSeasonPosterThumb:
|
case msSeasonPosterThumb:
|
||||||
seasonPosterThumbs.insert(pair<int, cTVDBMedia*>(season, media));
|
seasonPosterThumbs.insert(pair<int, cTVDBMedia*>(season, media));
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void cTVDBSeries::GetEpisode(int episodeId, cEpisode *e) {
|
void cTVDBSeries::GetEpisode(int episodeId, cEpisode *e) {
|
||||||
map<int, cTVDBEpisode*>::iterator hit = episodes.find(episodeId);
|
map<int, cTVDBEpisode*>::iterator hit = episodes.find(episodeId);
|
||||||
if (hit == episodes.end())
|
if (hit == episodes.end())
|
||||||
return;
|
return;
|
||||||
cTVDBEpisode *eStored = hit->second;
|
cTVDBEpisode *eStored = hit->second;
|
||||||
e->number = eStored->number;
|
e->number = eStored->number;
|
||||||
e->season = eStored->season;
|
e->season = eStored->season;
|
||||||
e->name = eStored->name;
|
e->name = eStored->name;
|
||||||
e->firstAired = eStored->firstAired;
|
e->firstAired = eStored->firstAired;
|
||||||
e->guestStars = eStored->guestStars;
|
e->guestStars = eStored->guestStars;
|
||||||
e->overview = eStored->overview;
|
e->overview = eStored->overview;
|
||||||
e->rating = eStored->rating;
|
e->rating = eStored->rating;
|
||||||
if (eStored->episodeImage) {
|
if (eStored->episodeImage) {
|
||||||
e->episodeImage.path = eStored->episodeImage->path;
|
e->episodeImage.path = eStored->episodeImage->path;
|
||||||
e->episodeImage.width = eStored->episodeImage->width;
|
e->episodeImage.width = eStored->episodeImage->width;
|
||||||
e->episodeImage.height = eStored->episodeImage->height;
|
e->episodeImage.height = eStored->episodeImage->height;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void cTVDBSeries::GetPosters(vector<cTvMedia> *p) {
|
void cTVDBSeries::GetPosters(vector<cTvMedia> *p) {
|
||||||
for (vector<cTVDBMedia*>::iterator it = posters.begin(); it != posters.end(); it++) {
|
for (vector<cTVDBMedia*>::iterator it = posters.begin(); it != posters.end(); it++) {
|
||||||
cTVDBMedia *mStored = *it;
|
cTVDBMedia *mStored = *it;
|
||||||
cTvMedia m;
|
cTvMedia m;
|
||||||
m.path = mStored->path;
|
m.path = mStored->path;
|
||||||
m.width = mStored->width;
|
m.width = mStored->width;
|
||||||
m.height = mStored->height;
|
m.height = mStored->height;
|
||||||
p->push_back(m);
|
p->push_back(m);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
bool cTVDBSeries::GetPoster(cTvMedia *p) {
|
bool cTVDBSeries::GetPoster(cTvMedia *p) {
|
||||||
if (posters.size() > 0) {
|
if (posters.size() > 0) {
|
||||||
p->path = posters[0]->path;
|
p->path = posters[0]->path;
|
||||||
p->width = posters[0]->width;
|
p->width = posters[0]->width;
|
||||||
p->height = posters[0]->height;
|
p->height = posters[0]->height;
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool cTVDBSeries::GetPosterThumb(cTvMedia *p) {
|
bool cTVDBSeries::GetPosterThumb(cTvMedia *p) {
|
||||||
if (posterThumb) {
|
if (posterThumb) {
|
||||||
p->path = posterThumb->path;
|
p->path = posterThumb->path;
|
||||||
p->width = posterThumb->width;
|
p->width = posterThumb->width;
|
||||||
p->height = posterThumb->height;
|
p->height = posterThumb->height;
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
void cTVDBSeries::GetBanners(vector<cTvMedia> *b) {
|
void cTVDBSeries::GetBanners(vector<cTvMedia> *b) {
|
||||||
for (vector<cTVDBMedia*>::iterator it = banners.begin(); it != banners.end(); it++) {
|
for (vector<cTVDBMedia*>::iterator it = banners.begin(); it != banners.end(); it++) {
|
||||||
cTVDBMedia *bStored = *it;
|
cTVDBMedia *bStored = *it;
|
||||||
cTvMedia m;
|
cTvMedia m;
|
||||||
m.path = bStored->path;
|
m.path = bStored->path;
|
||||||
m.width = bStored->width;
|
m.width = bStored->width;
|
||||||
m.height = bStored->height;
|
m.height = bStored->height;
|
||||||
b->push_back(m);
|
b->push_back(m);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
bool cTVDBSeries::GetRandomBanner(cTvMedia *b) {
|
bool cTVDBSeries::GetRandomBanner(cTvMedia *b) {
|
||||||
int numBanners = banners.size();
|
int numBanners = banners.size();
|
||||||
if (numBanners == 0)
|
if (numBanners == 0)
|
||||||
return false;
|
return false;
|
||||||
srand((unsigned)time(NULL));
|
srand((unsigned)time(NULL));
|
||||||
int banner = rand()%numBanners;
|
int banner = rand()%numBanners;
|
||||||
cTVDBMedia *bStored = banners[banner];
|
cTVDBMedia *bStored = banners[banner];
|
||||||
b->path = bStored->path;
|
b->path = bStored->path;
|
||||||
b->width = bStored->width;
|
b->width = bStored->width;
|
||||||
b->height = bStored->height;
|
b->height = bStored->height;
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
void cTVDBSeries::GetFanart(vector<cTvMedia> *f) {
|
void cTVDBSeries::GetFanart(vector<cTvMedia> *f) {
|
||||||
for (vector<cTVDBMedia*>::iterator it = fanart.begin(); it != fanart.end(); it++) {
|
for (vector<cTVDBMedia*>::iterator it = fanart.begin(); it != fanart.end(); it++) {
|
||||||
cTVDBMedia *fStored = *it;
|
cTVDBMedia *fStored = *it;
|
||||||
cTvMedia m;
|
cTvMedia m;
|
||||||
m.path = fStored->path;
|
m.path = fStored->path;
|
||||||
m.width = fStored->width;
|
m.width = fStored->width;
|
||||||
m.height = fStored->height;
|
m.height = fStored->height;
|
||||||
f->push_back(m);
|
f->push_back(m);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void cTVDBSeries::GetSeasonPoster(int episodeId, cTvMedia *sp) {
|
void cTVDBSeries::GetSeasonPoster(int episodeId, cTvMedia *sp) {
|
||||||
map<int, cTVDBEpisode*>::iterator hit = episodes.find(episodeId);
|
map<int, cTVDBEpisode*>::iterator hit = episodes.find(episodeId);
|
||||||
if (hit == episodes.end())
|
if (hit == episodes.end())
|
||||||
return;
|
return;
|
||||||
cTVDBEpisode *e = hit->second;
|
cTVDBEpisode *e = hit->second;
|
||||||
map<int, cTVDBMedia*>::iterator hit2 = seasonPosters.find(e->season);
|
map<int, cTVDBMedia*>::iterator hit2 = seasonPosters.find(e->season);
|
||||||
if (hit2 == seasonPosters.end())
|
if (hit2 == seasonPosters.end())
|
||||||
return;
|
return;
|
||||||
cTVDBMedia *spStored = hit2->second;
|
cTVDBMedia *spStored = hit2->second;
|
||||||
sp->width = spStored->width;
|
sp->width = spStored->width;
|
||||||
sp->height = spStored->height;
|
sp->height = spStored->height;
|
||||||
sp->path = spStored->path;
|
sp->path = spStored->path;
|
||||||
}
|
}
|
||||||
|
|
||||||
void cTVDBSeries::GetActors(vector<cActor> *a) {
|
void cTVDBSeries::GetActors(vector<cActor> *a) {
|
||||||
for (map<int, cTVDBActor*>::iterator it = actors.begin(); it != actors.end(); it++) {
|
for (map<int, cTVDBActor*>::iterator it = actors.begin(); it != actors.end(); it++) {
|
||||||
cTVDBActor *aStored = it->second;
|
cTVDBActor *aStored = it->second;
|
||||||
cActor act;
|
cActor act;
|
||||||
act.name = aStored->name;
|
act.name = aStored->name;
|
||||||
act.role = aStored->role;
|
act.role = aStored->role;
|
||||||
if (aStored->actorThumb) {
|
if (aStored->actorThumb) {
|
||||||
act.actorThumb.width = aStored->actorThumb->width;
|
act.actorThumb.width = aStored->actorThumb->width;
|
||||||
act.actorThumb.height = aStored->actorThumb->height;
|
act.actorThumb.height = aStored->actorThumb->height;
|
||||||
act.actorThumb.path = aStored->actorThumb->path;
|
act.actorThumb.path = aStored->actorThumb->path;
|
||||||
}
|
}
|
||||||
a->push_back(act);
|
a->push_back(act);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void cTVDBSeries::Dump(void) {
|
void cTVDBSeries::Dump(void) {
|
||||||
tell(0, "--------------------------- Series Info ----------------------------------");
|
tell(0, "--------------------------- Series Info ----------------------------------");
|
||||||
tell(0, "series %s, ID: %d", name.c_str(), id);
|
tell(0, "series %s, ID: %d", name.c_str(), id);
|
||||||
tell(0, "Overview: %s", overview.c_str());
|
tell(0, "Overview: %s", overview.c_str());
|
||||||
tell(0, "FirstAired: %s", firstAired.c_str());
|
tell(0, "FirstAired: %s", firstAired.c_str());
|
||||||
tell(0, "Network: %s", network.c_str());
|
tell(0, "Network: %s", network.c_str());
|
||||||
tell(0, "Status: %s", status.c_str());
|
tell(0, "Status: %s", status.c_str());
|
||||||
tell(0, "Genre: %s", genre.c_str());
|
tell(0, "Genre: %s", genre.c_str());
|
||||||
tell(0, "Rating: %f", rating);
|
tell(0, "Rating: %f", rating);
|
||||||
tell(0, "--------------------------- Media ----------------------------------");
|
tell(0, "--------------------------- Media ----------------------------------");
|
||||||
for (vector<cTVDBMedia*>::iterator it = posters.begin(); it != posters.end(); it++) {
|
for (vector<cTVDBMedia*>::iterator it = posters.begin(); it != posters.end(); it++) {
|
||||||
cTVDBMedia *m = *it;
|
cTVDBMedia *m = *it;
|
||||||
tell(0, "Poster %d, Path: %s", m->mediaType, m->path.c_str());
|
tell(0, "Poster %d, Path: %s", m->mediaType, m->path.c_str());
|
||||||
tell(0, "width %d, height %d", m->width, m->height);
|
tell(0, "width %d, height %d", m->width, m->height);
|
||||||
}
|
}
|
||||||
for (vector<cTVDBMedia*>::iterator it = banners.begin(); it != banners.end(); it++) {
|
for (vector<cTVDBMedia*>::iterator it = banners.begin(); it != banners.end(); it++) {
|
||||||
cTVDBMedia *m = *it;
|
cTVDBMedia *m = *it;
|
||||||
tell(0, "Banner %d, Path: %s", m->mediaType, m->path.c_str());
|
tell(0, "Banner %d, Path: %s", m->mediaType, m->path.c_str());
|
||||||
tell(0, "width %d, height %d", m->width, m->height);
|
tell(0, "width %d, height %d", m->width, m->height);
|
||||||
}
|
}
|
||||||
for (vector<cTVDBMedia*>::iterator it = fanart.begin(); it != fanart.end(); it++) {
|
for (vector<cTVDBMedia*>::iterator it = fanart.begin(); it != fanart.end(); it++) {
|
||||||
cTVDBMedia *m = *it;
|
cTVDBMedia *m = *it;
|
||||||
tell(0, "Fanart %d, Path: %s", m->mediaType, m->path.c_str());
|
tell(0, "Fanart %d, Path: %s", m->mediaType, m->path.c_str());
|
||||||
tell(0, "width %d, height %d", m->width, m->height);
|
tell(0, "width %d, height %d", m->width, m->height);
|
||||||
}
|
}
|
||||||
tell(0, "--------------------------- Episodes ----------------------------------");
|
tell(0, "--------------------------- Episodes ----------------------------------");
|
||||||
for (map<int, cTVDBEpisode*>::iterator it = episodes.begin(); it != episodes.end(); it++) {
|
for (map<int, cTVDBEpisode*>::iterator it = episodes.begin(); it != episodes.end(); it++) {
|
||||||
cTVDBEpisode *e = it->second;
|
cTVDBEpisode *e = it->second;
|
||||||
tell(0, "Episode %d, Name: %s", e->id, e->name.c_str());
|
tell(0, "Episode %d, Name: %s", e->id, e->name.c_str());
|
||||||
if (e->episodeImage) {
|
if (e->episodeImage) {
|
||||||
tell(0, "Episode Image: %d x %d, Path: %s", e->episodeImage->width, e->episodeImage->height, e->episodeImage->path.c_str());
|
tell(0, "Episode Image: %d x %d, Path: %s", e->episodeImage->width, e->episodeImage->height, e->episodeImage->path.c_str());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
tell(0, "--------------------------- Season Posters ----------------------------------");
|
tell(0, "--------------------------- Season Posters ----------------------------------");
|
||||||
for (map<int, cTVDBMedia*>::iterator it = seasonPosters.begin(); it != seasonPosters.end(); it++) {
|
for (map<int, cTVDBMedia*>::iterator it = seasonPosters.begin(); it != seasonPosters.end(); it++) {
|
||||||
int season = it->first;
|
int season = it->first;
|
||||||
cTVDBMedia *m = it->second;
|
cTVDBMedia *m = it->second;
|
||||||
tell(0, "Season %d, %d x %d, Path: %s", season, m->width, m->height, m->path.c_str());
|
tell(0, "Season %d, %d x %d, Path: %s", season, m->width, m->height, m->path.c_str());
|
||||||
}
|
}
|
||||||
tell(0, "--------------------------- Actors ----------------------------------");
|
tell(0, "--------------------------- Actors ----------------------------------");
|
||||||
for (map<int, cTVDBActor*>::iterator it = actors.begin(); it != actors.end(); it++) {
|
for (map<int, cTVDBActor*>::iterator it = actors.begin(); it != actors.end(); it++) {
|
||||||
cTVDBActor *a = it->second;
|
cTVDBActor *a = it->second;
|
||||||
tell(0, "Actor %d, Name: %s, Role %s", a->id, a->name.c_str(), a->role.c_str());
|
tell(0, "Actor %d, Name: %s, Role %s", a->id, a->name.c_str(), a->role.c_str());
|
||||||
if (a->actorThumb) {
|
if (a->actorThumb) {
|
||||||
tell(0, "Thumb: %d x %d, Path: %s", a->actorThumb->width, a->actorThumb->height, a->actorThumb->path.c_str());
|
tell(0, "Thumb: %d x %d, Path: %s", a->actorThumb->width, a->actorThumb->height, a->actorThumb->path.c_str());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (posterThumb) {
|
if (posterThumb) {
|
||||||
tell(0, "posterThumb path %s, width %d, height %d", posterThumb->path.c_str(), posterThumb->width, posterThumb->height);
|
tell(0, "posterThumb path %s, width %d, height %d", posterThumb->path.c_str(), posterThumb->width, posterThumb->height);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
286
tvdbseries.h
286
tvdbseries.h
@ -1,143 +1,143 @@
|
|||||||
#ifndef __TVSCRAPER_TVDBSERIES_H
|
#ifndef __TVSCRAPER_TVDBSERIES_H
|
||||||
#define __TVSCRAPER_TVDBSERIES_H
|
#define __TVSCRAPER_TVDBSERIES_H
|
||||||
|
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
#include <string>
|
#include <string>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
#include <map>
|
#include <map>
|
||||||
#include <set>
|
#include <set>
|
||||||
#include <utility>
|
#include <utility>
|
||||||
#include <algorithm>
|
#include <algorithm>
|
||||||
#include "services.h"
|
#include "services.h"
|
||||||
|
|
||||||
using namespace std;
|
using namespace std;
|
||||||
|
|
||||||
enum mediaSeries {
|
enum mediaSeries {
|
||||||
msBanner1,
|
msBanner1,
|
||||||
msBanner2,
|
msBanner2,
|
||||||
msBanner3,
|
msBanner3,
|
||||||
msPoster1,
|
msPoster1,
|
||||||
msPoster2,
|
msPoster2,
|
||||||
msPoster3,
|
msPoster3,
|
||||||
msSeasonPoster,
|
msSeasonPoster,
|
||||||
msFanart1,
|
msFanart1,
|
||||||
msFanart2,
|
msFanart2,
|
||||||
msFanart3,
|
msFanart3,
|
||||||
msEpisodePic,
|
msEpisodePic,
|
||||||
msActorThumb,
|
msActorThumb,
|
||||||
msPosterThumb,
|
msPosterThumb,
|
||||||
msSeasonPosterThumb,
|
msSeasonPosterThumb,
|
||||||
};
|
};
|
||||||
|
|
||||||
// --- cTVDBMedia -------------------------------------------------------------
|
// --- cTVDBMedia -------------------------------------------------------------
|
||||||
class cTVDBMedia {
|
class cTVDBMedia {
|
||||||
public:
|
public:
|
||||||
cTVDBMedia(void) {
|
cTVDBMedia(void) {
|
||||||
path = "";
|
path = "";
|
||||||
mediaType = msBanner1;
|
mediaType = msBanner1;
|
||||||
width = 0;
|
width = 0;
|
||||||
height = 0;
|
height = 0;
|
||||||
};
|
};
|
||||||
~cTVDBMedia(void) {
|
~cTVDBMedia(void) {
|
||||||
};
|
};
|
||||||
string path;
|
string path;
|
||||||
int mediaType;
|
int mediaType;
|
||||||
int width;
|
int width;
|
||||||
int height;
|
int height;
|
||||||
};
|
};
|
||||||
|
|
||||||
// --- cTVDBEpisode -------------------------------------------------------------
|
// --- cTVDBEpisode -------------------------------------------------------------
|
||||||
class cTVDBEpisode {
|
class cTVDBEpisode {
|
||||||
public:
|
public:
|
||||||
cTVDBEpisode(void) {
|
cTVDBEpisode(void) {
|
||||||
id = 0;
|
id = 0;
|
||||||
number = 0;
|
number = 0;
|
||||||
season = 0;
|
season = 0;
|
||||||
name = "";
|
name = "";
|
||||||
firstAired = "";
|
firstAired = "";
|
||||||
guestStars = "";
|
guestStars = "";
|
||||||
overview = "";
|
overview = "";
|
||||||
rating = 0.0;
|
rating = 0.0;
|
||||||
episodeImage = NULL;
|
episodeImage = NULL;
|
||||||
};
|
};
|
||||||
~cTVDBEpisode(void) {
|
~cTVDBEpisode(void) {
|
||||||
if (episodeImage)
|
if (episodeImage)
|
||||||
delete episodeImage;
|
delete episodeImage;
|
||||||
};
|
};
|
||||||
int id;
|
int id;
|
||||||
int number;
|
int number;
|
||||||
int season;
|
int season;
|
||||||
string name;
|
string name;
|
||||||
string firstAired;
|
string firstAired;
|
||||||
string guestStars;
|
string guestStars;
|
||||||
string overview;
|
string overview;
|
||||||
float rating;
|
float rating;
|
||||||
cTVDBMedia *episodeImage;
|
cTVDBMedia *episodeImage;
|
||||||
};
|
};
|
||||||
|
|
||||||
// --- cTVDBActor -------------------------------------------------------------
|
// --- cTVDBActor -------------------------------------------------------------
|
||||||
class cTVDBActor {
|
class cTVDBActor {
|
||||||
public:
|
public:
|
||||||
cTVDBActor(void) {
|
cTVDBActor(void) {
|
||||||
id = 0;
|
id = 0;
|
||||||
name = "";
|
name = "";
|
||||||
role = "";
|
role = "";
|
||||||
thumbWidth = 0;
|
thumbWidth = 0;
|
||||||
thumbHeight = 0;
|
thumbHeight = 0;
|
||||||
actorThumb = NULL;
|
actorThumb = NULL;
|
||||||
};
|
};
|
||||||
~cTVDBActor(void) {
|
~cTVDBActor(void) {
|
||||||
if (actorThumb)
|
if (actorThumb)
|
||||||
delete actorThumb;
|
delete actorThumb;
|
||||||
};
|
};
|
||||||
int id;
|
int id;
|
||||||
string name;
|
string name;
|
||||||
string role;
|
string role;
|
||||||
int thumbWidth;
|
int thumbWidth;
|
||||||
int thumbHeight;
|
int thumbHeight;
|
||||||
cTVDBMedia *actorThumb;
|
cTVDBMedia *actorThumb;
|
||||||
};
|
};
|
||||||
|
|
||||||
// --- cTVDBSeries -------------------------------------------------------------
|
// --- cTVDBSeries -------------------------------------------------------------
|
||||||
|
|
||||||
class cTVDBSeries {
|
class cTVDBSeries {
|
||||||
private:
|
private:
|
||||||
map<int, cTVDBEpisode*> episodes;
|
map<int, cTVDBEpisode*> episodes;
|
||||||
map<int, cTVDBActor*> actors;
|
map<int, cTVDBActor*> actors;
|
||||||
vector<cTVDBMedia*> posters;
|
vector<cTVDBMedia*> posters;
|
||||||
vector<cTVDBMedia*> banners;
|
vector<cTVDBMedia*> banners;
|
||||||
vector<cTVDBMedia*> fanart;
|
vector<cTVDBMedia*> fanart;
|
||||||
map<int, cTVDBMedia*> seasonPosters;
|
map<int, cTVDBMedia*> seasonPosters;
|
||||||
map<int, cTVDBMedia*> seasonPosterThumbs;
|
map<int, cTVDBMedia*> seasonPosterThumbs;
|
||||||
cTVDBMedia *posterThumb;
|
cTVDBMedia *posterThumb;
|
||||||
public:
|
public:
|
||||||
cTVDBSeries(void);
|
cTVDBSeries(void);
|
||||||
virtual ~cTVDBSeries(void);
|
virtual ~cTVDBSeries(void);
|
||||||
int id;
|
int id;
|
||||||
string name;
|
string name;
|
||||||
string overview;
|
string overview;
|
||||||
string firstAired;
|
string firstAired;
|
||||||
string network;
|
string network;
|
||||||
string genre;
|
string genre;
|
||||||
float rating;
|
float rating;
|
||||||
string status;
|
string status;
|
||||||
void InsertEpisode(cTVDBEpisode *episode);
|
void InsertEpisode(cTVDBEpisode *episode);
|
||||||
void InsertEpisodeImage(int episodeId, int width, int height, string path);
|
void InsertEpisodeImage(int episodeId, int width, int height, string path);
|
||||||
void InsertActor(cTVDBActor *actor);
|
void InsertActor(cTVDBActor *actor);
|
||||||
void InsertActorThumb(int actorId, int imgWidth, int imgHeight, string path);
|
void InsertActorThumb(int actorId, int imgWidth, int imgHeight, string path);
|
||||||
void InsertMedia(int mediaType, int imgWidth, int imgHeight, string path, int season = 0);
|
void InsertMedia(int mediaType, int imgWidth, int imgHeight, string path, int season = 0);
|
||||||
//Getter for Serivice Calls
|
//Getter for Serivice Calls
|
||||||
void GetEpisode(int episodeId, cEpisode *e);
|
void GetEpisode(int episodeId, cEpisode *e);
|
||||||
void GetPosters(vector<cTvMedia> *p);
|
void GetPosters(vector<cTvMedia> *p);
|
||||||
bool GetPoster(cTvMedia *p);
|
bool GetPoster(cTvMedia *p);
|
||||||
bool GetPosterThumb(cTvMedia *p);
|
bool GetPosterThumb(cTvMedia *p);
|
||||||
void GetBanners(vector<cTvMedia> *b);
|
void GetBanners(vector<cTvMedia> *b);
|
||||||
bool GetRandomBanner(cTvMedia *b);
|
bool GetRandomBanner(cTvMedia *b);
|
||||||
void GetFanart(vector<cTvMedia> *f);
|
void GetFanart(vector<cTvMedia> *f);
|
||||||
void GetSeasonPoster(int episodeId, cTvMedia *sp);
|
void GetSeasonPoster(int episodeId, cTvMedia *sp);
|
||||||
void GetActors(vector<cActor> *a);
|
void GetActors(vector<cActor> *a);
|
||||||
void Dump(void);
|
void Dump(void);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
#endif //__TVSCRAPER_TVDBSERIES_H
|
#endif //__TVSCRAPER_TVDBSERIES_H
|
||||||
|
28
update.h
28
update.h
@ -1,7 +1,6 @@
|
|||||||
#ifndef __UPDATE_H
|
#ifndef __UPDATE_H
|
||||||
#define __UPDATE_H
|
#define __UPDATE_H
|
||||||
|
|
||||||
#include <mysql/mysql.h>
|
|
||||||
#include <map>
|
#include <map>
|
||||||
|
|
||||||
#include <vdr/thread.h>
|
#include <vdr/thread.h>
|
||||||
@ -71,6 +70,33 @@ class cUpdate : public cThread {
|
|||||||
int CleanupSeries(void);
|
int CleanupSeries(void);
|
||||||
int CleanupMovies(void);
|
int CleanupMovies(void);
|
||||||
int CleanupRecordings(void);
|
int CleanupRecordings(void);
|
||||||
|
|
||||||
|
// statements
|
||||||
|
|
||||||
|
cDbStatement* selectReadScrapedEventsInit;
|
||||||
|
cDbStatement* selectReadScrapedEvents;
|
||||||
|
cDbStatement* selectImg;
|
||||||
|
cDbStatement* selectSeasonPoster;
|
||||||
|
cDbStatement* selectActors;
|
||||||
|
cDbStatement* selectActorThumbs;
|
||||||
|
cDbStatement* selectSeriesMedia;
|
||||||
|
cDbStatement* selectMovieActors;
|
||||||
|
cDbStatement* selectMovieActorThumbs;
|
||||||
|
cDbStatement* selectMovieMedia;
|
||||||
|
cDbStatement* selectMediaMovie;
|
||||||
|
cDbStatement* selectRecordings;
|
||||||
|
cDbStatement* selectCleanupRecordings;
|
||||||
|
|
||||||
|
cDbValue imageSize;
|
||||||
|
cDbValue posterSize;
|
||||||
|
cDbValue series_id;
|
||||||
|
cDbValue actorImageSize;
|
||||||
|
|
||||||
|
cDbValue actorRole;
|
||||||
|
cDbValue actorMovie;
|
||||||
|
cDbValue thbWidth;
|
||||||
|
cDbValue thbHeight;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
cUpdate(cScrapManager *manager);
|
cUpdate(cScrapManager *manager);
|
||||||
virtual ~cUpdate(void);
|
virtual ~cUpdate(void);
|
||||||
|
Loading…
Reference in New Issue
Block a user