From 2dd0af8171cdbad68df06d43aef2e23b86e5bf8b Mon Sep 17 00:00:00 2001 From: Toni Gundogdu Date: Sun, 17 Apr 2011 12:37:50 +0300 Subject: [PATCH] lib/quvi.c: Rewrite to use QUVIOPT_NORESOLVE Rewrite to use QUVIOPT_RESOLVE and resolve_redirection. --- lib/quvi.c | 25 +++++++++++++++++++------ 1 file changed, 19 insertions(+), 6 deletions(-) diff --git a/lib/quvi.c b/lib/quvi.c index 92dca7d..69914dd 100644 --- a/lib/quvi.c +++ b/lib/quvi.c @@ -142,16 +142,27 @@ QUVIcode quvi_parse(quvi_t quvi, char *url, quvi_media_t * dst) if (!video) return (QUVI_MEM); - *dst = video; video->quvi = quvi; + *dst = video; freprintf(&video->page_link, "%s", url); - if (!video->quvi->no_shortened) + if (!video->quvi->no_resolve) { - rc = is_shortened_url(video); + char *redirect_url = NULL; + + rc = resolve_redirection(quvi, video->page_link, &redirect_url); + if (rc != QUVI_OK) return (rc); + else + { + if (redirect_url) + { + freprintf(&video->page_link, "%s", redirect_url); + _free(redirect_url); + } + } } while (1) @@ -161,8 +172,10 @@ QUVIcode quvi_parse(quvi_t quvi, char *url, quvi_media_t * dst) return (rc); else { - if (strlen(video->redirect_url)) /* Found a redirect. */ + if (strlen(video->redirect_url)) { + /* Found an "in-script redirection instruction", not be + * confused with "resolving redirection" */ freprintf(&video->page_link, "%s", video->redirect_url); continue; } @@ -256,8 +269,8 @@ static QUVIcode _setopt(_quvi_t quvi, QUVIoption opt, va_list arg) case QUVIOPT_WRITEFUNCTION: quvi->write_func = va_arg(arg, quvi_callback_write); break; - case QUVIOPT_NOSHORTENED: - _setn(quvi->no_shortened); + case QUVIOPT_NORESOLVE: + _setn(quvi->no_resolve); case QUVIOPT_CATEGORY: _setn(quvi->category); default: -- 2.11.4.GIT