Internetradio: Update to Shoutcast API 2.0

Wünsche, Anträge, Fehlermeldungen
Houdini
Developer
Beiträge: 2183
Registriert: Mittwoch 10. Dezember 2003, 07:59

Internetradio: Update to Shoutcast API 2.0

Beitrag von Houdini »

auch wenns nicht mit den Shoutcast Bedingungen vereinbar ist...
Die SC_DEV_ID gibts erstmal nur von google

Code: Alles auswählen

Index: gui/audioplayer.cpp
===================================================================
RCS file: /cvs/tuxbox/apps/tuxbox/neutrino/src/gui/audioplayer.cpp,v
retrieving revision 1.85
diff -u -r1.85 audioplayer.cpp
--- a/gui/audioplayer.cpp	14 Jun 2010 06:37:10 -0000	1.85
+++ b/gui/audioplayer.cpp	23 Dec 2010 20:24:56 -0000
@@ -1386,8 +1389,7 @@
 }
 
 //------------------------------------------------------------------------
-#define SC_BASE_DIR	"http://www.shoutcast.com"
-#define SC_INIT_DIR	"/sbin/newxml.phtml"
+
 bool CAudioPlayerGui::openSCbrowser(void)
 {
 	bool result = false;
Index: gui/filebrowser.cpp
===================================================================
RCS file: /cvs/tuxbox/apps/tuxbox/neutrino/src/gui/filebrowser.cpp,v
retrieving revision 1.136
diff -u -r1.136 filebrowser.cpp
--- a/gui/filebrowser.cpp	13 Jun 2010 17:41:02 -0000	1.136
+++ b/gui/filebrowser.cpp	23 Dec 2010 20:24:57 -0000
@@ -82,6 +82,7 @@
 #error not using 64 bit file offsets
 #endif
 
+
 #define SMSKEY_TIMEOUT 2000
 //------------------------------------------------------------------------
 size_t CurlWriteToString(void *ptr, size_t size, size_t nmemb, void *data)
@@ -694,7 +695,7 @@
 					CFile file;
 					file.Mode = S_IFDIR + 0777 ;
 					file.Name = " Top500"; // use space to have it at the beginning of the list
-					file.Url = "/sbin/newxml.phtml?genre=Top500";
+					file.Url = SC_GET_TOP500;
 					file.Size = 0;
 					file.Time = 0;
 					flist->push_back(file);
@@ -702,7 +703,7 @@
 					CFile file2;
 					file2.Mode = S_IFDIR + 0777 ;
 					file2.Name = "..";
-					file2.Url = "/sbin/newxml.phtml";
+					file2.Url = SC_INIT_DIR;
 					file2.Size = 0;
 					file2.Time = 0;
 					flist->push_back(file2);
@@ -712,7 +713,7 @@
 					if (xml_decode == 1) {
 						file.Mode = S_IFDIR + 0777 ;
 						file.Name = xmlGetAttribute(element, "name");
-						file.Url = "/sbin/newxml.phtml?genre=" + file.Name;
+						file.Url = (std::string)SC_GET_GENRE + file.Name;
 						file.Size = 0;
 						file.Time = 0;
 						flist->push_back(file);
@@ -729,7 +730,7 @@
 								if (ptr && (strcmp(ptr, "audio/mpeg")==0)) {
 									file.Mode = S_IFREG + 0777 ;
 									file.Name = xmlGetAttribute(element, "name");
-									file.Url = base + tunein_base + (std::string)"?id=" + xmlGetAttribute(element, "id");
+									file.Url = (std::string)SC_TUNE_IN_BASE + tunein_base + (std::string)"?id=" + xmlGetAttribute(element, "id") + (std::string)"&k=" + SC_DEV_ID;
 									//printf("adding %s (%s)\n", file.Name.c_str(), file.Url.c_str());
 									ptr = xmlGetAttribute(element, "br");
 									if (ptr) {
Index: gui/filebrowser.h
===================================================================
RCS file: /cvs/tuxbox/apps/tuxbox/neutrino/src/gui/filebrowser.h,v
retrieving revision 1.42
diff -u -r1.42 filebrowser.h
--- a/gui/filebrowser.h	18 Aug 2009 11:51:59 -0000	1.42
+++ b/gui/filebrowser.h	23 Dec 2010 20:24:57 -0000
@@ -55,6 +55,18 @@
 
 #define VLC_URI "vlc://"
 
+#if 0
+#define SC_BASE_DIR	"http://www.shoutcast.com"
+#define SC_INIT_DIR	"/sbin/newxml.phtml"
+#else
+#define SC_DEV_ID		"???"
+#define SC_BASE_DIR		"http://api.shoutcast.com"
+#define SC_TUNE_IN_BASE		"http://yp.shoutcast.com"
+#define SC_INIT_DIR		"/legacy/genrelist?k="SC_DEV_ID
+#define SC_GET_GENRE		"/legacy/stationsearch?k="SC_DEV_ID"&search="
+#define SC_GET_TOP500		"/legacy/Top500?k="SC_DEV_ID
+#endif
+
 /**
  * Converts input of numeric keys to SMS style char input.
  */
GetAway
Contributor
Beiträge: 1509
Registriert: Donnerstag 27. Dezember 2007, 12:59

Re: Internetradio: Update to Shoutcast API 2.0

Beitrag von GetAway »

@Houdini

Patch: shoutcast_api2.0_2010_12_15_2304.diff

Besten Dank. Wäre es nicht besser die Developer ID aus einer Datei einzulesen?
Das Hardcoden ist doch suboptimal.
Houdini
Developer
Beiträge: 2183
Registriert: Mittwoch 10. Dezember 2003, 07:59

Re: Internetradio: Update to Shoutcast API 2.0

Beitrag von Houdini »

> Wäre es nicht besser die Developer ID aus einer Datei einzulesen?

Ja stimmt,
ich hatte das mal kurz zu Test zusammengehackt.