MCDataEngine.m 23 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490
  1. //
  2. // MCDataEngine.m
  3. // MeiCheng
  4. //
  5. //
  6. #import "MCDataEngine.h"
  7. #import "FMSongListModel.h"
  8. #import "FMSongModel.h"
  9. #import "FMTDMovieModel.h"
  10. #define DocumentsPath [NSHomeDirectory() stringByAppendingPathComponent:@"Documents"]
  11. NSString * error_code = @"error_code";
  12. NSString * ting_uid = @"ting_uid";
  13. NSString * name = @"name";
  14. NSString * firstchar = @"firstchar";
  15. NSString * gender = @"gender";
  16. NSString * area = @"area";
  17. NSString * country = @"country";
  18. NSString * avatar_big = @"avatar_big";
  19. NSString * avatar_middle = @"avatar_middle";
  20. NSString * avatar_small = @"avatar_small";
  21. NSString * avatar_mini = @"avatar_mini";
  22. NSString * constellation = @"constellation";
  23. NSString * stature = @"stature";
  24. NSString * weight = @"weight";
  25. NSString * bloodtype = @"bloodtype";
  26. NSString * company = @"company";
  27. NSString * intro = @"intro";
  28. NSString * songs_total = @"songs_total";
  29. NSString * albums_total = @"albums_total";
  30. NSString * birth = @"birth";
  31. NSString * url = @"url";
  32. NSString * artist_id = @"artist_id";
  33. NSString * avatar_s180 = @"avatar_s180";
  34. NSString * avatar_s500 = @"avatar_s500";
  35. NSString * avatar_s1000 = @"avatar_s1000";
  36. NSString * piao_id = @"piao_id";
  37. NSString * songlist= @"songlist";
  38. #import "FMSingerModel.h"
  39. @implementation MCDataEngine
  40. -(MKNetworkOperation *)getSingerInformationWith:(long long)tinguid WithCompletionHandler:(SalesResponseBlock)completion errorHandler:(MKNKErrorBlock)errorHandler
  41. {
  42. self.showError = YES;
  43. NSString *urlPath = [NSString stringWithFormat:@"/v1/restserver/ting?from=android&version=2.4.0&method=baidu.ting.artist.getinfo&format=json&tinguid=%lld",tinguid];
  44. MKNetworkOperation *op = [self operationWithPath:urlPath];
  45. [op addCompletionHandler:^(MKNetworkOperation *completedOperation) {
  46. id respJson = [completedOperation responseJSON];
  47. if ([self checkError:respJson]) {
  48. return ;
  49. }
  50. // NSLog(@"resp:%@",respJson);
  51. @try{
  52. NSMutableArray * array = [NSMutableArray new];
  53. NSDictionary * dictionary = respJson;
  54. if ([[dictionary allKeys] count]>1) {
  55. FMSingerModel * model = [FMSingerModel new];
  56. model.ting_uid = [[dictionary objectForKey:ting_uid] longLongValue];
  57. model.name = [dictionary objectForKey:name];
  58. model.firstchar = [dictionary objectForKey:firstchar];
  59. model.gender = [[dictionary objectForKey:gender] intValue];
  60. model.area = [[dictionary objectForKey:area] intValue];
  61. model.country = [dictionary objectForKey:country];
  62. model.avatar_big = [dictionary objectForKey:avatar_big];
  63. model.avatar_middle =[dictionary objectForKey:avatar_middle];
  64. model.avatar_small = [dictionary objectForKey:avatar_small];
  65. model.avatar_mini =[dictionary objectForKey:avatar_mini];
  66. model.constellation = [dictionary objectForKey:constellation];
  67. if ([dictionary objectForKey:stature]!=[NSNull null]) {
  68. model.stature = [[dictionary objectForKey:stature] floatValue];
  69. }else{
  70. model.stature = 0.00f;
  71. }
  72. if ([dictionary objectForKey:weight]!=[NSNull null]) {
  73. model.weight = [[dictionary objectForKey:weight] floatValue];
  74. }else{
  75. model.weight = 0.00f;
  76. }
  77. model.bloodtype = [dictionary objectForKey:bloodtype];
  78. model.company =[dictionary objectForKey:company];
  79. model.intro =[dictionary objectForKey:intro];
  80. model.albums_total = [[dictionary objectForKey:albums_total] intValue];
  81. model.songs_total = [[dictionary objectForKey:songs_total] intValue];
  82. model.birth = [dictionary objectForKey:birth];
  83. model.url = [dictionary objectForKey:url];
  84. model.artist_id = [[dictionary objectForKey:artist_id] intValue];
  85. model.avatar_s180 = [dictionary objectForKey:avatar_s180];
  86. model.avatar_s500 = [dictionary objectForKey:avatar_s500];
  87. model.avatar_s1000 = [dictionary objectForKey:avatar_s1000];
  88. model.piao_id = [[dictionary objectForKey:piao_id] intValue];
  89. BOOL sucess = [FMSingerModel insertToDB:model];
  90. if (sucess) {
  91. NSLog(@"%@ sucess %lld",model.name,model.ting_uid);
  92. }
  93. }else{
  94. int errorcode = [[dictionary objectForKey:error_code] intValue];
  95. NSLog(@"%d",errorcode);
  96. }
  97. completion(array);
  98. }
  99. @catch (NSException *exception) {
  100. KHError *appError = [[KHError alloc] initWithDomain:kHAppErrorDomain code:100 userInfo:nil];
  101. appError.reason = kHErrorParse;
  102. errorHandler(appError);
  103. }
  104. } errorHandler:^(MKNetworkOperation *completedOperation, NSError *error) {
  105. NSLog(@"ERROR:%@",error);
  106. KHError *appError = [[KHError alloc] initWithMKNetworkOperation:completedOperation error:error];
  107. errorHandler(appError);
  108. }];
  109. [self enqueueOperation:op];
  110. return op;
  111. }
  112. -(MKNetworkOperation *)getSingerSongListWith:(long long)tinguid :(int)number
  113. WithCompletionHandler:(FMSongListModelResponseBlock)completion
  114. errorHandler:(MKNKErrorBlock)errorHandler
  115. {
  116. self.showError = YES;
  117. NSString *urlPath = [NSString stringWithFormat:@"/v1/restserver/ting?from=android&version=2.4.0&method=baidu.ting.artist.getSongList&format=json&order=2&tinguid=%lld&offset=0&limits=%d",tinguid,number];
  118. MKNetworkOperation *op = [self operationWithPath:urlPath];
  119. [op addCompletionHandler:^(MKNetworkOperation *completedOperation) {
  120. id respJson = [completedOperation responseJSON];
  121. if ([self checkError:respJson]) {
  122. return ;
  123. }
  124. // NSLog(@"resp:%@",respJson);
  125. FMSongList * list = [FMSongList new];
  126. @try{
  127. NSDictionary * dictionary = respJson;
  128. if ([[dictionary allKeys] count]>1) {
  129. list.songnums = [[dictionary objectForKey:@"songnums"] intValue];
  130. list.havemore = [[dictionary objectForKey:@"havemore"] boolValue];
  131. list.error_code =[[dictionary objectForKey:@"error_code"] intValue];
  132. NSArray * temp = [dictionary objectForKey:songlist];
  133. for (NSDictionary * dict in temp) {
  134. FMSongListModel * model = [FMSongListModel new];
  135. model.artist_id = [[dict objectForKey:@"artist_id"] intValue];
  136. model.all_artist_ting_uid = [[dict objectForKey:@"all_artist_ting_uid"] intValue];
  137. model.all_artist_id = [[dict objectForKey:@"all_artist_id"] intValue];
  138. model.language = [dict objectForKey:@"language"];
  139. model.publishtime = [dict objectForKey:@"publishtime"];
  140. model.album_no = [[dict objectForKey:@"album_no"] intValue];
  141. model.pic_big = [dict objectForKey:@"pic_big"];
  142. model.pic_small = [dict objectForKey:@"pic_small"];
  143. model.country = [dict objectForKey:@"country"];
  144. model.area = [[dict objectForKey:@"area"] intValue];
  145. model.lrclink = [dict objectForKey:@"lrclink"];
  146. model.hot = [[dict objectForKey:@"hot"] intValue];
  147. model.file_duration = [[dict objectForKey:@"file_duration"] intValue];
  148. model.del_status = [[dict objectForKey:@"del_status"] intValue];
  149. model.resource_type = [[dict objectForKey:@"resource_type"] intValue];
  150. model.copy_type = [[dict objectForKey:@"copy_type"] intValue];
  151. model.relate_status = [[dict objectForKey:@"relate_status"] intValue];
  152. model.all_rate = [[dict objectForKey:@"all_rate"] intValue];
  153. model.has_mv_mobile = [[dict objectForKey:@"has_mv_mobile"] intValue];
  154. model.toneid = [[dict objectForKey:@"toneid"] longLongValue];
  155. model.song_id = [[dict objectForKey:@"song_id"] longLongValue];
  156. model.title = [dict objectForKey:@"title"];
  157. model.ting_uid = [[dict objectForKey:@"ting_uid"] longLongValue];
  158. model.author = [dict objectForKey:@"author"];
  159. model.album_id = [[dict objectForKey:@"album_id"] longLongValue];
  160. model.album_title = [dict objectForKey:@"album_title"];
  161. model.is_first_publish = [[dict objectForKey:@"is_first_publish"] intValue];
  162. model.havehigh = [[dict objectForKey:@"havehigh"] intValue];
  163. model.charge = [[dict objectForKey:@"charge"] intValue];
  164. model.has_mv = [[dict objectForKey:@"has_mv"] intValue];
  165. model.learn = [[dict objectForKey:@"learn"] intValue];
  166. model.piao_id = [[dict objectForKey:@"piao_id"] intValue];
  167. model.listen_total = [[dict objectForKey:@"listen_total"] longLongValue];
  168. [list.songLists addObject:model];
  169. }
  170. }else{
  171. int errorcode = [[dictionary objectForKey:error_code] intValue];
  172. NSLog(@"%d",errorcode);
  173. }
  174. completion(list);
  175. }
  176. @catch (NSException *exception) {
  177. KHError *appError = [[KHError alloc] initWithDomain:kHAppErrorDomain code:100 userInfo:nil];
  178. appError.reason = kHErrorParse;
  179. errorHandler(appError);
  180. }
  181. } errorHandler:^(MKNetworkOperation *completedOperation, NSError *error) {
  182. NSLog(@"ERROR:%@",error);
  183. KHError *appError = [[KHError alloc] initWithMKNetworkOperation:completedOperation error:error];
  184. errorHandler(appError);
  185. }];
  186. [self enqueueOperation:op];
  187. return op;
  188. }
  189. -(MKNetworkOperation *)getSongInformationWith:(long long)songID
  190. WithCompletionHandler:(FMSongModelResponseBlock)completion
  191. errorHandler:(MKNKErrorBlock)errorHandler
  192. {
  193. self.showError = YES;
  194. NSString *urlPath = [NSString stringWithFormat:@"/data/music/links?songIds=%lld",songID];
  195. KHNetworkEngine * netwrok = [self initWithHostName:@"ting.baidu.com"];
  196. MKNetworkOperation *op = [netwrok operationWithPath:urlPath];
  197. [op addCompletionHandler:^(MKNetworkOperation *completedOperation) {
  198. id respJson = [completedOperation responseJSON];
  199. if ([self checkError:respJson]) {
  200. return ;
  201. }
  202. // NSLog(@"resp:%@",respJson);
  203. FMSongModel * song = [FMSongModel new];
  204. @try{
  205. NSDictionary * dictionary = respJson;
  206. if ([[dictionary allKeys] count]>1) {
  207. NSDictionary * data = [dictionary objectForKey:@"data"];
  208. NSArray * songList = [data objectForKey:@"songList"];
  209. for (NSDictionary * sub in songList) {
  210. song.songLink = [sub objectForKey:@"songLink"];
  211. NSRange range = [song.songLink rangeOfString:@"src"];
  212. if (range.location != 2147483647 && range.length != 0) {
  213. NSString * temp = [song.songLink substringToIndex:range.location-1];
  214. song.songLink = temp;
  215. }
  216. song.songName = [sub objectForKey:@"songName"];
  217. song.lrcLink = [sub objectForKey:@"lrcLink"];
  218. song.songPicBig = [sub objectForKey:@"songPicBig"];
  219. song.time = [[sub objectForKey:@"time"] intValue];
  220. }
  221. }else{
  222. int errorcode = [[dictionary objectForKey:error_code] intValue];
  223. NSLog(@"%d",errorcode);
  224. }
  225. completion(song);
  226. }
  227. @catch (NSException *exception) {
  228. KHError *appError = [[KHError alloc] initWithDomain:kHAppErrorDomain code:100 userInfo:nil];
  229. appError.reason = kHErrorParse;
  230. errorHandler(appError);
  231. }
  232. } errorHandler:^(MKNetworkOperation *completedOperation, NSError *error) {
  233. NSLog(@"ERROR:%@",error);
  234. KHError *appError = [[KHError alloc] initWithMKNetworkOperation:completedOperation error:error];
  235. errorHandler(appError);
  236. }];
  237. [self enqueueOperation:op];
  238. return op;
  239. }
  240. -(MKNetworkOperation *)getSongLrcWith:(long long)tingUid :(long long)songID :(NSString *)lrclink
  241. WithCompletionHandler:(FMSongLrcResponseBlock)completion
  242. errorHandler:(MKNKErrorBlock)errorHandler
  243. {
  244. self.showError = YES;
  245. KHNetworkEngine * netwrok = [self initWithHostName:@"ting.baidu.com"];
  246. MKNetworkOperation *op = [netwrok operationWithPath:lrclink];
  247. [op addCompletionHandler:^(MKNetworkOperation *completedOperation) {
  248. NSData * respData = [completedOperation responseData];
  249. if ([self checkError:respData]) {
  250. return ;
  251. }
  252. NSFileManager *fileMgr = [NSFileManager defaultManager];
  253. NSString *UIDPath = [DocumentsPath stringByAppendingPathComponent:[NSString stringWithFormat:@"%lld",tingUid]];
  254. NSString * SIDPath = [UIDPath stringByAppendingPathComponent:[NSString stringWithFormat:@"%lld",songID]];
  255. if (![fileMgr fileExistsAtPath:UIDPath]) {
  256. BOOL creatUID = [fileMgr createDirectoryAtPath:UIDPath withIntermediateDirectories:YES attributes:nil error:nil];
  257. if (creatUID) {
  258. NSLog(@"建立歌手文件夹成功");
  259. }
  260. }
  261. if (![fileMgr fileExistsAtPath:SIDPath]) {
  262. BOOL creatSID = [fileMgr createDirectoryAtPath:SIDPath withIntermediateDirectories:YES attributes:nil error:nil];
  263. if (creatSID) {
  264. NSLog(@"建立歌曲文件夹成功");
  265. }
  266. }
  267. BOOL sucess = NO;
  268. NSString * filePath = [SIDPath stringByAppendingPathComponent:[NSString stringWithFormat:@"%lld.lrc",songID]];
  269. if (![fileMgr fileExistsAtPath:filePath]) {
  270. BOOL creat = [fileMgr createFileAtPath:filePath contents:respData attributes:nil];
  271. if (creat) {
  272. NSLog(@"lrc文件保存成功");
  273. sucess = YES;
  274. }
  275. }else{
  276. sucess = YES;
  277. }
  278. // NSLog(@"resp:%@",respData);
  279. @try{
  280. completion(sucess,filePath);
  281. }
  282. @catch (NSException *exception) {
  283. KHError *appError = [[KHError alloc] initWithDomain:kHAppErrorDomain code:100 userInfo:nil];
  284. appError.reason = kHErrorParse;
  285. errorHandler(appError);
  286. }
  287. } errorHandler:^(MKNetworkOperation *completedOperation, NSError *error) {
  288. NSLog(@"ERROR:%@",error);
  289. KHError *appError = [[KHError alloc] initWithMKNetworkOperation:completedOperation error:error];
  290. errorHandler(appError);
  291. }];
  292. [self enqueueOperation:op];
  293. return op;
  294. }
  295. -(MKNetworkOperation *)downLoadSongWith:(long long)tingUid :(long long)songID :(NSString *)songLink
  296. WithCompletionHandler:(FMSongLinkDownLoadResponseBlock)completion
  297. errorHandler:(MKNKErrorBlock)errorHandler
  298. {
  299. self.showError = YES;
  300. MKNetworkOperation *op = [self operationWithURLString:songLink];
  301. [op addCompletionHandler:^(MKNetworkOperation *completedOperation) {
  302. NSData * respData = [completedOperation responseData];
  303. if ([self checkError:respData]) {
  304. return ;
  305. }
  306. NSFileManager *fileMgr = [NSFileManager defaultManager];
  307. NSString *UIDPath = [DocumentsPath stringByAppendingPathComponent:[NSString stringWithFormat:@"%lld",tingUid]];
  308. NSString * SIDPath = [UIDPath stringByAppendingPathComponent:[NSString stringWithFormat:@"%lld",songID]];
  309. if (![fileMgr fileExistsAtPath:UIDPath]) {
  310. BOOL creatUID = [fileMgr createDirectoryAtPath:UIDPath withIntermediateDirectories:YES attributes:nil error:nil];
  311. if (creatUID) {
  312. NSLog(@"建立歌手文件夹成功");
  313. }
  314. }
  315. if (![fileMgr fileExistsAtPath:SIDPath]) {
  316. BOOL creatSID = [fileMgr createDirectoryAtPath:SIDPath withIntermediateDirectories:YES attributes:nil error:nil];
  317. if (creatSID) {
  318. NSLog(@"建立歌曲文件夹成功");
  319. }
  320. }
  321. BOOL sucess = NO;
  322. NSString * filePath = [SIDPath stringByAppendingPathComponent:[NSString stringWithFormat:@"%lld.mp3",songID]];
  323. if (![fileMgr fileExistsAtPath:filePath]) {
  324. BOOL creat = [fileMgr createFileAtPath:filePath contents:respData attributes:nil];
  325. if (creat) {
  326. NSLog(@"mp3文件保存成功");
  327. sucess = YES;
  328. }
  329. }else{
  330. sucess = YES;
  331. }
  332. // NSLog(@"resp:%@",respData);
  333. @try{
  334. completion(sucess,filePath);
  335. }
  336. @catch (NSException *exception) {
  337. KHError *appError = [[KHError alloc] initWithDomain:kHAppErrorDomain code:100 userInfo:nil];
  338. appError.reason = kHErrorParse;
  339. errorHandler(appError);
  340. }
  341. } errorHandler:^(MKNetworkOperation *completedOperation, NSError *error) {
  342. NSLog(@"ERROR:%@",error);
  343. KHError *appError = [[KHError alloc] initWithMKNetworkOperation:completedOperation error:error];
  344. errorHandler(appError);
  345. }];
  346. [op onDownloadProgressChanged:^(double progress) {
  347. NSLog(@"%.2f",progress*100.0);
  348. }];
  349. [self enqueueOperation:op];
  350. return op;
  351. }
  352. -(MKNetworkOperation *)getTDMovieListWith:(int)pageNo :(int)pageSize :(int)channelId :(NSString *)sort
  353. WithCompletionHandler:(FMTDMovieListResponseBlock)completion
  354. errorHandler:(MKNKErrorBlock)errorHandler
  355. {
  356. self.showError = YES;
  357. KHNetworkEngine * netwrok = [self initWithHostName:@"api.tudou.com"];
  358. NSString * urlPath = [NSString stringWithFormat:@"/v3/gw?method=item.ranking&format=json&appKey=2aaf400b13fc9bad&pageNo=%d&pageSize=%d&channelId=%d&sort=%@",pageNo,pageSize,channelId,sort];
  359. MKNetworkOperation *op = [netwrok operationWithPath:urlPath];
  360. [op addCompletionHandler:^(MKNetworkOperation *completedOperation) {
  361. NSDictionary * respData = [completedOperation responseJSON];
  362. // NSLog(@"resp:%@",respData);
  363. NSDictionary * multiPageResult = [respData objectForKey:@"multiPageResult"];
  364. NSDictionary * page =[multiPageResult objectForKey:@"page"];
  365. NSArray * results = [multiPageResult objectForKey:@"results"];
  366. FMTDMovieList * movieList = [FMTDMovieList new];
  367. movieList.totalCount = [[page objectForKey:@"totalCount"] intValue];
  368. // if (movieList.totalCount != 0) {
  369. // NSLog(@"%@",op.url);
  370. // }
  371. for (NSDictionary * sub in results) {
  372. // NSLog(@"%@",sub);
  373. FMTDMovieModel * model = [FMTDMovieModel new];
  374. model.title = [sub objectForKey:@"title"];
  375. model.tags = [sub objectForKey:@"tags"];
  376. model.description = [sub objectForKey:@"description"];
  377. model.picUrl = [sub objectForKey:@"picUrl"];
  378. model.picUrl__16__9 = [sub objectForKey:@"picUrl__16__9"];
  379. model.pubDate = [sub objectForKey:@"pubDate"];
  380. model.itemUrl = [sub objectForKey:@"itemUrl"];
  381. model.mediaType = [sub objectForKey:@"mediaType"];
  382. model.bigPicUrl = [sub objectForKey:@"bigPicUrl"];
  383. model.totalTime = [[sub objectForKey:@"totalTime"] intValue];
  384. model.playTimes = [[sub objectForKey:@"playTimes"] intValue];
  385. model.commentCount = [sub objectForKey:@"commentCount"];
  386. model.html5Url = [sub objectForKey:@"html5Url"];
  387. [movieList.movieLists addObject:model];
  388. }
  389. @try{
  390. completion(movieList);
  391. }
  392. @catch (NSException *exception) {
  393. KHError *appError = [[KHError alloc] initWithDomain:kHAppErrorDomain code:100 userInfo:nil];
  394. appError.reason = kHErrorParse;
  395. errorHandler(appError);
  396. }
  397. } errorHandler:^(MKNetworkOperation *completedOperation, NSError *error) {
  398. NSLog(@"ERROR:%@",error);
  399. KHError *appError = [[KHError alloc] initWithMKNetworkOperation:completedOperation error:error];
  400. errorHandler(appError);
  401. }];
  402. [self enqueueOperation:op];
  403. return op;
  404. }
  405. -(MKNetworkOperation *)searchTDMovieWith:(int)pageNo :(int)pageSize :(NSString *)orderBy :(NSString *)keyWord
  406. WithCompletionHandler:(FMTDMovieListResponseBlock)completion
  407. errorHandler:(MKNKErrorBlock)errorHandler
  408. {
  409. self.showError = YES;
  410. KHNetworkEngine * netwrok = [self initWithHostName:@"api.tudou.com"];
  411. NSString * urlPath = [NSString stringWithFormat:@"v6/video/search?app_key=b30323ace96d8762&format=json&kw=%@&pageNo=%d&pageSize=%d&orderBy=%@",keyWord,pageNo,pageSize,orderBy];
  412. MKNetworkOperation *op = [netwrok operationWithPath:urlPath];
  413. [op addCompletionHandler:^(MKNetworkOperation *completedOperation) {
  414. NSDictionary * respData = [completedOperation responseJSON];
  415. // NSLog(@"resp:%@",respData);
  416. NSDictionary * page =[respData objectForKey:@"page"];
  417. NSArray * results = [respData objectForKey:@"results"];
  418. FMTDMovieList * movieList = [FMTDMovieList new];
  419. movieList.totalCount = [[page objectForKey:@"totalCount"] intValue];
  420. for (NSDictionary * sub in results) {
  421. FMTDMovieModel * model = [FMTDMovieModel new];
  422. model.title = [sub objectForKey:@"title"];
  423. model.tags = [sub objectForKey:@"tags"];
  424. model.description = [sub objectForKey:@"description"];
  425. model.picUrl = [sub objectForKey:@"picUrl"];
  426. model.picUrl__16__9 = [sub objectForKey:@"picUrl__16__9"];
  427. model.pubDate = [sub objectForKey:@"pubDate"];
  428. model.itemUrl = [sub objectForKey:@"itemUrl"];
  429. model.playUrl = [sub objectForKey:@"playUrl"];
  430. model.mediaType = [sub objectForKey:@"mediaType"];
  431. model.bigPicUrl = [sub objectForKey:@"bigPicUrl"];
  432. model.totalTime = [[sub objectForKey:@"totalTime"] intValue];
  433. model.playTimes = [[sub objectForKey:@"playTimes"] intValue];
  434. model.commentCount = [sub objectForKey:@"commentCount"];
  435. model.html5Url = [sub objectForKey:@"html5Url"];
  436. model.outerGPlayerUrl = [sub objectForKey:@"outerGPlayerUrl"];
  437. model.ownerName = [sub objectForKey:@"ownerName"];
  438. [movieList.movieLists addObject:model];
  439. }
  440. @try{
  441. completion(movieList);
  442. }
  443. @catch (NSException *exception) {
  444. KHError *appError = [[KHError alloc] initWithDomain:kHAppErrorDomain code:100 userInfo:nil];
  445. appError.reason = kHErrorParse;
  446. errorHandler(appError);
  447. }
  448. } errorHandler:^(MKNetworkOperation *completedOperation, NSError *error) {
  449. NSLog(@"ERROR:%@",error);
  450. KHError *appError = [[KHError alloc] initWithMKNetworkOperation:completedOperation error:error];
  451. errorHandler(appError);
  452. }];
  453. [self enqueueOperation:op];
  454. return op;
  455. }
  456. @end