subtitles: accept smi in addition to srt
This commit is contained in:
parent
0721528bcd
commit
381c4805e6
@ -297,7 +297,7 @@ inotify_insert_file(char * name, const char * path)
|
|||||||
/* Is it cover art for another file? */
|
/* Is it cover art for another file? */
|
||||||
if( is_image(path) )
|
if( is_image(path) )
|
||||||
update_if_album_art(path);
|
update_if_album_art(path);
|
||||||
else if( ends_with(path, ".srt") )
|
else if( is_caption(path) )
|
||||||
check_for_captions(path, 0);
|
check_for_captions(path, 0);
|
||||||
|
|
||||||
/* Check if we're supposed to be scanning for this file type in this directory */
|
/* Check if we're supposed to be scanning for this file type in this directory */
|
||||||
@ -538,7 +538,7 @@ inotify_remove_file(const char * path)
|
|||||||
int64_t detailID;
|
int64_t detailID;
|
||||||
int rows, playlist;
|
int rows, playlist;
|
||||||
|
|
||||||
if( ends_with(path, ".srt") )
|
if( is_caption(path) )
|
||||||
{
|
{
|
||||||
return sql_exec(db, "DELETE from CAPTIONS where PATH = '%q'", path);
|
return sql_exec(db, "DELETE from CAPTIONS where PATH = '%q'", path);
|
||||||
}
|
}
|
||||||
|
39
metadata.c
39
metadata.c
@ -157,41 +157,42 @@ dlna_timestamp_is_present(const char *filename, int *raw_packet_size)
|
|||||||
void
|
void
|
||||||
check_for_captions(const char *path, int64_t detailID)
|
check_for_captions(const char *path, int64_t detailID)
|
||||||
{
|
{
|
||||||
char *file = malloc(MAXPATHLEN);
|
char file[MAXPATHLEN];
|
||||||
char *id = NULL;
|
char *p;
|
||||||
|
int ret;
|
||||||
|
|
||||||
sprintf(file, "%s", path);
|
strncpyt(file, path, sizeof(file));
|
||||||
strip_ext(file);
|
p = strip_ext(file);
|
||||||
|
if (!p)
|
||||||
|
p = strrchr(file, '\0');
|
||||||
|
|
||||||
/* If we weren't given a detail ID, look for one. */
|
/* If we weren't given a detail ID, look for one. */
|
||||||
if( !detailID )
|
if (!detailID)
|
||||||
{
|
{
|
||||||
id = sql_get_text_field(db, "SELECT ID from DETAILS where (PATH > '%q.' and PATH <= '%q.z')"
|
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( id )
|
if (detailID <= 0)
|
||||||
{
|
|
||||||
//DPRINTF(E_MAXDEBUG, L_METADATA, "New file %s looks like a caption file.\n", path);
|
|
||||||
detailID = strtoll(id, NULL, 10);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
{
|
||||||
//DPRINTF(E_MAXDEBUG, L_METADATA, "No file found for caption %s.\n", path);
|
//DPRINTF(E_MAXDEBUG, L_METADATA, "No file found for caption %s.\n", path);
|
||||||
goto no_source_video;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
strcat(file, ".srt");
|
strcpy(p, ".srt");
|
||||||
if( access(file, R_OK) == 0 )
|
ret = access(file, R_OK);
|
||||||
|
if (ret != 0)
|
||||||
|
{
|
||||||
|
strcpy(p, ".smi");
|
||||||
|
ret = access(file, R_OK);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (ret == 0)
|
||||||
{
|
{
|
||||||
sql_exec(db, "INSERT into CAPTIONS"
|
sql_exec(db, "INSERT into CAPTIONS"
|
||||||
" (ID, PATH) "
|
" (ID, PATH) "
|
||||||
"VALUES"
|
"VALUES"
|
||||||
" (%lld, %Q)", detailID, file);
|
" (%lld, %Q)", detailID, file);
|
||||||
}
|
}
|
||||||
no_source_video:
|
|
||||||
if( id )
|
|
||||||
sqlite3_free(id);
|
|
||||||
free(file);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
|
16
utils.c
16
utils.c
@ -227,14 +227,16 @@ escape_tag(const char *tag, int force_alloc)
|
|||||||
return esc_tag;
|
return esc_tag;
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
char *
|
||||||
strip_ext(char * name)
|
strip_ext(char *name)
|
||||||
{
|
{
|
||||||
char * period;
|
char *period;
|
||||||
|
|
||||||
period = strrchr(name, '.');
|
period = strrchr(name, '.');
|
||||||
if( period )
|
if (period)
|
||||||
*period = '\0';
|
*period = '\0';
|
||||||
|
|
||||||
|
return period;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Code basically stolen from busybox */
|
/* Code basically stolen from busybox */
|
||||||
@ -408,6 +410,12 @@ is_playlist(const char * file)
|
|||||||
return (ends_with(file, ".m3u") || ends_with(file, ".pls"));
|
return (ends_with(file, ".m3u") || ends_with(file, ".pls"));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int
|
||||||
|
is_caption(const char * file)
|
||||||
|
{
|
||||||
|
return (ends_with(file, ".srt") || ends_with(file, ".smi"));
|
||||||
|
}
|
||||||
|
|
||||||
int
|
int
|
||||||
is_album_art(const char * name)
|
is_album_art(const char * name)
|
||||||
{
|
{
|
||||||
|
3
utils.h
3
utils.h
@ -63,13 +63,14 @@ char *strcasestrc(const char *s, const char *p, const char t);
|
|||||||
char *modifyString(char *string, const char *before, const char *after, int noalloc);
|
char *modifyString(char *string, const char *before, const char *after, int noalloc);
|
||||||
char *escape_tag(const char *tag, int force_alloc);
|
char *escape_tag(const char *tag, int force_alloc);
|
||||||
char *unescape_tag(const char *tag, int force_alloc);
|
char *unescape_tag(const char *tag, int force_alloc);
|
||||||
void strip_ext(char * name);
|
char *strip_ext(char *name);
|
||||||
|
|
||||||
/* Metadata functions */
|
/* Metadata functions */
|
||||||
int is_video(const char * file);
|
int is_video(const char * file);
|
||||||
int is_audio(const char * file);
|
int is_audio(const char * file);
|
||||||
int is_image(const char * file);
|
int is_image(const char * file);
|
||||||
int is_playlist(const char * file);
|
int is_playlist(const char * file);
|
||||||
|
int is_caption(const char * file);
|
||||||
int is_album_art(const char * name);
|
int is_album_art(const char * name);
|
||||||
int resolve_unknown_type(const char * path, media_types dir_type);
|
int resolve_unknown_type(const char * path, media_types dir_type);
|
||||||
const char *mime_to_ext(const char * mime);
|
const char *mime_to_ext(const char * mime);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user