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.

246 lines
7.1 KiB

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