Commit a9f6f8e5 authored by Paweł Wegner's avatar Paweł Wegner
Browse files

YouTube: added youtube_dl_url hint.

parent 5a335fce
......@@ -33,7 +33,24 @@ const std::string VIDEO_ID_PREFIX = "video###";
namespace cloudstorage {
YouTube::YouTube() : CloudProvider(make_unique<Auth>()) {}
YouTube::YouTube()
: CloudProvider(make_unique<Auth>()),
youtube_dl_url_("http://youtube-dl.appspot.com") {}
void YouTube::initialize(const std::string& token,
ICloudProvider::ICallback::Pointer callback,
const ICloudProvider::Hints& hints) {
CloudProvider::initialize(token, std::move(callback), hints);
setWithHint(hints, "youtube_dl_url",
[this](std::string url) { youtube_dl_url_ = url; });
}
ICloudProvider::Hints YouTube::hints() const {
Hints result = {{"youtube_dl_url", youtube_dl_url_}};
auto t = CloudProvider::hints();
result.insert(t.begin(), t.end());
return result;
}
std::string YouTube::name() const { return "youtube"; }
......@@ -152,10 +169,10 @@ IItem::Pointer YouTube::toItem(const Json::Value& v, std::string kind) const {
VIDEO_ID_PREFIX + video_id, IItem::FileType::Video);
item->set_thumbnail_url(
v["snippet"]["thumbnails"]["default"]["url"].asString());
item->set_url(
"http://youtube-dl.appspot.com/api/play?url=https://www.youtube.com/"
"watch?v=" +
video_id);
item->set_url(youtube_dl_url_ +
"/api/play?url=https://www.youtube.com/"
"watch?v=" +
video_id);
return item;
}
}
......
......@@ -34,6 +34,9 @@ class YouTube : public CloudProvider {
public:
YouTube();
void initialize(const std::string& token, ICallback::Pointer,
const Hints& hints);
Hints hints() const;
std::string name() const;
private:
......@@ -59,6 +62,8 @@ class YouTube : public CloudProvider {
public:
std::string authorizeLibraryUrl() const;
};
std::string youtube_dl_url_;
};
} // namespace cloudstorage
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment