summaryrefslogtreecommitdiffstats
path: root/main/libquvi/fix-redirects.patch
blob: d6352947e1f3e3ec1e18e6b0410140a30cc3ddbb (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
Do not use Effective URL if no redirections happened. This fixes to not
drop 'fragment' part of the URL that some services need to identify the
media to play.

diff -ru libquvi-0.9.4.orig/src/curl/resolve.c libquvi-0.9.4/src/curl/resolve.c
--- libquvi-0.9.4.orig/src/curl/resolve.c	2013-11-04 14:55:25.000000000 -0200
+++ libquvi-0.9.4/src/curl/resolve.c	2014-10-20 16:36:38.493630381 -0300
@@ -61,10 +61,17 @@
 
   if (curlcode == CURLE_OK && r->status.resp_code == 200)
     {
-      gchar *u = NULL;
-      curl_easy_getinfo(c, CURLINFO_EFFECTIVE_URL, &u);
-      /* Leave comparison for resolve_redirections.lua */
-      g_string_assign(r->url.dst, u);
+      long count = 0;
+      curl_easy_getinfo(c, CURLINFO_REDIRECT_COUNT, &count);
+      if (count > 0)
+        {
+          gchar *u = NULL;
+          curl_easy_getinfo(c, CURLINFO_EFFECTIVE_URL, &u);
+          /* Leave comparison for resolve_redirections.lua */
+          g_string_assign(r->url.dst, u);
+        }
+      else
+        g_string_assign(r->url.dst, r->url.addr->str); 
     }
   else
     {