66#include " bat_get_media.h"
77
88#include < sstream>
9+ #include < cmath>
910
1011#include " bat_get_media.h"
1112#include " bat_helper.h"
@@ -95,14 +96,8 @@ void BatGetMedia::getPublisherInfoDataCallback(const std::string& mediaId, const
9596 return ;
9697 }
9798
98- std::vector<std::string> split = braveledger_bat_helper::split (mediaId, ' _' );
99- std::string new_media_id = mediaId;
100- if (!split.empty ()) {
101- new_media_id = split[0 ];
102- }
103-
10499 if (!publisher_info.get ()) {
105- std::string mediaURL = getMediaURL (new_media_id , providerName);
100+ std::string mediaURL = getMediaURL (mediaId , providerName);
106101 if (YOUTUBE_MEDIA_TYPE == providerName) {
107102 auto request = ledger_->LoadURL ((std::string)YOUTUBE_PROVIDER_URL + " ?format=json&url=" + ledger_->URIEncode (mediaURL),
108103 std::vector<std::string>(), " " , " " , ledger::URL_METHOD::GET, &handler_);
@@ -118,12 +113,16 @@ void BatGetMedia::getPublisherInfoDataCallback(const std::string& mediaId, const
118113 _2,
119114 _3));
120115 } else if (TWITCH_MEDIA_TYPE == providerName) {
121- const std::string mediaUrl = getMediaURL (new_media_id, providerName);
116+ const std::string twitchMediaID =
117+ mediaId.find (MEDIA_DELIMITER) != std::string::npos ?
118+ mediaId :
119+ braveledger_bat_helper::split (mediaId, MEDIA_DELIMITER)[0 ];
120+ const std::string mediaUrl = getMediaURL (twitchMediaID, providerName);
122121 std::unique_ptr<ledger::PublisherInfo> new_publisher_info (new ledger::PublisherInfo ());
123122 new_publisher_info->favicon_url = " " ;
124123 new_publisher_info->url = mediaUrl + " /videos" ;
125- std::string id = providerName + " #author:" + new_media_id ;
126- new_publisher_info->name = new_media_id ;
124+ std::string id = providerName + " #author:" + twitchMediaID ;
125+ new_publisher_info->name = twitchMediaID ;
127126 new_publisher_info->id = id;
128127
129128 ledger::TwitchEventInfo oldEvent;
@@ -259,11 +258,15 @@ uint64_t BatGetMedia::getTwitchDuration(const ledger::TwitchEventInfo& oldEventI
259258 return 0 ;
260259 }
261260
261+ if (oldEventInfo.status_ .empty ()) { // if autoplay is off and play is pressed
262+ return 0 ;
263+ }
264+
262265 if (time > TWITCH_MAXIMUM_SECONDS_CHUNK) {
263266 time = TWITCH_MAXIMUM_SECONDS_CHUNK;
264267 }
265268
266- return (uint64_t )time;
269+ return (uint64_t )std::round ( time) ;
267270}
268271
269272void BatGetMedia::getPublisherFromMediaPropsCallback (const uint64_t & duration, const std::string& media_key,
0 commit comments