| 16 |
16 |
* implied. In no event shall the authors be liable for any damages arising from
|
| 17 |
17 |
* the use of this software.
|
| 18 |
18 |
*/
|
| 19 |
|
|
|
19 |
#include <stdlib.h>
|
|
20 |
#include <stdio.h>
|
|
21 |
#include <string.h>
|
|
22 |
#include <unistd.h>
|
| 20 |
23 |
#include "playlist-internal.h"
|
| 21 |
24 |
|
| 22 |
25 |
#include "audstrings.h"
|
| ... | ... | |
| 28 |
31 |
|
| 29 |
32 |
EXPORT bool aud_filename_is_playlist (const char * filename)
|
| 30 |
33 |
{
|
| 31 |
|
StringBuf ext = uri_get_extension (filename);
|
|
34 |
bool istuneinstream = false;
|
|
35 |
if (strstr(filename, "://tunein.com/"))
|
|
36 |
{
|
|
37 |
StringBuf temp_tunein_filename = filename_build ({aud_get_path (AudPath::UserDir), "tunein.pls"});
|
|
38 |
remove ((const char *) temp_tunein_filename);
|
|
39 |
system ((const char *) str_concat ({"getTuneinStream.pl ", filename, " >", temp_tunein_filename}));
|
|
40 |
if (access((const char *) temp_tunein_filename, F_OK ) != -1 )
|
|
41 |
istuneinstream = true;
|
|
42 |
}
|
| 32 |
43 |
|
|
44 |
StringBuf ext = istuneinstream ? str_printf (_("pls")) : uri_get_extension (filename);
|
| 33 |
45 |
if (ext)
|
| 34 |
46 |
{
|
| 35 |
47 |
for (PluginHandle * plugin : aud_plugin_list (PluginType::Playlist))
|
| ... | ... | |
| 44 |
56 |
|
| 45 |
57 |
bool playlist_load (const char * filename, String & title, Index<PlaylistAddItem> & items)
|
| 46 |
58 |
{
|
|
59 |
bool istuneinstream = false;
|
|
60 |
bool plugin_found = false;
|
|
61 |
|
| 47 |
62 |
AUDINFO ("Loading playlist %s.\n", filename);
|
| 48 |
63 |
|
| 49 |
|
StringBuf ext = uri_get_extension (filename);
|
| 50 |
|
bool plugin_found = false;
|
|
64 |
if (strstr(filename, "://tunein.com/"))
|
|
65 |
istuneinstream = true;
|
|
66 |
|
|
67 |
StringBuf ext = istuneinstream ? str_printf (_("pls")) : uri_get_extension (filename);
|
| 51 |
68 |
|
| 52 |
69 |
if (ext)
|
| 53 |
70 |
{
|
| ... | ... | |
| 63 |
80 |
if (! pp)
|
| 64 |
81 |
continue;
|
| 65 |
82 |
|
| 66 |
|
VFSFile file (filename, "r");
|
| 67 |
|
if (! file)
|
|
83 |
if (istuneinstream)
|
| 68 |
84 |
{
|
| 69 |
|
aud_ui_show_error (str_printf (_("Error opening %s:\n%s"),
|
| 70 |
|
filename, file.error ()));
|
| 71 |
|
return false;
|
|
85 |
StringBuf temp_tunein_filename = filename_build ({"file://", aud_get_path (AudPath::UserDir), "tunein.pls"});
|
|
86 |
|
|
87 |
VFSFile file ((const char *) temp_tunein_filename, "r");
|
|
88 |
if (! file)
|
|
89 |
{
|
|
90 |
aud_ui_show_error (str_printf (_("Error opening %s:\n%s"),
|
|
91 |
(const char *) temp_tunein_filename, file.error ()));
|
|
92 |
return false;
|
|
93 |
}
|
|
94 |
|
|
95 |
if (pp->load ((const char *) temp_tunein_filename, file, title, items))
|
|
96 |
return true;
|
| 72 |
97 |
}
|
|
98 |
else
|
|
99 |
{
|
|
100 |
VFSFile file (filename, "r");
|
|
101 |
if (! file)
|
|
102 |
{
|
|
103 |
aud_ui_show_error (str_printf (_("Error opening %s:\n%s"),
|
|
104 |
filename, file.error ()));
|
|
105 |
return false;
|
|
106 |
}
|
| 73 |
107 |
|
| 74 |
|
if (pp->load (filename, file, title, items))
|
| 75 |
|
return true;
|
|
108 |
if (pp->load (filename, file, title, items))
|
|
109 |
return true;
|
|
110 |
}
|
| 76 |
111 |
|
| 77 |
112 |
title = String ();
|
| 78 |
113 |
items.clear ();
|