monitor: Support NFO file changes
Detect when a .nfo file changes, and rescan metadata for the associated video file.
This commit is contained in:
30
metadata.c
30
metadata.c
@ -96,7 +96,7 @@ dlna_timestamp_is_present(const char *filename, int *raw_packet_size)
|
||||
if (buffer[i + MPEG_TS_PACKET_LENGTH_DLNA] == MPEG_TS_SYNC_CODE &&
|
||||
buffer[i + MPEG_TS_PACKET_LENGTH_DLNA*2] == MPEG_TS_SYNC_CODE)
|
||||
{
|
||||
*raw_packet_size = MPEG_TS_PACKET_LENGTH_DLNA;
|
||||
*raw_packet_size = MPEG_TS_PACKET_LENGTH_DLNA;
|
||||
if (buffer[i+MPEG_TS_PACKET_LENGTH] == 0x00 &&
|
||||
buffer[i+MPEG_TS_PACKET_LENGTH+1] == 0x00 &&
|
||||
buffer[i+MPEG_TS_PACKET_LENGTH+2] == 0x00 &&
|
||||
@ -106,8 +106,8 @@ dlna_timestamp_is_present(const char *filename, int *raw_packet_size)
|
||||
return 1;
|
||||
} else if (buffer[i + MPEG_TS_PACKET_LENGTH] == MPEG_TS_SYNC_CODE &&
|
||||
buffer[i + MPEG_TS_PACKET_LENGTH*2] == MPEG_TS_SYNC_CODE) {
|
||||
*raw_packet_size = MPEG_TS_PACKET_LENGTH;
|
||||
return 0;
|
||||
*raw_packet_size = MPEG_TS_PACKET_LENGTH;
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -125,13 +125,13 @@ check_for_captions(const char *path, int64_t detailID)
|
||||
strncpyt(file, path, sizeof(file));
|
||||
p = strip_ext(file);
|
||||
if (!p)
|
||||
p = strrchr(file, '\0');
|
||||
return;
|
||||
|
||||
/* If we weren't given a detail ID, look for one. */
|
||||
if (!detailID)
|
||||
{
|
||||
detailID = sql_get_int64_field(db, "SELECT ID from DETAILS where (PATH > '%q.' and PATH <= '%q.z')"
|
||||
" and MIME glob 'video/*' limit 1", file, file);
|
||||
" and MIME glob 'video/*' limit 1", file, file);
|
||||
if (detailID <= 0)
|
||||
{
|
||||
//DPRINTF(E_MAXDEBUG, L_METADATA, "No file found for caption %s.\n", path);
|
||||
@ -287,7 +287,7 @@ GetFolderMetadata(const char *name, const char *path, const char *artist, const
|
||||
}
|
||||
|
||||
int64_t
|
||||
GetAudioMetadata(const char *path, char *name)
|
||||
GetAudioMetadata(const char *path, const char *name)
|
||||
{
|
||||
char type[4];
|
||||
static char lang[6] = { '\0' };
|
||||
@ -303,7 +303,6 @@ GetAudioMetadata(const char *path, char *name)
|
||||
|
||||
if ( stat(path, &file) != 0 )
|
||||
return 0;
|
||||
strip_ext(name);
|
||||
|
||||
if( ends_with(path, ".mp3") )
|
||||
{
|
||||
@ -384,7 +383,9 @@ GetAudioMetadata(const char *path, char *name)
|
||||
}
|
||||
else
|
||||
{
|
||||
m.title = name;
|
||||
free_flags |= FLAG_TITLE;
|
||||
m.title = strdup(name);
|
||||
strip_ext(m.title);
|
||||
}
|
||||
for( i = ROLE_START; i < N_ROLE; i++ )
|
||||
{
|
||||
@ -493,7 +494,7 @@ libjpeg_error_handler(j_common_ptr cinfo)
|
||||
}
|
||||
|
||||
int64_t
|
||||
GetImageMetadata(const char *path, char *name)
|
||||
GetImageMetadata(const char *path, const char *name)
|
||||
{
|
||||
ExifData *ed;
|
||||
ExifEntry *e = NULL;
|
||||
@ -514,7 +515,6 @@ GetImageMetadata(const char *path, char *name)
|
||||
//DEBUG DPRINTF(E_DEBUG, L_METADATA, "Parsing %s...\n", path);
|
||||
if ( stat(path, &file) != 0 )
|
||||
return 0;
|
||||
strip_ext(name);
|
||||
//DEBUG DPRINTF(E_DEBUG, L_METADATA, " * size: %jd\n", file.st_size);
|
||||
|
||||
/* MIME hard-coded to JPEG for now, until we add PNG support */
|
||||
@ -639,13 +639,15 @@ no_exifdata:
|
||||
else if( (width <= 4096 && height <= 4096) || !GETFLAG(DLNA_STRICT_MASK) )
|
||||
m.dlna_pn = strdup("JPEG_LRG");
|
||||
xasprintf(&m.resolution, "%dx%d", width, height);
|
||||
m.title = strdup(name);
|
||||
strip_ext(m.title);
|
||||
|
||||
ret = sql_exec(db, "INSERT into DETAILS"
|
||||
" (PATH, TITLE, SIZE, TIMESTAMP, DATE, RESOLUTION,"
|
||||
" ROTATION, THUMBNAIL, CREATOR, DLNA_PN, MIME) "
|
||||
"VALUES"
|
||||
" (%Q, '%q', %lld, %lld, %Q, %Q, %u, %d, %Q, %Q, %Q);",
|
||||
path, name, (long long)file.st_size, (long long)file.st_mtime, m.date,
|
||||
path, m.title, (long long)file.st_size, (long long)file.st_mtime, m.date,
|
||||
m.resolution, m.rotation, thumb, m.creator, m.dlna_pn, m.mime);
|
||||
if( ret != SQLITE_OK )
|
||||
{
|
||||
@ -662,7 +664,7 @@ no_exifdata:
|
||||
}
|
||||
|
||||
int64_t
|
||||
GetVideoMetadata(const char *path, char *name)
|
||||
GetVideoMetadata(const char *path, const char *name)
|
||||
{
|
||||
struct stat file;
|
||||
int ret, i;
|
||||
@ -685,7 +687,6 @@ GetVideoMetadata(const char *path, char *name)
|
||||
//DEBUG DPRINTF(E_DEBUG, L_METADATA, "Parsing video %s...\n", name);
|
||||
if ( stat(path, &file) != 0 )
|
||||
return 0;
|
||||
strip_ext(name);
|
||||
//DEBUG DPRINTF(E_DEBUG, L_METADATA, " * size: %jd\n", file.st_size);
|
||||
|
||||
ret = lav_open(&ctx, path);
|
||||
@ -1533,7 +1534,10 @@ video_no_dlna:
|
||||
}
|
||||
|
||||
if( !m.title )
|
||||
{
|
||||
m.title = strdup(name);
|
||||
strip_ext(m.title);
|
||||
}
|
||||
|
||||
album_art = find_album_art(path, m.thumb_data, m.thumb_size);
|
||||
freetags(&video);
|
||||
|
Reference in New Issue
Block a user