### Carthage installation Source: https://github.com/0xced/xcdyoutubekit/blob/master/README.md Add the XCDYouTubeKit dependency to your Cartfile. The version constraint is '~> 2.15'. ```objc github "0xced/XCDYouTubeKit" ~> 2.15 ``` -------------------------------- ### Start the logger with LoggerStartForBuildUser Source: https://github.com/0xced/xcdyoutubekit/blob/master/XCDYouTubeKit Demo/Pods/NSLogger/README.markdown Add this line at the beginning of your main() function in main.m to start the logger. It only works when NSLogger is added via CocoaPods. Configure the Bonjour service name in the desktop viewer's Network preferences to receive traces only for your user. ```objective-c LoggerStartForBuildUser(); ``` -------------------------------- ### CocoaPods installation Source: https://github.com/0xced/xcdyoutubekit/blob/master/README.md Add the XCDYouTubeKit pod to your Podfile. The version constraint is '~> 2.15'. ```ruby pod "XCDYouTubeKit", "~> 2.15" ``` -------------------------------- ### CocoaPods Swift Installation Source: https://github.com/0xced/xcdyoutubekit/blob/master/XCDYouTubeKit Demo/Pods/CocoaLumberjack/README.md Install CocoaLumberjack with Swift support via CocoaPods. The 'Swift' subspec includes all Obj-C code plus Swift code. ```ruby platform :ios, '8.0' pod 'CocoaLumberjack/Swift' use_frameworks! ``` -------------------------------- ### CocoaPods Obj-C Installation Source: https://github.com/0xced/xcdyoutubekit/blob/master/XCDYouTubeKit Demo/Pods/CocoaLumberjack/README.md Install CocoaLumberjack for Objective-C via CocoaPods. ```ruby platform :ios, '7.0' pod 'CocoaLumberjack' ``` -------------------------------- ### Example bug report console log with XCDYouTubeVideoErrorDomain Source: https://github.com/0xced/xcdyoutubekit/blob/master/CONTRIBUTING.md Shown as the log output in a good bug report example. It displays a playback error with domain XCDYouTubeVideoErrorDomain, code 2, and message "Invalid parameters." The error occurs because the video identifier is invalid (EdeVaT-zZt44 with an extra 4 instead of EdeVaT-zZt4). ```text 2015-01-11 14:50:40.994 XCDYouTubeKit iOS Demo[67501:60b] Finish Reason: Playback Error Error Domain=XCDYouTubeVideoErrorDomain Code=2 "Invalid parameters." UserInfo=0x7a6955a0 {NSURL=https://www.youtube.com/get_video_info?el=detailpage&hl=en&ps=default&video_id=EdeVaT-zZt44, NSLocalizedDescription=Invalid parameters.} ``` -------------------------------- ### Get video metadata (iOS, tvOS, macOS) Source: https://github.com/0xced/xcdyoutubekit/blob/master/README.md Fetches a XCDYouTubeVideo object for a given video identifier. The identifier is an 11-character string. The completion handler provides the video or an error. ```objc NSString *videoIdentifier = @"9bZkp7q19f0"; // A 11 characters YouTube video identifier [[XCDYouTubeClient defaultClient] getVideoWithIdentifier:videoIdentifier completionHandler:^(XCDYouTubeVideo *video, NSError *error) { if (video) { // Do something with the `video` object } else { // Handle error } }]; ``` -------------------------------- ### Swift Logging Setup Source: https://github.com/0xced/xcdyoutubekit/blob/master/XCDYouTubeKit Demo/Pods/CocoaLumberjack/README.md Configure loggers for TTY, ASL, and file logging with rolling frequency and maximum file count. Log messages at various levels. ```swift DDLog.addLogger(DDTTYLogger.sharedInstance()) // TTY = Xcode console DDLog.addLogger(DDASLLogger.sharedInstance()) // ASL = Apple System Logs let fileLogger: DDFileLogger = DDFileLogger() // File Logger fileLogger.rollingFrequency = 60*60*24 // 24 hours fileLogger.logFileManager.maximumNumberOfLogFiles = 7 DDLog.addLogger(fileLogger) ... DDLogVerbose("Verbose"); DDLogDebug("Debug"); DDLogInfo("Info"); DDLogWarn("Warn"); DDLogError("Error"); ``` -------------------------------- ### Objective-C Logging Setup Source: https://github.com/0xced/xcdyoutubekit/blob/master/XCDYouTubeKit Demo/Pods/CocoaLumberjack/README.md Configure loggers for TTY, ASL, and file logging with rolling frequency and maximum file count. Log messages at various levels. ```objc [DDLog addLogger:[DDTTYLogger sharedInstance]]; // TTY = Xcode console [DDLog addLogger:[DDASLLogger sharedInstance]]; // ASL = Apple System Logs DDFileLogger *fileLogger = [[DDFileLogger alloc] init]; // File Logger fileLogger.rollingFrequency = 60 * 60 * 24; // 24 hour rolling fileLogger.logFileManager.maximumNumberOfLogFiles = 7; [DDLog addLogger:fileLogger]; ... DDLogVerbose(@"Verbose"); DDLogDebug(@"Debug"); DDLogInfo(@"Info"); DDLogWarn(@"Warn"); DDLogError(@"Error"); ``` -------------------------------- ### Present video in a non full-screen view (iOS 8.0) Source: https://github.com/0xced/xcdyoutubekit/blob/master/README.md Embeds the video player in a container view using presentInView: and starts playback. ```objc XCDYouTubeVideoPlayerViewController *videoPlayerViewController = [[XCDYouTubeVideoPlayerViewController alloc] initWithVideoIdentifier:@"9bZkp7q19f0"]; [videoPlayerViewController presentInView:self.videoContainerView]; [videoPlayerViewController.moviePlayer play]; ``` -------------------------------- ### Install XCDLumberjackNSLogger via CocoaPods Source: https://github.com/0xced/xcdyoutubekit/blob/master/XCDYouTubeKit Demo/Pods/XCDLumberjackNSLogger/README.md Add the pod to your Podfile to install version 1.0.2 or later. Requires iOS 5.0+ or OS X 10.7+. ```ruby pod "XCDLumberjackNSLogger", "~> 1.0.2" ``` -------------------------------- ### Add NSLogger to Podfile Source: https://github.com/0xced/xcdyoutubekit/blob/master/XCDYouTubeKit Demo/Pods/NSLogger/README.markdown Add this line to your project's Podfile to install NSLogger via CocoaPods. After adding, download the pre-built NSLogger desktop viewer for OS X. ```ruby pod "NSLogger" ``` -------------------------------- ### Swift Import Statement Source: https://github.com/0xced/xcdyoutubekit/blob/master/XCDYouTubeKit Demo/Pods/CocoaLumberjack/README.md Import CocoaLumberjack in Swift after installing via CocoaPods or manually. ```swift import CocoaLumberjack ``` -------------------------------- ### Carthage Cartfile Source: https://github.com/0xced/xcdyoutubekit/blob/master/XCDYouTubeKit Demo/Pods/CocoaLumberjack/README.md Add CocoaLumberjack to your Cartfile for Carthage installation (iOS 8+). ```plaintext github "CocoaLumberjack/CocoaLumberjack" ``` -------------------------------- ### Replay recorded HTTP interactions with VCRURLConnection Source: https://github.com/0xced/xcdyoutubekit/blob/master/XCDYouTubeKit Tests/VCRURLConnection/README.md Loads a previously recorded cassette file, starts VCRURLConnection, and performs the same request. No network request is made; the recorded response is returned via NSURLConnectionDelegate methods. ```objective-c NSURL *cassetteURL = [NSURL fileURLWithPath:@"/path/to/cassette.json"]; [VCR loadCassetteWithContentsOfURL:cassetteURL]; [VCR start]; // request an HTTP interaction that was recorded to cassette.json NSString *path = @"http://example.com/example"; NSURL *url = [NSURL URLWithString:path]; NSURLRequest *request = [NSURLRequest requestWithURL:url]; // use either NSURLSession or NSURLConnection NSURLSessionDataTask *task = [[NSURLSession sharedSession] dataTaskWithRequest:request]; [task resume]; // The cassette has a recording for this request, so no network request // is made. Instead NSURLConnectionDelegate methods are called with the // previously recorded response. ``` -------------------------------- ### Record HTTP interactions with VCRURLConnection Source: https://github.com/0xced/xcdyoutubekit/blob/master/XCDYouTubeKit Tests/VCRURLConnection/README.md Starts VCRURLConnection, performs a network request via NSURLSession, and saves the recorded request/response pair to a JSON cassette file. Use this to record HTTP interactions for later replay in tests. ```objective-c [VCR start]; NSString *path = @"http://example.com/example"; NSURL *url = [NSURL URLWithString:path]; NSURLRequest *request = [NSURLRequest requestWithURL:url]; // use either NSURLSession or NSURLConnection NSURLSessionDataTask *task = [[NSURLSession sharedSession] dataTaskWithRequest:request]; [task resume]; // NSURLSession makes a real network request and VCRURLConnection // will record the request/response pair. // once async request is complete or application is ready to exit: [VCR save:@"/path/to/cassette.json"]; // copy the output file into your project ``` -------------------------------- ### Log a message with LoggerApp Source: https://github.com/0xced/xcdyoutubekit/blob/master/XCDYouTubeKit Demo/Pods/NSLogger/README.markdown Use LoggerApp to add traces to your code after importing . The format string and arguments work like NSLog. ```objective-c LoggerApp(1, @"Hello world! Today is: %@", [self myDate]); ``` -------------------------------- ### Configure viewer host for NSLogger Source: https://github.com/0xced/xcdyoutubekit/blob/master/XCDYouTubeKit Demo/Pods/XCDLumberjackNSLogger/README.md Sets the viewer host IP address and port (50000) using LoggerSetViewerHost, then adds the logger to DDLog. ```objc XCDLumberjackNSLogger *logger = [XCDLumberjackNSLogger new]; LoggerSetViewerHost(logger.logger, CFSTR("10.0.1.7"), 50000); [DDLog addLogger:logger]; ``` -------------------------------- ### Configure bonjour service name for NSLogger Source: https://github.com/0xced/xcdyoutubekit/blob/master/XCDYouTubeKit Demo/Pods/XCDLumberjackNSLogger/README.md Reads the NSLOGGER_BONJOUR_SERVICE_NAME environment variable and initializes the logger with that bonjour service name. ```objc NSString *bonjourServiceName = [[[NSProcessInfo processInfo] environment] objectForKey:@"NSLOGGER_BONJOUR_SERVICE_NAME"]; [DDLog addLogger:[[XCDLumberjackNSLogger alloc] initWithBonjourServiceName:bonjourServiceName]]; ``` -------------------------------- ### Present video in full-screen (iOS 8.0) Source: https://github.com/0xced/xcdyoutubekit/blob/master/README.md Uses XCDYouTubeVideoPlayerViewController to present a video full-screen. Observes MPMoviePlayerPlaybackDidFinishNotification and handles playback errors. ```objc - (void) playVideo { XCDYouTubeVideoPlayerViewController *videoPlayerViewController = [[XCDYouTubeVideoPlayerViewController alloc] initWithVideoIdentifier:@"9bZkp7q19f0"]; [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(moviePlayerPlaybackDidFinish:) name:MPMoviePlayerPlaybackDidFinishNotification object:videoPlayerViewController.moviePlayer]; [self presentMoviePlayerViewControllerAnimated:videoPlayerViewController]; } - (void) moviePlayerPlaybackDidFinish:(NSNotification *)notification { [[NSNotificationCenter defaultCenter] removeObserver:self name:MPMoviePlayerPlaybackDidFinishNotification object:notification.object]; MPMovieFinishReason finishReason = [notification.userInfo[MPMoviePlayerPlaybackDidFinishReasonUserInfoKey] integerValue]; if (finishReason == MPMovieFinishReasonPlaybackError) { NSError *error = notification.userInfo[XCDMoviePlayerPlaybackDidFinishErrorUserInfoKey]; // Handle error } } ``` -------------------------------- ### Swift Package Manager dependency Source: https://github.com/0xced/xcdyoutubekit/blob/master/README.md Add XCDYouTubeKit to the dependencies value of your Package.swift. The version constraint is 'from: 2.15.0'. ```swift dependencies: [ .package(url: "https://github.com/0xced/XCDYouTubeKit.git", from: "2.15.0") ] ``` -------------------------------- ### Play video with AVPlayerViewController (iOS 8.0+ & tvOS) Source: https://github.com/0xced/xcdyoutubekit/blob/master/README.md Presents a video using AVPlayerViewController and XCDYouTubeClient. Selects the stream URL with priority: HTTP live streaming, HD720, Medium360, Small240. Dismisses the view controller on error. ```objc AVPlayerViewController *playerViewController = [AVPlayerViewController new]; [self presentViewController:playerViewController animated:YES completion:nil]; __weak AVPlayerViewController *weakPlayerViewController = playerViewController; [[XCDYouTubeClient defaultClient] getVideoWithIdentifier:videoIdentifier completionHandler:^(XCDYouTubeVideo * _Nullable video, NSError * _Nullable error) { if (video) { NSDictionary *streamURLs = video.streamURLs; NSURL *streamURL = streamURLs[XCDYouTubeVideoQualityHTTPLiveStreaming] ?: streamURLs[@(XCDYouTubeVideoQualityHD720)] ?: streamURLs[@(XCDYouTubeVideoQualityMedium360)] ?: streamURLs[@(XCDYouTubeVideoQualitySmall240)]; weakPlayerViewController.player = [AVPlayer playerWithURL:streamURL]; [weakPlayerViewController.player play]; } else { [self dismissViewControllerAnimated:YES completion:nil]; } }]; ``` -------------------------------- ### Translate contexts to tags in XCDLumberjackNSLogger Source: https://github.com/0xced/xcdyoutubekit/blob/master/XCDYouTubeKit Demo/Pods/XCDLumberjackNSLogger/README.md Sets a dictionary mapping numeric log contexts to string tags, e.g., 80 to "CocoaHTTPServer" and 0xced70676 to "XCDYouTubeKit", then adds the logger. ```objc XCDLumberjackNSLogger *logger = [XCDLumberjackNSLogger new]; logger.tags = @{ @80 : @"CocoaHTTPServer", @((NSInteger)0xced70676) : @"XCDYouTubeKit" }; [DDLog addLogger:logger]; ``` -------------------------------- ### Force CocoaLumberjack 1.x Source: https://github.com/0xced/xcdyoutubekit/blob/master/XCDYouTubeKit Demo/Pods/CocoaLumberjack/README.md Force version 1.x when a conflicting library requires it by setting the version before the conflicting library. ```ruby pod 'CocoaLumberjack', '~> 1.9' pod 'ConflictingLibrary' ``` -------------------------------- ### Send logs to NSLogger with DDLog addLogger Source: https://github.com/0xced/xcdyoutubekit/blob/master/XCDYouTubeKit Demo/Pods/XCDLumberjackNSLogger/README.md Adds a new XCDLumberjackNSLogger instance to the CocoaLumberjack logging system, sending all logs to NSLogger. ```objc [DDLog addLogger:[XCDLumberjackNSLogger new]]; ``` -------------------------------- ### Current Patterns in XCDYouTubeKit 2.9.0 Source: https://github.com/0xced/xcdyoutubekit/blob/master/REGULAR_EXPRESSION.md These are the hard-coded ICU regular expressions used by XCDYouTubeKit version 2.9.0 to parse YouTube videos. They are based on the youtube-dl extractor and must be kept in the exact order shown; incorrect ordering can prevent some videos from playing. Use these as a reference when updating custom patterns on your server. ```regex \b[cs]\s*&&\s*[adf]\.set\([^,]+\s*,\s*encodeURIComponent\s*\(\s*([a-zA-Z0-9$]+)\( ``` ```regex \b[a-zA-Z0-9]+\s*&&\s*[a-zA-Z0-9]+\.set\([^,]+\s*,\s*encodeURIComponent\s*\(\s*([a-zA-Z0-9$]+)\( ``` ```regex \b([a-zA-Z0-9$]{2})\s*=\s*function\(\s*a\s*\)\s*\{\s*a\s*=\s*a\.split\(\s*""\s*\) ``` ```regex ([a-zA-Z0-9$]+)\s*=\s*function\(\s*a\s*\)\s*\{\s*a\s*=\s*a\.split\(\s*""\s*\) ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.