Adds support for URLs (streaming) in m3u playlist files.
Also added a few file types that the filescanner should ignore.
This commit is contained in:
parent
f6f3057930
commit
4552acba7e
|
@ -66,6 +66,7 @@
|
|||
|
||||
struct deferred_pl {
|
||||
char *path;
|
||||
time_t mtime;
|
||||
struct deferred_pl *next;
|
||||
};
|
||||
|
||||
|
@ -294,8 +295,8 @@ fixup_tags(struct media_file_info *mfi)
|
|||
}
|
||||
|
||||
|
||||
static void
|
||||
process_media_file(char *file, time_t mtime, off_t size, int compilation)
|
||||
void
|
||||
process_media_file(char *file, time_t mtime, off_t size, int compilation, int url)
|
||||
{
|
||||
struct media_file_info mfi;
|
||||
char *filename;
|
||||
|
@ -364,13 +365,28 @@ process_media_file(char *file, time_t mtime, off_t size, int compilation)
|
|||
/* Artwork - don't scan */
|
||||
goto out;
|
||||
}
|
||||
else if ((strcmp(ext, ".db") == 0)
|
||||
|| (strcmp(ext, ".ini") == 0))
|
||||
{
|
||||
/* System files - don't scan */
|
||||
goto out;
|
||||
}
|
||||
else if ((filename[1] == '_')
|
||||
|| (filename[1] == '.'))
|
||||
{
|
||||
/* Hidden files - don't scan */
|
||||
goto out;
|
||||
}
|
||||
}
|
||||
|
||||
/* General case */
|
||||
if (ret < 0)
|
||||
{
|
||||
ret = scan_metadata_ffmpeg(file, &mfi);
|
||||
mfi.data_kind = 0; /* real file */
|
||||
if (url == 0)
|
||||
mfi.data_kind = 0; /* real file */
|
||||
if (url == 1)
|
||||
mfi.data_kind = 1; /* url/stream */
|
||||
}
|
||||
|
||||
if (ret < 0)
|
||||
|
@ -401,7 +417,7 @@ process_media_file(char *file, time_t mtime, off_t size, int compilation)
|
|||
}
|
||||
|
||||
static void
|
||||
process_playlist(char *file)
|
||||
process_playlist(char *file, time_t mtime)
|
||||
{
|
||||
char *ext;
|
||||
|
||||
|
@ -409,7 +425,7 @@ process_playlist(char *file)
|
|||
if (ext)
|
||||
{
|
||||
if (strcmp(ext, ".m3u") == 0)
|
||||
scan_m3u_playlist(file);
|
||||
scan_m3u_playlist(file, mtime);
|
||||
#ifdef ITUNES
|
||||
else if (strcmp(ext, ".xml") == 0)
|
||||
scan_itunes_itml(file);
|
||||
|
@ -419,7 +435,7 @@ process_playlist(char *file)
|
|||
|
||||
/* Thread: scan */
|
||||
static void
|
||||
defer_playlist(char *path)
|
||||
defer_playlist(char *path, time_t mtime)
|
||||
{
|
||||
struct deferred_pl *pl;
|
||||
|
||||
|
@ -442,6 +458,7 @@ defer_playlist(char *path)
|
|||
return;
|
||||
}
|
||||
|
||||
pl->mtime = mtime;
|
||||
pl->next = playlists;
|
||||
playlists = pl;
|
||||
|
||||
|
@ -458,7 +475,7 @@ process_deferred_playlists(void)
|
|||
{
|
||||
playlists = pl->next;
|
||||
|
||||
process_playlist(pl->path);
|
||||
process_playlist(pl->path, pl->mtime);
|
||||
|
||||
free(pl->path);
|
||||
free(pl);
|
||||
|
@ -487,9 +504,9 @@ process_file(char *file, time_t mtime, off_t size, int compilation, int flags)
|
|||
)
|
||||
{
|
||||
if (flags & F_SCAN_BULK)
|
||||
defer_playlist(file);
|
||||
defer_playlist(file, mtime);
|
||||
else
|
||||
process_playlist(file);
|
||||
process_playlist(file, mtime);
|
||||
|
||||
return;
|
||||
}
|
||||
|
@ -502,7 +519,7 @@ process_file(char *file, time_t mtime, off_t size, int compilation, int flags)
|
|||
}
|
||||
|
||||
/* Not any kind of special file, so let's see if it's a media file */
|
||||
process_media_file(file, mtime, size, compilation);
|
||||
process_media_file(file, mtime, size, compilation, 0);
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -10,15 +10,15 @@ filescanner_init(void);
|
|||
void
|
||||
filescanner_deinit(void);
|
||||
|
||||
void
|
||||
process_media_file(char *file, time_t mtime, off_t size, int compilation, int url);
|
||||
|
||||
/* Actual scanners */
|
||||
int
|
||||
scan_metadata_ffmpeg(char *file, struct media_file_info *mfi);
|
||||
|
||||
int
|
||||
scan_url_file(char *file, struct media_file_info *mfi);
|
||||
|
||||
void
|
||||
scan_m3u_playlist(char *file);
|
||||
scan_m3u_playlist(char *file, time_t mtime);
|
||||
|
||||
#ifdef ITUNES
|
||||
void
|
||||
|
|
|
@ -41,7 +41,7 @@
|
|||
|
||||
|
||||
void
|
||||
scan_m3u_playlist(char *file)
|
||||
scan_m3u_playlist(char *file, time_t mtime)
|
||||
{
|
||||
FILE *fp;
|
||||
struct playlist_info *pli;
|
||||
|
@ -165,6 +165,17 @@ scan_m3u_playlist(char *file)
|
|||
buf[len] = '\0';
|
||||
}
|
||||
|
||||
/* Check if line is an URL */
|
||||
if (strcmp(buf, "http://") > 0)
|
||||
{
|
||||
DPRINTF(E_DBG, L_SCAN, "Playlist contains URL entry\n");
|
||||
|
||||
filename = strdup(buf);
|
||||
process_media_file(filename, mtime, 0, 0, 1);
|
||||
|
||||
goto urlexit;
|
||||
}
|
||||
|
||||
/* Absolute vs. relative path */
|
||||
if (buf[0] == '/')
|
||||
{
|
||||
|
@ -191,6 +202,7 @@ scan_m3u_playlist(char *file)
|
|||
continue;
|
||||
}
|
||||
|
||||
urlexit:
|
||||
ret = db_pl_add_item_bypath(pl_id, filename);
|
||||
if (ret < 0)
|
||||
DPRINTF(E_WARN, L_SCAN, "Could not add %s to playlist\n", filename);
|
||||
|
|
|
@ -579,6 +579,7 @@ main(int argc, char **argv)
|
|||
}
|
||||
|
||||
av_register_all();
|
||||
avformat_network_init();
|
||||
av_log_set_callback(logger_ffmpeg);
|
||||
#if LIBAVFORMAT_VERSION_MAJOR < 53
|
||||
register_ffmpeg_evbuffer_url_protocol();
|
||||
|
@ -814,6 +815,7 @@ main(int argc, char **argv)
|
|||
|
||||
signal_block_fail:
|
||||
gcrypt_init_fail:
|
||||
avformat_network_deinit();
|
||||
av_lockmgr_register(NULL);
|
||||
|
||||
ffmpeg_init_fail:
|
||||
|
|
Loading…
Reference in New Issue