From 4bc0f0764682b14074fe092c7b55281ac5f00b16 Mon Sep 17 00:00:00 2001 From: martii Date: Sun, 9 Jun 2013 11:05:25 +0200 Subject: [PATCH] yt: need to encode search string Origin commit data ------------------ Branch: ni/coolstream Commit: https://github.com/neutrino-images/ni-neutrino/commit/50e953cf27538e0e41f0e4571d95a465ac22ddcc Author: martii Date: 2013-06-09 (Sun, 09 Jun 2013) ------------------ No further description and justification available within origin commit message! ------------------ This commit was generated by Migit --- src/system/ytparser.cpp | 11 +++++++++++ src/system/ytparser.h | 1 + 2 files changed, 12 insertions(+) diff --git a/src/system/ytparser.cpp b/src/system/ytparser.cpp index 14074b407..012684e77 100644 --- a/src/system/ytparser.cpp +++ b/src/system/ytparser.cpp @@ -168,6 +168,16 @@ void cYTFeedParser::decodeUrl(std::string &url) curl_free(str); } +void cYTFeedParser::encodeUrl(std::string &txt) +{ + CURL * curl_handle = curl_easy_init(); + char * str = curl_easy_escape(curl_handle, txt.c_str(), txt.length()); + curl_easy_cleanup(curl_handle); + if(str) + txt = str; + curl_free(str); +} + void cYTFeedParser::splitString(std::string &str, std::string delim, std::vector &strlist, int start) { strlist.clear(); @@ -502,6 +512,7 @@ bool cYTFeedParser::ParseFeed(yt_feed_mode_t mode, std::string search, std::stri else if (mode == SEARCH) { if (search.empty()) return false; + encodeUrl(search); url = "http://gdata.youtube.com/feeds/api/videos?q="; url += search; url += "&"; diff --git a/src/system/ytparser.h b/src/system/ytparser.h index 357ac1409..8978f7ef0 100644 --- a/src/system/ytparser.h +++ b/src/system/ytparser.h @@ -88,6 +88,7 @@ class cYTFeedParser std::string getXmlData(xmlNodePtr node); static size_t CurlWriteToString(void *ptr, size_t size, size_t nmemb, void *data); + static void encodeUrl(std::string &txt); static void decodeUrl(std::string &url); static void splitString(std::string &str, std::string delim, std::vector &strlist, int start = 0); static void splitString(std::string &str, std::string delim, std::map &strmap, int start = 0);