I think exposing the NSDictionary object that the XCDYouTubeVideo class is initialized with would be really helpful. For instance, this would make it more flexible to use features that aren't implemented by the library as yet (https://github.com/0xced/XCDYouTubeKit/pull/281). Sometimes pull requests may not be merged with the library for whatever reason. By exposing this property it enables us to add these features on our own.
Currently, this is my method of getting the NSDictionary which isn't pretty for obvious reasons. 😉
self.operation = [[XCDYouTubeClient defaultClient] getVideoWithIdentifier:@"wJdeVtnUxuk" completionHandler:^(XCDYouTubeVideo * _Nullable video, NSError * _Nullable error) {
NSURLSessionDataTask *task = [self.operation valueForKey:@"dataTask"];
if (!task) {
return;
}
[[[NSURLSession sharedSession]dataTaskWithURL:task.response.URL completionHandler:^(NSData * _Nullable data, NSURLResponse * _Nullable response, NSError * _Nullable error) {
if (!data) {
return;
}
CFStringEncoding encoding = CFStringConvertIANACharSetNameToEncoding((__bridge CFStringRef)response.textEncodingName ?: CFSTR(""));
// Use kCFStringEncodingMacRoman as fallback because it defines characters for every byte value and is ASCII compatible. See https://mikeash.com/pyblog/friday-qa-2010-02-19-character-encodings.html
NSString *responseString = CFBridgingRelease(CFStringCreateWithBytes(kCFAllocatorDefault, data.bytes, (CFIndex)data.length, encoding != kCFStringEncodingInvalidId ? encoding : kCFStringEncodingMacRoman, false)) ?: @"";
NSDictionary *dic = DictionaryWithQueryString(responseString);
}]resume];
}];
I think exposing the
NSDictionary
object that theXCDYouTubeVideo
class is initialized with would be really helpful. For instance, this would make it more flexible to use features that aren't implemented by the library as yet (https://github.com/0xced/XCDYouTubeKit/pull/281). Sometimes pull requests may not be merged with the library for whatever reason. By exposing this property it enables us to add these features on our own.Currently, this is my method of getting the
NSDictionary
which isn't pretty for obvious reasons. 😉