????????既上一篇解析愛奇藝的視頻地址冒版,解析樂視的視頻也是需要視頻的網(wǎng)頁地址魄眉。然后一步一步的剝離出真正的視頻地址薇组。
大概流程:
-- 讀取信息的API
-- 拼接完整的API
-- 獲取偽裝視頻的url
-- 獲取真正的視頻地址
一:拼接讀取偽裝地址的API
? ?NSString * API_URL = @"http://player-pc.le.com/mms/out/video/playJson?????????id=%@&platid=1&splatid=101&format=1&source=1000&tkey=%d&domain=www.le.com?ion=cn&accesyx=1";
?? ? ? ? NSString * idkey = [[[[url componentsSeparatedByString:@"/"] lastObject] componentsSeparatedByString:@"."] firstObject];
????????int loc = 185025305;
?? ? ? ?NSInteger timeSch = (NSInteger)[NSDate date].timeIntervalSince1970;
? ? ? ? long tkey = [self rorpa:timeSchpb:loc%17] ^ loc;
?? ? ? ?NSString* urlStr = [NSString stringWithFormat:API_URL,idkey,tkey];
-(long)rorpa:(NSInteger)pa pb:(NSInteger)pb{
? ? long? pc =0;
? ? while(pc<pb) {
? ? ? ? pa = [self urshift:pan:1] + ((pa &1)<<31);
? ? ? ? pc+=1;
? ? }
? ? returnpa;
}
-(long)urshift:(long)val n:(long)n{
? ? return val >=0? val >> n : (val +0x100000000L) >> n;
}?
二)獲取偽裝的視頻地址
#define parames @"&m3v=1&format=1&expect=3&tss=ios";
-(void)getReultdata:(NSString*)urlStr{
? ? [self.videoArr removeAllObjects];
? ? AFHTTPSessionManager * afMn = [AFHTTPSessionManager manager];
? ? afMn.responseSerializer = [AFHTTPResponseSerializer serializer];
? ? [afMn GET:urlStr parameters:nil progress:^(NSProgress *_Nonnull downloadProgress) {
? ? } success:^(NSURLSessionDataTask * _Nonnull task,id? _Nullable responseObject) {
? ? ? ? NSDictionary * dic = [NSJSONSerialization JSONObjectWithData:responseObject options:NSJSONReadingMutableContainers error:nil];
? ? ? ? NSDictionary * videoDic = [dic objectForKey:@"msgs"];
? ? ? ? NSDictionary * playUrl = [videoDic objectForKey:@"playurl"];
? ? ? ? if(playUrl && playUrl.count>0) ? ? ? ?{
? ? ? ? ? ? NSString * domain = [[playUrl objectForKey:@"domain"] firstObject];
? ? ? ? ? ? NSDictionary * urlArr = [playUrl objectForKey:@"dispatch"];
? ? ? ? ? ? /*for (NSString * key in urlArr) //這個(gè)是獲取所有的數(shù)據(jù) {
?? ? ? ? ? ?}*/
?? ? ? ? ? ?//現(xiàn)在只需要獲取第一個(gè)數(shù)據(jù)就可以了
? ? ? ? ? ? NSString * key = [[urlArr allKeys] firstObject];
? ? ? ? ? ? NSString * urlPg = [[urlArr objectForKey:key] firstObject];
? ? ? ? ? ? VideoModel * video = [VideoModel new];
? ? ? ? ? ? video.videoName = [playUrl objectForKey:@"title"];
? ? ? ? ? ? video.videoMilliseconds = [[playUrl objectForKey:@"duration"] integerValue];
? ? ? ? ? ? video.videopng = [playUrl objectForKey:@"pic"];
? ? ? ? ? ? video.srcUrl = urlStr;
? ? ? ? ? ? video.streamType = key;
? ? ? ? ? ? NSString * pg =parames;
? ? ? ? ? ? NSString * viurl = [[domain stringByAppendingString:urlPg] stringByAppendingString:pg];
? ? ? ? ? ? [selfgetVideoUrl:viurl video:video];
? ? ? ? }
? ? ? ? else ?{
? ? ? ? ? ? self.anLyBlock([NSMutableArray array]);
? ? ? ? }
?? ?} failure:^(NSURLSessionDataTask *_Nullable task, NSError *_Nonnull error) {
? ? ? ? //失敗
? ? ? ? if(self.anLyBlock)
? ? ? ? ? ? self.anLyBlock([NSMutableArray array]);
? ? }];
}
三)獲取真正的視頻地址
-(void)getVideoUrl:(NSString*)url video:(VideoModel*)video{
? ? AFHTTPSessionManager * afMn = [AFHTTPSessionManager manager];
? ? afMn.responseSerializer = [AFHTTPResponseSerializer serializer];
? ? [afMn GET:url parameters:nil progress:^(NSProgress *_Nonnull downloadProgress) {
? ? } success:^(NSURLSessionDataTask *_Nonnull task,id? _Nullable responseObject) {
? ? ? ? NSDictionary * dic = [NSJSONSerialization JSONObjectWithData:responseObject options:NSJSONReadingMutableContainers error:nil];
? ? ? ? NSDictionary * videoDic = [[dic objectForKey:@"nodelist"] firstObject];
? ? ? ? video.videoUrl = [videoDic objectForKey:@"location"];
? ? ? ? [self.videoArr addObject:video];
? ? ? ? __weaktypeof(self) weakSelf =self;
? ? ? ? if(self.anLyBlock)
? ? ? ? ? ? self.anLyBlock(weakSelf.videoArr);
? ? } failure:^(NSURLSessionDataTask *_Nullable task, NSError *_Nonnull error) {
? ? ? ? if(self.anLyBlock)
? ? ? ? ? ? self.anLyBlock([NSMutableArray array]);
? ? }];
}
如有不合理的地方趁怔,請(qǐng)斧正队腐。
申明:這只是自己的一些研究而已蚕捉,請(qǐng)不要用于商業(yè)用途。如果影響到你的利益柴淘,請(qǐng)聯(lián)系我迫淹。