mirror of the now-defunct rocklinux.org
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

265 lines
8.0 KiB

  1. # --- ROCK-COPYRIGHT-NOTE-BEGIN ---
  2. #
  3. # This copyright note is auto-generated by ./scripts/Create-CopyPatch.
  4. # Please add additional copyright information _after_ the line containing
  5. # the ROCK-COPYRIGHT-NOTE-END tag. Otherwise it might get removed by
  6. # the ./scripts/Create-CopyPatch script. Do not edit this copyright text!
  7. #
  8. # ROCK Linux: rock-src/package/mathieu/streamtuner/live365.patch
  9. # ROCK Linux is Copyright (C) 1998 - 2006 Clifford Wolf
  10. #
  11. # This patch file is dual-licensed. It is available under the license the
  12. # patched project is licensed under, as long as it is an OpenSource license
  13. # as defined at http://www.opensource.org/ (e.g. BSD, X11) or under the terms
  14. # of the GNU General Public License as published by the Free Software
  15. # Foundation; either version 2 of the License, or (at your option) any later
  16. # version.
  17. #
  18. # --- ROCK-COPYRIGHT-NOTE-END ---
  19. diff -ruN streamtuner-0.99.99/src/plugins/live365/live365.c streamtuner-0.99.99-new/src/plugins/live365/live365.c
  20. --- streamtuner-0.99.99/src/plugins/live365/live365.c 2004-12-19 11:27:03.000000000 +0100
  21. +++ streamtuner-0.99.99-new/src/plugins/live365/live365.c 2005-06-15 13:39:16.000000000 +0200
  22. @@ -1,5 +1,5 @@
  23. /*
  24. - * Copyright (c) 2002, 2003, 2004 Jean-Yves Lefort
  25. + * Copyright (C) 2002-2005 Jean-Yves Lefort
  26. * All rights reserved.
  27. *
  28. * Redistribution and use in source and binary forms, with or without
  29. @@ -59,7 +59,9 @@
  30. {
  31. ACCESS_ALL,
  32. ACCESS_VIP,
  33. - ACCESS_SUBSCRIPTION
  34. + ACCESS_SUBSCRIPTION,
  35. + ACCESS_SOLD_OUT,
  36. + ACCESS_UNKNOWN
  37. } Access;
  38. typedef struct
  39. @@ -94,7 +96,8 @@
  40. {
  41. GList **streams;
  42. Live365Stream *stream;
  43. - Live365Stream *finished_stream;
  44. + gboolean first_page;
  45. + gboolean looped;
  46. gboolean has_next_page;
  47. } ReloadStreamsInfo;
  48. @@ -263,13 +266,16 @@
  49. case FIELD_ACCESS_STRING:
  50. {
  51. - const char *str = NULL;
  52. + const char *str;
  53. switch (stream->access)
  54. {
  55. case ACCESS_ALL: str = _("All"); break;
  56. case ACCESS_VIP: str = _("VIP"); break;
  57. case ACCESS_SUBSCRIPTION: str = _("Subscription"); break;
  58. + case ACCESS_SOLD_OUT: str = _("Sold out"); break;
  59. + case ACCESS_UNKNOWN: str = _("Unknown"); break;
  60. + default: str = NULL; break;
  61. }
  62. g_value_set_string(value, str);
  63. @@ -707,14 +713,16 @@
  64. char *s1, *s2, *s3, *s4, *s5;
  65. if ((s1 = st_strstr_span(line, "<a href=\"/cgi-bin/directory"))
  66. - && (s2 = st_strstr_span(s1, "&genre="))
  67. + && (s2 = st_strstr_span(s1, "genre="))
  68. && (s3 = strchr(s2, '"'))
  69. && (s4 = st_strchr_span(s3, '>'))
  70. && (s5 = strstr(s4, "</a>")))
  71. {
  72. category = st_category_new();
  73. category->name = g_strndup(s2, s3 - s2);
  74. - category->label = st_sgml_ref_expand_len(s4, s5 - s4);
  75. + category->label = ! strcmp(category->name, "Recommendations")
  76. + ? g_strdup(_("Recommendations"))
  77. + : st_sgml_ref_expand_len(s4, s5 - s4);
  78. category->url_postfix = g_strconcat(DIRECTORY_PREFIX, category->name, NULL);
  79. }
  80. else if ((s1 = st_strstr_span(line, "<a href=\"/genres/"))
  81. @@ -755,6 +763,8 @@
  82. *streams = NULL;
  83. info.streams = streams;
  84. + info.first_page = TRUE;
  85. + info.looped = FALSE;
  86. session = st_transfer_session_new();
  87. @@ -802,9 +812,11 @@
  88. if (status) /* only display warning if the transfer was otherwise correct */
  89. PARSE_ERROR;
  90. }
  91. +
  92. + info.first_page = FALSE;
  93. }
  94. - while (status && info.has_next_page
  95. - && (stream_limit == -1 || received_streams < stream_limit));
  96. + while (status && info.has_next_page && ! info.looped
  97. + && (stream_limit == -1 || received_streams < stream_limit));
  98. st_transfer_session_free(session);
  99. @@ -818,6 +830,10 @@
  100. char *s1, *s2, *s3, *s4, *s5, *s6, *s7;
  101. char *word1, *word2, *word3;
  102. + /* if we have detected a loop, we just ignore the page */
  103. + if (info->looped)
  104. + return;
  105. +
  106. if ((s1 = st_str_has_prefix_span(line, "<TD CLASS=\"icon\""))
  107. && (s2 = st_strstr_span(s1, "DrawPlayIcon")))
  108. {
  109. @@ -834,15 +850,18 @@
  110. info->stream->access = ACCESS_VIP;
  111. else if (strstr(s2, "'SUBSCRIPTION'"))
  112. info->stream->access = ACCESS_SUBSCRIPTION;
  113. + else if (strstr(s2, "'SOLD_OUT'"))
  114. + info->stream->access = ACCESS_SOLD_OUT;
  115. else
  116. - PARSE_ERROR;
  117. -
  118. - info->finished_stream = NULL;
  119. + {
  120. + PARSE_ERROR;
  121. + info->stream->access = ACCESS_UNKNOWN;
  122. + }
  123. }
  124. else if ((s1 = st_str_has_prefix_span(line, "<TD CLASS=\"title"))
  125. - && (s2 = st_strstr_span(s1, "href='"))
  126. - && (s3 = strstr(s2, "'>"))
  127. - && (s4 = strstr(s3, "</a>")))
  128. + && (s2 = st_strstr_span(s1, "href='"))
  129. + && (s3 = strstr(s2, "'>"))
  130. + && (s4 = strstr(s3, "</a>")))
  131. {
  132. if (info->stream)
  133. {
  134. @@ -865,12 +884,19 @@
  135. else
  136. PARSE_ERROR;
  137. }
  138. - else if ((s1 = st_strstr_span(line, "&station_id="))
  139. - && (s2 = strchr(s1, '&')))
  140. + else if ((s1 = st_str_has_prefix_span(line, "<TD CLASS=\"handle\""))
  141. + && (s2 = st_strstr_span(s1, "ReadCookie("))
  142. + && (s3 = st_strstr_span(s2, ", '"))
  143. + && (s4 = strchr(s3, '\''))
  144. + && (s5 = st_strstr_span(s4, "&station_id="))
  145. + && (s6 = strchr(s5, '&')))
  146. {
  147. if (info->stream)
  148. {
  149. - word1 = g_strndup(s1, s2 - s1);
  150. + g_free(info->stream->broadcaster);
  151. + info->stream->broadcaster = st_sgml_ref_expand_len(s3, s4 - s3);
  152. +
  153. + word1 = g_strndup(s5, s6 - s5);
  154. if (st_str_like(word1, ST_NUMERIC))
  155. info->stream->station_id = atoi(word1);
  156. g_free(word1);
  157. @@ -878,34 +904,23 @@
  158. else
  159. PARSE_ERROR;
  160. }
  161. - else if ((s1 = st_strstr_span(line, "alt=\"More broadcaster info"))
  162. - && (s2 = st_strchr_span(s1, '>'))
  163. - && (s3 = strstr(s2, "</a>")))
  164. - {
  165. - if (info->stream)
  166. - {
  167. - g_free(info->stream->broadcaster);
  168. - info->stream->broadcaster = st_sgml_ref_expand_len(s2, s3 - s2);
  169. - }
  170. - else
  171. - PARSE_ERROR;
  172. - }
  173. else if ((s1 = st_str_has_prefix_span(line, "<TD CLASS=\"connection\""))
  174. && (s2 = st_strchr_span(s1, '>'))
  175. - && (s3 = strstr(s2, "<br>"))
  176. - && ((s4 = strstr(s3, "<img src='/images/mp3pro"))
  177. - || (s4 = strstr(s3, "</TD>"))))
  178. + && (s3 = strchr(s2, '<')))
  179. {
  180. if (info->stream)
  181. {
  182. word1 = st_sgml_ref_expand_len(s2, s3 - s2);
  183. - s3 += 4; word2 = st_sgml_ref_expand_len(s3, s4 - s3);
  184. -
  185. +
  186. g_free(info->stream->audio);
  187. - info->stream->audio = g_strdup_printf(g_str_has_prefix(s4, "</TD>") ? "%s %s" : "%s %s, MP3Pro", word2, word1);
  188. - g_free(word1);
  189. - g_free(word2);
  190. + if (strstr(s3, "<img src='/images/mp3pro"))
  191. + {
  192. + info->stream->audio = g_strdup_printf("%s, MP3Pro", word1);
  193. + g_free(word1);
  194. + }
  195. + else
  196. + info->stream->audio = word1;
  197. }
  198. else
  199. PARSE_ERROR;
  200. @@ -947,12 +962,17 @@
  201. else
  202. PARSE_ERROR;
  203. }
  204. - else if (strstr(line, "TD CLASS=\"tabledesc2\""))
  205. + else if ((s1 = st_strstr_span(line, "<TD CLASS=\"desc\"")))
  206. {
  207. if (info->stream)
  208. {
  209. if (info->stream->station_id)
  210. {
  211. + if ((s2 = st_strstr_span(s1, "<a class='desc-link' href='"))
  212. + && (s3 = st_strchr_span(s2, '>'))
  213. + && (s4 = strstr(s3, "<BR>")))
  214. + info->stream->description = st_sgml_ref_expand_len(s3, s4 - s3);
  215. +
  216. ((STStream *) info->stream)->name = g_strdup_printf("%i", info->stream->station_id);
  217. *(info->streams) = g_list_append(*(info->streams), info->stream);
  218. }
  219. @@ -962,23 +982,23 @@
  220. stream_free_cb(info->stream, NULL);
  221. }
  222. - info->finished_stream = info->stream;
  223. info->stream = NULL;
  224. }
  225. else
  226. PARSE_ERROR;
  227. }
  228. - else if ((s1 = st_strstr_span(line, "<a class='desc-link' href='"))
  229. - && (s2 = st_strchr_span(s1, '>'))
  230. - && (s3 = strstr(s2, "<BR>")))
  231. + else if ((s1 = st_strstr_span(line, "<TD class=\"pagination\""))
  232. + && (s2 = st_strstr_span(s1, ">Showing "))
  233. + && (s3 = strchr(s2, '-')))
  234. {
  235. - if (info->finished_stream)
  236. + word1 = g_strndup(s2, s3 - s2);
  237. + if (st_str_like(word1, ST_NUMERIC))
  238. {
  239. - info->finished_stream->description = st_sgml_ref_expand_len(s2, s3 - s2);
  240. - info->finished_stream = NULL;
  241. + int n = atoi(word1);
  242. + if (n == 1 && ! info->first_page)
  243. + info->looped = TRUE;
  244. }
  245. - else
  246. - PARSE_ERROR;
  247. + g_free(word1);
  248. }
  249. else if (strstr(line, "Next</A>"))
  250. info->has_next_page = TRUE;