streamtuner-0.99.99-live365.diff 7.0 KB

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