教你下载ditto视频app中的好玩视频
1.ditto视频app
重点内容
2.首先是抓包获取app的视频地址
用charles
开启代理:
同一wifi下,手机设置电脑的代理ip:
然后就抓了,这么多抓包工具,随便你用什么工具了,windows可以用findler.
最后获取的数据接口为:
http://ditto.short.tv/api/v1/videos
http://ditto.short.tv/api/v1/sliders
http://ditto.short.tv/api/v1/videos/153
http://ditto.short.tv/api/v1/videos?page=2
3.用网页分析返回的json:
所需的就是这个url了
4.获取url,因为我是ios开发,所以直接上ios代码了
- (void)getDittoVideos {
for (int i = 1;i <= 3; i++) {
NSString *url = [NSString stringWithFormat:@"http://ditto.short.tv/api/v1/videos?page=%d",i];
AFHTTPRequestOperationManager *manager = [AFHTTPRequestOperationManager manager];
[manager GET:url parameters:nil success:^(AFHTTPRequestOperation *operation, id responseObject) {
NSLog(@"%d\n",i);
NSString *detail = @"";
NSArray *videoList = responseObject;
for (int j=0;j<videoList.count;j++) {
NSString *name = [NSString stringWithFormat:@"%@.%@.mp4#%@",videoList[j][@"id"],videoList[j][@"title"],videoList[j][@"url"][@"m3u8"]];
detail = [NSString stringWithFormat:@"%@\n%@",detail,name];
}
NSLog(@"%@",detail);
} failure:^(AFHTTPRequestOperation *operation, NSError *error) {
}];
}
}
5.地址为m3u8,是一种直播的格式,不是mp4格式,所以用常规方法下载是不行的了,下载m3u8可以用ffmpeg下载
ffmpeg下载地址:https://www.ffmpeg.org/
下载命令:
./ffmpeg -i "url" -c copy -bsf:a aac_adtstoasc "fileName.mp4"
6.下载为mp4格式(python)
#coding=utf-8
import re,urllib2,os
for line in open("url.txt"):
contents = line.split(‘#‘)
name = contents[0]
url = contents[1]
urlTmp = url.split()
cmd = "./ffmpeg -i \"%s\" -c copy -bsf:a aac_adtstoasc \"%s\"" % (urlTmp[0],name)
os.system(cmd)
7.ok了,视频都下载下来了
原文地址:http://blog.csdn.net/rainlesvio/article/details/45921233