mirror of
https://github.com/owntone/owntone-server.git
synced 2025-02-23 11:32:34 -05:00
Fix bug in m3u scanner
This commit is contained in:
parent
2dfa64abcf
commit
35e9b3dc30
6
src/db.c
6
src/db.c
@ -326,6 +326,8 @@ free_pi(struct pairing_info *pi, int content_only)
|
|||||||
|
|
||||||
if (!content_only)
|
if (!content_only)
|
||||||
free(pi);
|
free(pi);
|
||||||
|
else
|
||||||
|
memset(pi, 0, sizeof(struct pairing_info));
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
@ -402,6 +404,8 @@ free_mfi(struct media_file_info *mfi, int content_only)
|
|||||||
|
|
||||||
if (!content_only)
|
if (!content_only)
|
||||||
free(mfi);
|
free(mfi);
|
||||||
|
else
|
||||||
|
memset(mfi, 0, sizeof(struct media_file_info));
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
@ -452,6 +456,8 @@ free_pli(struct playlist_info *pli, int content_only)
|
|||||||
|
|
||||||
if (!content_only)
|
if (!content_only)
|
||||||
free(pli);
|
free(pli);
|
||||||
|
else
|
||||||
|
memset(pli, 0, sizeof(struct playlist_info));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -46,7 +46,7 @@ extinf_get(char *string, struct media_file_info *mfi, int *extinf)
|
|||||||
{
|
{
|
||||||
char *ptr;
|
char *ptr;
|
||||||
|
|
||||||
if (strcmp(string, "#EXTINF:") <= 0)
|
if (strncmp(string, "#EXTINF:", strlen("#EXTINF:")) != 0)
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
ptr = strchr(string, ',');
|
ptr = strchr(string, ',');
|
||||||
@ -54,11 +54,7 @@ extinf_get(char *string, struct media_file_info *mfi, int *extinf)
|
|||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
/* New extinf found, so clear old data */
|
/* New extinf found, so clear old data */
|
||||||
if (*extinf)
|
free_mfi(mfi, 1);
|
||||||
{
|
|
||||||
free(mfi->artist);
|
|
||||||
free(mfi->title);
|
|
||||||
}
|
|
||||||
|
|
||||||
*extinf = 1;
|
*extinf = 1;
|
||||||
mfi->artist = strdup(ptr + 1);
|
mfi->artist = strdup(ptr + 1);
|
||||||
@ -74,17 +70,6 @@ extinf_get(char *string, struct media_file_info *mfi, int *extinf)
|
|||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
|
||||||
extinf_reset(struct media_file_info *mfi, int *extinf)
|
|
||||||
{
|
|
||||||
if (*extinf)
|
|
||||||
{
|
|
||||||
free(mfi->artist);
|
|
||||||
free(mfi->title);
|
|
||||||
}
|
|
||||||
*extinf = 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
void
|
void
|
||||||
scan_m3u_playlist(char *file, time_t mtime)
|
scan_m3u_playlist(char *file, time_t mtime)
|
||||||
{
|
{
|
||||||
@ -105,8 +90,6 @@ scan_m3u_playlist(char *file, time_t mtime)
|
|||||||
|
|
||||||
DPRINTF(E_INFO, L_SCAN, "Processing static playlist: %s\n", file);
|
DPRINTF(E_INFO, L_SCAN, "Processing static playlist: %s\n", file);
|
||||||
|
|
||||||
memset(&mfi, 0, sizeof(struct media_file_info));
|
|
||||||
|
|
||||||
ret = stat(file, &sb);
|
ret = stat(file, &sb);
|
||||||
if (ret < 0)
|
if (ret < 0)
|
||||||
{
|
{
|
||||||
@ -171,6 +154,7 @@ scan_m3u_playlist(char *file, time_t mtime)
|
|||||||
}
|
}
|
||||||
|
|
||||||
extinf = 0;
|
extinf = 0;
|
||||||
|
memset(&mfi, 0, sizeof(struct media_file_info));
|
||||||
|
|
||||||
while (fgets(buf, sizeof(buf), fp) != NULL)
|
while (fgets(buf, sizeof(buf), fp) != NULL)
|
||||||
{
|
{
|
||||||
@ -191,7 +175,7 @@ scan_m3u_playlist(char *file, time_t mtime)
|
|||||||
if (len < 1)
|
if (len < 1)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
/* Saves metadata in extinf if EXTINF metadata line */
|
/* Saves metadata in mfi if EXTINF metadata line */
|
||||||
if (extinf_get(buf, &mfi, &extinf))
|
if (extinf_get(buf, &mfi, &extinf))
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
@ -199,7 +183,7 @@ scan_m3u_playlist(char *file, time_t mtime)
|
|||||||
if ((!isalnum(buf[0])) && (buf[0] != '/') && (buf[0] != '.'))
|
if ((!isalnum(buf[0])) && (buf[0] != '/') && (buf[0] != '.'))
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
/* Check if line is an URL */
|
/* Check if line is an URL, will be added to library */
|
||||||
if (strcmp(buf, "http://") > 0)
|
if (strcmp(buf, "http://") > 0)
|
||||||
{
|
{
|
||||||
DPRINTF(E_DBG, L_SCAN, "Playlist contains URL entry\n");
|
DPRINTF(E_DBG, L_SCAN, "Playlist contains URL entry\n");
|
||||||
@ -217,7 +201,7 @@ scan_m3u_playlist(char *file, time_t mtime)
|
|||||||
|
|
||||||
filescanner_process_media(filename, mtime, 0, F_SCAN_TYPE_URL, &mfi);
|
filescanner_process_media(filename, mtime, 0, F_SCAN_TYPE_URL, &mfi);
|
||||||
}
|
}
|
||||||
/* Regular file */
|
/* Regular file, should already be in library */
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
/* m3u might be from Windows so we change backslash to forward slash */
|
/* m3u might be from Windows so we change backslash to forward slash */
|
||||||
@ -274,7 +258,9 @@ scan_m3u_playlist(char *file, time_t mtime)
|
|||||||
if (ret < 0)
|
if (ret < 0)
|
||||||
DPRINTF(E_WARN, L_SCAN, "Could not add %s to playlist\n", filename);
|
DPRINTF(E_WARN, L_SCAN, "Could not add %s to playlist\n", filename);
|
||||||
|
|
||||||
extinf_reset(&mfi, &extinf);
|
/* Clean up in preparation for next item */
|
||||||
|
extinf = 0;
|
||||||
|
free_mfi(&mfi, 1);
|
||||||
free(filename);
|
free(filename);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user