视频地址破解
2022-07-18 本文已影响0人
冬的天
#define VoidPlayAPI @"https://api.bilibili.com/x/web-interface/view"
#define VoidPlayDetailAPI @"https://api.bilibili.com/x/player/playurl?callback=callbackfunction&page=1&platform=html5&quality=3&vtype=mp4&type=jsonp"
-初始视频ids来源:b站视频页面,右键打开源码,搜索aid找到对应的值(一串数字)即可按照下面流程开始!
-(void)resqData:(NSString*)ids{
NSDictionary*dic=@{@"aid":ids};
[NetWork GET:VoidPlayAPI parameters:dic successWtihBlock:^(id responseObject) {
NSLog(@"ssse---%@",responseObject);
NSDictionary*dict=responseObject[@"data"];
NSString*str=[NSString stringWithFormat:@"%@",dict[@"aid"]];
NSString*str1=[NSString stringWithFormat:@"%@",dict[@"cid"]];
NSLog(@"ssse---%@--%@",str,str1);
[self resqVoid:str cid:str1];
[MBProgressHUD hideHUD];
} failure:^(NSError *error) {
[MBProgressHUD hideHUD];
}] ;
}
-(void)resqVoid:(NSString*)aid cid:(NSString*)cid{
NSDictionary*dic=@{@"avid":aid,@"cid":cid};
[NetWork GET:VoidPlayDetailAPI parameters:dic successWtihBlock:^(id responseObject) {
NSString*pourl=[NSString stringWithFormat:@"%@", responseObject[@"data"][@"durl"][0][@"url"]];
NSLog(@"pourl___%@",pourl);
NSURL *webVideoUrl =[NSURL URLWithString:pourl];
self.item=[AVPlayerItem playerItemWithURL:webVideoUrl];
//设置AVPlayer中的AVPlayerItem
self.player=[AVPlayer playerWithPlayerItem:self.item];
//初始化AVPlayerViewController
self.moviePlayer=[[playViewController alloc]init];
self.moviePlayer.showsPlaybackControls = YES;
self.moviePlayer.player=self.player;
[self.player play];
//设置AVPlayerViewController的frame
self.moviePlayer.view.frame=SCREEN_FRAME;
[self presentViewController:self.moviePlayer animated:YES completion:nil];
} failure:^(NSError *error) {
}];
}