Skip to content

Commit

Permalink
Fix live playurl
Browse files Browse the repository at this point in the history
  • Loading branch information
typcn committed Oct 11, 2015
1 parent 4223d09 commit e6ce35b
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 3 deletions.
2 changes: 1 addition & 1 deletion bilibili/Info.plist
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
</dict>
</array>
<key>CFBundleVersion</key>
<string>1092</string>
<string>1096</string>
<key>LSApplicationCategoryType</key>
<string>public.app-category.video</string>
<key>LSMinimumSystemVersion</key>
Expand Down
21 changes: 19 additions & 2 deletions bilibili/PlayerView/PlayerView.mm
Original file line number Diff line number Diff line change
Expand Up @@ -209,7 +209,7 @@ - (void)LoadVideo{
}
return;
}else if([vUrl containsString:@"live.bilibili"]){
baseAPIUrl = @"http://live.bilibili.com/api/playurl?platform=android&_device=android&_hwid=%@&_aid=%@&_tid=0&_p=%@&_down=0&cid=%@&quality=%d&otype=json&appkey=%@&type=%@&sign=%@";
baseAPIUrl = @"http://live.bilibili.com/api/playurl?platform=android&_appver=406001&_buvid=%@infoc&_device=android&_hwid=%@&_aid=0&_tid=0&_p=%@&_down=0&cid=%@&quality=1&otype=json&appkey=%@&type=mp4&sign=%@";
vAID = @"LIVE";
vPID = @"LIVE";
}else{
Expand Down Expand Up @@ -246,13 +246,30 @@ - (void)LoadVideo{
type = @"mp4";
}
getUrl: NSLog(@"Getting video url");

NSString *param = [NSString stringWithFormat:@"platform=android&_device=android&_hwid=%@&_aid=%@&_tid=0&_p=%@&_down=0&cid=%@&quality=%d&otype=json&appkey=%@&type=%@%@",hwid,vAID,vPID,vCID,quality,APIKey,type,APISecret];
NSString *uuid = [[NSUUID UUID] UUIDString];
NSString *rndhwid = [self randomStringWithLength:16];

if([vPID isEqualToString:@"LIVE"]){
NSLog(@"Generate LIVE Params");
param = [NSString stringWithFormat:@"platform=android&_appver=406001&_buvid=%@infoc&_device=android&_hwid=%@&_aid=0&_tid=0&_p=%@&_down=0&cid=%@&quality=1&otype=json&appkey=%@&type=mp4&sign=%@",uuid,rndhwid,vCID,vCID,APIKey,APISecret];
}

NSString *sign = [self md5:[param stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding]];

// Get Playback URL

NSURL* URL = [NSURL URLWithString:[NSString stringWithFormat:baseAPIUrl,hwid,vAID,vPID,vCID,quality,APIKey,type,sign]];
NSString *pbUrl;

if([vPID isEqualToString:@"LIVE"]){
NSLog(@"Generate LIVE APIUrl");
pbUrl = [NSString stringWithFormat:baseAPIUrl,uuid,rndhwid,vCID,vCID,APIKey,sign];
}else{
pbUrl = [NSString stringWithFormat:baseAPIUrl,hwid,vAID,vPID,vCID,quality,APIKey,type,sign];
}

NSURL* URL = [NSURL URLWithString:pbUrl];
NSLog(@"APIURL %@",[URL absoluteString]);
NSMutableURLRequest* request = [NSMutableURLRequest requestWithURL:URL];
request.HTTPMethod = @"GET";
Expand Down

0 comments on commit e6ce35b

Please sign in to comment.