From a65737b4e70ad2de20c4791ea87c4141c27afa58 Mon Sep 17 00:00:00 2001 From: chme Date: Sat, 25 Feb 2017 15:27:48 +0100 Subject: [PATCH] [filescanner] Add scan-metadata function for non library items For now only support scanning metadata for internet radio streams --- src/library/filescanner.c | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) diff --git a/src/library/filescanner.c b/src/library/filescanner.c index 15b52551..5ecdc61a 100644 --- a/src/library/filescanner.c +++ b/src/library/filescanner.c @@ -1529,6 +1529,34 @@ filescanner_fullrescan() return 0; } +static int +scan_metadata(const char *path, struct media_file_info *mfi) +{ + int ret; + + if (strncasecmp(path, "http://", strlen("http://")) == 0) + { + memset(mfi, 0, sizeof(struct media_file_info)); + mfi->path = strdup(path); + mfi->fname = strdup(basename(mfi->path)); + mfi->data_kind = DATA_KIND_HTTP; + mfi->directory_id = DIR_HTTP; + + ret = scan_metadata_ffmpeg(path, mfi); + if (ret < 0) + { + DPRINTF(E_LOG, L_SCAN, "Playlist URL '%s' is unavailable for probe/metadata, assuming MP3 encoding\n", path); + mfi->type = strdup("mp3"); + mfi->codectype = strdup("mpeg"); + mfi->description = strdup("MPEG audio file"); + } + + return METADATA_OK; + } + + return METADATA_PATH_INVALID; +} + /* Thread: main */ static int filescanner_init(void) @@ -1561,4 +1589,5 @@ struct library_source filescanner = .initscan = filescanner_initscan, .rescan = filescanner_rescan, .fullrescan = filescanner_fullrescan, + .scan_metadata = scan_metadata, };