Skip to content

Commit

Permalink
加上可以收看 MeetAV
Browse files Browse the repository at this point in the history
  • Loading branch information
DaidoujiChen committed Dec 31, 2014
1 parent 201100b commit 72efca4
Show file tree
Hide file tree
Showing 14 changed files with 476 additions and 1 deletion.
46 changes: 46 additions & 0 deletions e-Hentai.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,12 @@
01519AF51A3053BA0091C985 /* IPadDownloadManagerCell.xib in Resources */ = {isa = PBXBuildFile; fileRef = 01519AF41A3053BA0091C985 /* IPadDownloadManagerCell.xib */; };
015755421A3055B4009083B4 /* IPadSearchFilterViewController.xib in Resources */ = {isa = PBXBuildFile; fileRef = 015755411A3055B4009083B4 /* IPadSearchFilterViewController.xib */; };
015B89E819FF9B2500CFA9DE /* SupportKitLocalizable.strings in Resources */ = {isa = PBXBuildFile; fileRef = 015B89E619FF9B2500CFA9DE /* SupportKitLocalizable.strings */; };
0162712D1A538F08005DCD29 /* MeetAVParser.m in Sources */ = {isa = PBXBuildFile; fileRef = 0162712B1A538F08005DCD29 /* MeetAVParser.m */; };
016271381A539845005DCD29 /* VideoViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 016271351A539845005DCD29 /* VideoViewController.m */; };
016271391A539845005DCD29 /* VideoViewController.xib in Resources */ = {isa = PBXBuildFile; fileRef = 016271361A539845005DCD29 /* VideoViewController.xib */; };
0162713D1A5398CF005DCD29 /* VideoCollectionViewCell.m in Sources */ = {isa = PBXBuildFile; fileRef = 0162713B1A5398CF005DCD29 /* VideoCollectionViewCell.m */; };
0162713E1A5398CF005DCD29 /* VideoCollectionViewCell.xib in Resources */ = {isa = PBXBuildFile; fileRef = 0162713C1A5398CF005DCD29 /* VideoCollectionViewCell.xib */; };
016271401A53E097005DCD29 /* IPadVideoViewController.xib in Resources */ = {isa = PBXBuildFile; fileRef = 0162713F1A53E097005DCD29 /* IPadVideoViewController.xib */; };
0163C7D719D8FD5300105ECF /* DownloadedViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 0163C7D619D8FD5300105ECF /* DownloadedViewController.m */; };
0163E4721A3FD019007C3D58 /* DiveExHentai.m in Sources */ = {isa = PBXBuildFile; fileRef = 0163E4711A3FD019007C3D58 /* DiveExHentai.m */; };
016A359F19B6FB8A00E3371A /* HentaiParser.m in Sources */ = {isa = PBXBuildFile; fileRef = 016A359E19B6FB8A00E3371A /* HentaiParser.m */; };
Expand Down Expand Up @@ -156,6 +162,15 @@
015755411A3055B4009083B4 /* IPadSearchFilterViewController.xib */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = file.xib; name = IPadSearchFilterViewController.xib; path = SearchFilterViewController/IPadSearchFilterViewController.xib; sourceTree = "<group>"; };
015B89E419FF9AC900CFA9DE /* zh-Hant */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = "zh-Hant"; path = "zh-Hant.lproj/InfoPlist.strings"; sourceTree = "<group>"; };
015B89E719FF9B2500CFA9DE /* zh-Hant */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = "zh-Hant"; path = "zh-Hant.lproj/SupportKitLocalizable.strings"; sourceTree = "<group>"; };
0162712A1A538F08005DCD29 /* MeetAVParser.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MeetAVParser.h; sourceTree = "<group>"; };
0162712B1A538F08005DCD29 /* MeetAVParser.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = MeetAVParser.m; sourceTree = "<group>"; };
016271341A539845005DCD29 /* VideoViewController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = VideoViewController.h; sourceTree = "<group>"; };
016271351A539845005DCD29 /* VideoViewController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = VideoViewController.m; sourceTree = "<group>"; };
016271361A539845005DCD29 /* VideoViewController.xib */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = file.xib; path = VideoViewController.xib; sourceTree = "<group>"; };
0162713A1A5398CF005DCD29 /* VideoCollectionViewCell.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = VideoCollectionViewCell.h; sourceTree = "<group>"; };
0162713B1A5398CF005DCD29 /* VideoCollectionViewCell.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = VideoCollectionViewCell.m; sourceTree = "<group>"; };
0162713C1A5398CF005DCD29 /* VideoCollectionViewCell.xib */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = file.xib; path = VideoCollectionViewCell.xib; sourceTree = "<group>"; };
0162713F1A53E097005DCD29 /* IPadVideoViewController.xib */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = file.xib; path = IPadVideoViewController.xib; sourceTree = "<group>"; };
0163C7D519D8FD5300105ECF /* DownloadedViewController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = DownloadedViewController.h; path = DownloadedViewController/DownloadedViewController.h; sourceTree = "<group>"; };
0163C7D619D8FD5300105ECF /* DownloadedViewController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = DownloadedViewController.m; path = DownloadedViewController/DownloadedViewController.m; sourceTree = "<group>"; };
0163E4701A3FD019007C3D58 /* DiveExHentai.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = DiveExHentai.h; sourceTree = "<group>"; };
Expand Down Expand Up @@ -437,6 +452,29 @@
path = Hpple;
sourceTree = "<group>";
};
016271271A538F08005DCD29 /* MeetParser */ = {
isa = PBXGroup;
children = (
0162712A1A538F08005DCD29 /* MeetAVParser.h */,
0162712B1A538F08005DCD29 /* MeetAVParser.m */,
);
path = MeetParser;
sourceTree = "<group>";
};
016271311A539845005DCD29 /* VideoViewController */ = {
isa = PBXGroup;
children = (
016271341A539845005DCD29 /* VideoViewController.h */,
016271351A539845005DCD29 /* VideoViewController.m */,
016271361A539845005DCD29 /* VideoViewController.xib */,
0162713F1A53E097005DCD29 /* IPadVideoViewController.xib */,
0162713A1A5398CF005DCD29 /* VideoCollectionViewCell.h */,
0162713B1A5398CF005DCD29 /* VideoCollectionViewCell.m */,
0162713C1A5398CF005DCD29 /* VideoCollectionViewCell.xib */,
);
path = VideoViewController;
sourceTree = "<group>";
};
0163C7D419D8FC5600105ECF /* DownloadedViewController */ = {
isa = PBXGroup;
children = (
Expand Down Expand Up @@ -613,6 +651,7 @@
children = (
013F8F061A490B66002B8C47 /* RealmModels */,
0137F40919C1684500528359 /* HentaiDownloadCenter */,
016271271A538F08005DCD29 /* MeetParser */,
0150033319B6E5E90055F47D /* HentaiParser */,
0163E46F1A3FD019007C3D58 /* DiveExHentai */,
0150033619B6E5E90055F47D /* ThirdParty */,
Expand All @@ -629,6 +668,7 @@
01758F711A3FE05300677BA2 /* ExMainViewController */,
0118081119B6F06200FE0DA1 /* PhotoViewController */,
0163C7D419D8FC5600105ECF /* DownloadedViewController */,
016271311A539845005DCD29 /* VideoViewController */,
019926A019ADDB83009F814B /* Images.xcassets */,
0199268F19ADDB83009F814B /* Supporting Files */,
);
Expand Down Expand Up @@ -769,6 +809,8 @@
isa = PBXResourcesBuildPhase;
buildActionMask = 2147483647;
files = (
016271401A53E097005DCD29 /* IPadVideoViewController.xib in Resources */,
0162713E1A5398CF005DCD29 /* VideoCollectionViewCell.xib in Resources */,
017AE5C31A00D24600317939 /* SearchFilterViewController.xib in Resources */,
0180D91C1A021282002554FC /* [email protected] in Resources */,
019926A119ADDB83009F814B /* Images.xcassets in Resources */,
Expand Down Expand Up @@ -799,6 +841,7 @@
015B89E819FF9B2500CFA9DE /* SupportKitLocalizable.strings in Resources */,
0180D92C1A02140E002554FC /* [email protected] in Resources */,
015755421A3055B4009083B4 /* IPadSearchFilterViewController.xib in Resources */,
016271391A539845005DCD29 /* VideoViewController.xib in Resources */,
0180D9281A02139F002554FC /* [email protected] in Resources */,
);
runOnlyForDeploymentPostprocessing = 0;
Expand Down Expand Up @@ -852,10 +895,12 @@
013F8F111A490D59002B8C47 /* HentaiSaveLibrary_HentaiResult.m in Sources */,
019290221A25D6C70094B423 /* DaiPortalBlockAnalysis.m in Sources */,
0150034619B6E5E90055F47D /* XPathQuery.m in Sources */,
0162713D1A5398CF005DCD29 /* VideoCollectionViewCell.m in Sources */,
01FB6FD419E23FB4006CBEF2 /* NSString+Hentai.m in Sources */,
013F8F0E1A490BB1002B8C47 /* HentaiSaveLibrary_HentaiInfo.m in Sources */,
016BBF0F19B94E4F0015E11E /* LightWeightPlist+HandleCache.m in Sources */,
0118081619B6F06200FE0DA1 /* HentaiNavigationController.m in Sources */,
016271381A539845005DCD29 /* VideoViewController.m in Sources */,
016BBF1519B953D40015E11E /* HentaiDownloadImageOperation.m in Sources */,
01758F741A3FE07400677BA2 /* ExMainViewController.m in Sources */,
013F8F141A490DBA002B8C47 /* HentaiSaveLibrary_Images.m in Sources */,
Expand All @@ -875,6 +920,7 @@
019290251A25D6C70094B423 /* NSObject+DaiPortal.m in Sources */,
01BBD60119E3D428003538CF /* HentaiPhotoCell.m in Sources */,
013F8F171A490E06002B8C47 /* HentaiSaveLibrary.m in Sources */,
0162712D1A538F08005DCD29 /* MeetAVParser.m in Sources */,
016BBF1119B94E4F0015E11E /* LightWeightPlist.m in Sources */,
019290211A25D6C70094B423 /* DaiPortal.m in Sources */,
016BBF0B19B94E4F0015E11E /* FilesManager.m in Sources */,
Expand Down
22 changes: 22 additions & 0 deletions e-Hentai/MeetParser/MeetAVParser.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
//
// MeetAVParser.h
// e-Hentai
//
// Created by 啟倫 陳 on 2014/12/26.
// Copyright (c) 2014年 ChilunChen. All rights reserved.
//

#import <Foundation/Foundation.h>

typedef enum {
MeetParserStatusNetworkFail = -1,
MeetParserStatusParseFail,
MeetParserStatusSuccess
} MeetParserStatus;

@interface MeetAVParser : NSObject

+ (void)requestListForQuery:(NSString *)query completion:(void (^)(MeetParserStatus status, NSArray *listArray))completion;
+ (void)parseVideoFrom:(NSString *)urlString completion:(void (^)(MeetParserStatus status, NSString *videoURL))completion;

@end
108 changes: 108 additions & 0 deletions e-Hentai/MeetParser/MeetAVParser.m
Original file line number Diff line number Diff line change
@@ -0,0 +1,108 @@
//
// MeetAVParser.m
// e-Hentai
//
// Created by 啟倫 陳 on 2014/12/26.
// Copyright (c) 2014年 ChilunChen. All rights reserved.
//

#import "MeetAVParser.h"

#import <objc/runtime.h>

@implementation MeetAVParser

#pragma mark - class method

+ (void)requestListForQuery:(NSString *)query completion:(void (^)(MeetParserStatus status, NSArray *listArray))completion {
NSString *queryString = [NSString stringWithFormat:@"http://www.meetav.com/search_result.php?query=%@&type=videos&submit=Search", query];

[NSURLConnection sendAsynchronousRequest:[NSURLRequest requestWithURL:[NSURL URLWithString:[queryString stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding]]] queue:[self defaultOperationQueue] completionHandler: ^(NSURLResponse *response, NSData *data, NSError *connectionError) {
if (connectionError) {
dispatch_async(dispatch_get_main_queue(), ^{
completion(MeetParserStatusNetworkFail, nil);
});
return;
}

NSMutableArray *listArray = [NSMutableArray array];
TFHpple *xpathParser = [[TFHpple alloc] initWithHTMLData:data encoding:@"utf-8"];
NSArray *pageURL = [xpathParser searchWithXPathQuery:@"//h2 [@style='display:none']//a"];
NSArray *thumbURL = [xpathParser searchWithXPathQuery:@"//div [@class='vid_thumb']//a//img"];

if ([pageURL count]) {
for (int i=0; i<[pageURL count]; i++) {
TFHppleElement *eachURL = pageURL[i];
TFHppleElement *eachThumbURL = thumbURL[i];
[listArray addObject:@{ @"title":[eachURL text], @"url":[eachURL attributes][@"href"], @"thumb":[eachThumbURL attributes][@"src"] }];
}
dispatch_async(dispatch_get_main_queue(), ^{
completion(MeetParserStatusSuccess, listArray);
});
}
else {
dispatch_async(dispatch_get_main_queue(), ^{
completion(MeetParserStatusParseFail, nil);
});
}
}];
}

+ (void)parseVideoFrom:(NSString *)urlString completion:(void (^)(MeetParserStatus status, NSString *videoURL))completion {
[self setCompletion:completion];
[[self meetAVWebView] loadRequest:[NSURLRequest requestWithURL:[NSURL URLWithString:[urlString stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding]]]];
}

#pragma mark - UIWebViewDelegate

+ (void)webViewDidFinishLoad:(UIWebView *)webView {
NSString *hq_video_file = [self.meetAVWebView stringByEvaluatingJavaScriptFromString:@"hq_video_file"];
if (hq_video_file) {
if ([[hq_video_file pathExtension] isEqualToString:@"mp4"]) {
[self completion](MeetParserStatusSuccess, hq_video_file);
}
else {
[self completion](MeetParserStatusParseFail, nil);
}
[webView stopLoading];
[self setMeetAVWebView:nil];
}
}

+ (void)webView:(UIWebView *)webView didFailLoadWithError:(NSError *)error {
[self completion](MeetParserStatusNetworkFail, nil);
[webView stopLoading];
[self setMeetAVWebView:nil];
}

#pragma mark - runtime objects

+ (void)setMeetAVWebView:(UIWebView *)meetAVWebView {
objc_setAssociatedObject(self, @selector(meetAVWebView), meetAVWebView, OBJC_ASSOCIATION_RETAIN_NONATOMIC);
}

+ (UIWebView *)meetAVWebView {
if (!objc_getAssociatedObject(self, _cmd)) {
UIWebView *meetAVWebView = [UIWebView new];
meetAVWebView.delegate = (id <UIWebViewDelegate> )self;
[self setMeetAVWebView:meetAVWebView];
}
return objc_getAssociatedObject(self, _cmd);
}

+ (void)setCompletion:(void (^)(MeetParserStatus status, NSString *videoURL))completion {
objc_setAssociatedObject(self, @selector(completion), completion, OBJC_ASSOCIATION_COPY_NONATOMIC);
}

+ (void (^)(MeetParserStatus status, NSString *videoURL))completion {
return objc_getAssociatedObject(self, _cmd);
}

+ (NSOperationQueue *)defaultOperationQueue {
if (!objc_getAssociatedObject(self, _cmd)) {
objc_setAssociatedObject(self, _cmd, [NSOperationQueue new], OBJC_ASSOCIATION_RETAIN_NONATOMIC);
}
return objc_getAssociatedObject(self, _cmd);
}

@end
8 changes: 8 additions & 0 deletions e-Hentai/Menu.plist
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,14 @@
<key>controller</key>
<string>ExMainViewController</string>
</dict>
<dict>
<key>displayName</key>
<string>MeetAV(試閱)</string>
<key>image</key>
<string>exterior</string>
<key>controller</key>
<string>VideoViewController</string>
</dict>
<dict>
<key>displayName</key>
<string>已下載</string>
Expand Down
3 changes: 2 additions & 1 deletion e-Hentai/SliderViewController/SliderViewController.h
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,8 @@

#import "MainViewController.h"
#import "MenuViewController.h"
#import "VideoViewController.h"

@interface SliderViewController : IIViewDeckController <MainViewControllerDelegate, MenuViewControllerDelegate, IIViewDeckControllerDelegate>
@interface SliderViewController : IIViewDeckController <MainViewControllerDelegate, VideoViewControllerDelegate, MenuViewControllerDelegate, IIViewDeckControllerDelegate>

@end
10 changes: 10 additions & 0 deletions e-Hentai/SliderViewController/SliderViewController.m
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,16 @@ - (void)needToPushViewController:(UIViewController *)controller {
[hentaiNavigation pushViewController:controller animated:YES];
}

#pragma mark - VideoViewControllerDelegate

- (void)needToPresentMovieViewController:(MPMoviePlayerViewController *)controller {
UIWindow *newWindow = [[UIWindow alloc] initWithFrame:[UIScreen mainScreen].bounds];
UIViewController *rootViewController = [UIViewController new];
newWindow.rootViewController = rootViewController;
[newWindow makeKeyAndVisible];
[rootViewController presentMoviePlayerViewControllerAnimated:controller];
}

#pragma mark - MenuViewControllerDelegate

//切換 controller
Expand Down
41 changes: 41 additions & 0 deletions e-Hentai/VideoViewController/IPadVideoViewController.xib
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<document type="com.apple.InterfaceBuilder3.CocoaTouch.XIB" version="3.0" toolsVersion="6254" systemVersion="13F34" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES">
<dependencies>
<deployment identifier="iOS"/>
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="6247"/>
</dependencies>
<objects>
<placeholder placeholderIdentifier="IBFilesOwner" id="-1" userLabel="File's Owner" customClass="VideoViewController">
<connections>
<outlet property="meetAVCollectionView" destination="dRq-2U-Zl7" id="f1f-1B-KbC"/>
<outlet property="view" destination="iN0-l3-epB" id="EXZ-vT-eLA"/>
</connections>
</placeholder>
<placeholder placeholderIdentifier="IBFirstResponder" id="-2" customClass="UIResponder"/>
<view contentMode="scaleToFill" id="iN0-l3-epB">
<rect key="frame" x="0.0" y="0.0" width="768" height="1024"/>
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
<subviews>
<collectionView opaque="NO" clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="scaleToFill" fixedFrame="YES" minimumZoomScale="0.0" maximumZoomScale="0.0" dataMode="none" translatesAutoresizingMaskIntoConstraints="NO" id="dRq-2U-Zl7">
<rect key="frame" x="0.0" y="0.0" width="768" height="1024"/>
<color key="backgroundColor" white="0.0" alpha="0.0" colorSpace="calibratedWhite"/>
<collectionViewFlowLayout key="collectionViewLayout" minimumLineSpacing="20" minimumInteritemSpacing="20" id="Spq-a4-RSV">
<size key="itemSize" width="150" height="160"/>
<size key="headerReferenceSize" width="0.0" height="0.0"/>
<size key="footerReferenceSize" width="0.0" height="0.0"/>
<inset key="sectionInset" minX="20" minY="20" maxX="20" maxY="20"/>
</collectionViewFlowLayout>
<cells/>
<connections>
<outlet property="dataSource" destination="-1" id="UD7-VT-ehg"/>
<outlet property="delegate" destination="-1" id="LGa-qO-a7R"/>
</connections>
</collectionView>
</subviews>
<color key="backgroundColor" white="1" alpha="1" colorSpace="custom" customColorSpace="calibratedWhite"/>
<simulatedNavigationBarMetrics key="simulatedTopBarMetrics" prompted="NO"/>
<simulatedScreenMetrics key="simulatedDestinationMetrics" type="iPad"/>
<point key="canvasLocation" x="521" y="447"/>
</view>
</objects>
</document>
16 changes: 16 additions & 0 deletions e-Hentai/VideoViewController/VideoCollectionViewCell.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
//
// VideoCollectionViewCell.h
// e-Hentai
//
// Created by 啟倫 陳 on 2014/12/31.
// Copyright (c) 2014年 ChilunChen. All rights reserved.
//

#import <UIKit/UIKit.h>

@interface VideoCollectionViewCell : UICollectionViewCell

@property (weak, nonatomic) IBOutlet UIImageView *cellImageView;
@property (weak, nonatomic) IBOutlet UILabel *cellLabel;

@end
24 changes: 24 additions & 0 deletions e-Hentai/VideoViewController/VideoCollectionViewCell.m
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
//
// VideoCollectionViewCell.m
// e-Hentai
//
// Created by 啟倫 陳 on 2014/12/31.
// Copyright (c) 2014年 ChilunChen. All rights reserved.
//

#import "VideoCollectionViewCell.h"

@implementation VideoCollectionViewCell

#pragma mark - life cycle

- (id)initWithFrame:(CGRect)frame {
self = [super initWithFrame:frame];
if (self) {
NSArray *arrayOfViews = [[NSBundle mainBundle] loadNibNamed:NSStringFromClass([self class]) owner:self options:nil];
self = arrayOfViews[0];
}
return self;
}

@end
Loading

0 comments on commit 72efca4

Please sign in to comment.