Skip to content

Commit

Permalink
Fixes twitch url
Browse files Browse the repository at this point in the history
  • Loading branch information
NejcZdovc committed Jun 25, 2019
1 parent a205ca9 commit 215a051
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 15 deletions.
29 changes: 15 additions & 14 deletions vendor/bat-native-ledger/src/bat/ledger/internal/media/twitch.cc
Original file line number Diff line number Diff line change
Expand Up @@ -424,15 +424,13 @@ void MediaTwitch::OnMediaPublisherInfo(
return;
}

std::string media_url = GetMediaURL(user_id);
std::string oembed_url =
(std::string)TWITCH_VOD_URL + media_props[media_props.size() - 1];

auto callback = std::bind(&MediaTwitch::OnEmbedResponse,
this,
real_duration,
media_key,
media_url,
visit_data,
window_id,
user_id,
Expand All @@ -450,7 +448,7 @@ void MediaTwitch::OnMediaPublisherInfo(
// Live stream
SavePublisherInfo(real_duration,
media_key,
GetMediaURL(media_id),
"",
media_id,
visit_data,
window_id,
Expand All @@ -472,7 +470,6 @@ void MediaTwitch::FetchDataFromUrl(
void MediaTwitch::OnEmbedResponse(
const uint64_t duration,
const std::string& media_key,
const std::string& media_url,
const ledger::VisitData& visit_data,
const uint64_t window_id,
const std::string& user_id,
Expand All @@ -495,7 +492,7 @@ void MediaTwitch::OnEmbedResponse(

SavePublisherInfo(duration,
media_key,
media_url,
"",
author_name,
visit_data,
window_id,
Expand Down Expand Up @@ -542,7 +539,7 @@ void MediaTwitch::OnMediaPublisherActivity(
if (!publisher_favicon_url.empty()) {
SavePublisherInfo(0,
media_key,
GetMediaURL(media_id),
"",
publisher_name,
visit_data,
window_id,
Expand Down Expand Up @@ -584,7 +581,7 @@ void MediaTwitch::OnPublisherInfo(

SavePublisherInfo(0,
media_key,
GetMediaURL(media_id),
"",
publisher_name,
visit_data,
window_id,
Expand Down Expand Up @@ -623,18 +620,22 @@ void MediaTwitch::SavePublisherInfo(const uint64_t duration,
return;
}

ledger::VisitData updated_visit_data(visit_data);

ledger::VisitData new_visit_data;
if (fav_icon.length() > 0) {
updated_visit_data.favicon_url = fav_icon;
new_visit_data.favicon_url = fav_icon;
}

std::string url = publisher_url;
if (url.empty()) {
url = GetMediaURL(channel_id) + "/videos";
}

updated_visit_data.provider = TWITCH_MEDIA_TYPE;
updated_visit_data.name = publisher_name;
updated_visit_data.url = publisher_url + "/videos";
new_visit_data.provider = TWITCH_MEDIA_TYPE;
new_visit_data.name = publisher_name;
new_visit_data.url = url;

ledger_->SaveMediaVisit(key,
updated_visit_data,
new_visit_data,
duration,
window_id);
if (!media_key.empty()) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,6 @@ class MediaTwitch : public ledger::LedgerCallbackHandler {
void OnEmbedResponse(
const uint64_t duration,
const std::string& media_key,
const std::string& media_url,
const ledger::VisitData& visit_data,
const uint64_t window_id,
const std::string& user_id,
Expand Down

0 comments on commit 215a051

Please sign in to comment.