Skip to content

Commit

Permalink
Update regex patterns as per (ytdl-org/youtube-dl@abefc03) (fixes #437)
Browse files Browse the repository at this point in the history
  • Loading branch information
SoneeJohn committed Jun 21, 2019
1 parent 2c72c0f commit c31851f
Showing 1 changed file with 11 additions and 6 deletions.
17 changes: 11 additions & 6 deletions XCDYouTubeKit/XCDYouTubePlayerScript.m
Expand Up @@ -74,13 +74,18 @@ - (instancetype) initWithString:(NSString *)string
}

//See list of regex patterns here https://github.com/rg3/youtube-dl/blob/master/youtube_dl/extractor/youtube.py#L1179
NSArray<NSString *>*patterns = @[@"\\.sig\\|\\|([a-zA-Z0-9$]+)\\(",
@"[\"']signature[\"']\\s*,\\s*([^\\(]+)",
@"yt\\.akamaized\\.net/\\)\\s*\\|\\|\\s*.*?\\s*c\\s*&&\\s*(?:d|a)\\.set\\([^,]+\\s*,\\s*(?:encodeURIComponent\\s*\\()?([a-zA-Z0-9$]+)\\(",
@"\\bc\\s*&&\\s*(?:d|a)\\.set\\([^,]+\\s*,\\s*(?:encodeURIComponent\\s*\\()?\\s*([a-zA-Z0-9$]+)\\(",
@"\\bc\\s*&&\\s*(?:d|a)\\.set\\([^,]+\\s*,\\s*\\([^)]*\\)\\s*\\(\\s*([a-zA-Z0-9$]+)\\("
NSArray<NSString *>*patterns = @[@"\\b[cs]\\s*&&\\s*[adf]\\.set\\([^,]+\\s*,\\s*encodeURIComponent\\s*\\(\\s*([a-zA-Z0-9$]+)\\(",
@"\\b[a-zA-Z0-9]+\\s*&&\\s*[a-zA-Z0-9]+\\.set\\([^,]+\\s*,\\s*encodeURIComponent\\s*\\(\\s*([a-zA-Z0-9$]+)\\(",
@"([\"\\\'])signature\\1\\s*,\\s*([a-zA-Z0-9$]+)\\(",
@"\\.sig\\|\\|([a-zA-Z0-9$]+)\\(",
@"yt\\.akamaized\\.net/\\)\\s*\\|\\|\\s*.*?\\s*[cs]\\s*&&\\s*[adf]\\.set\\([^,]+\\s*,\\s*(?:encodeURIComponent\\s*\\()?\\s*([a-zA-Z0-9$]+)\\(",
@"\\b[cs]\\s*&&\\s*[adf]\\.set\\([^,]+\\s*,\\s*([a-zA-Z0-9$]+)\\(",
@"\\b[a-zA-Z0-9]+\\s*&&\\s*[a-zA-Z0-9]+\\.set\\([^,]+\\s*,\\s*([a-zA-Z0-9$]+)\\(",
@"\\bc\\s*&&\\s*a\\.set\\([^,]+\\s*,\\s*\\([^)]*\\)\\s*\\(\\s*([a-zA-Z0-9$]+)\\(",
@"\\bc\\s*&&\\s*[a-zA-Z0-9]+\\.set\\([^,]+\\s*,\\s*\\([^)]*\\)\\s*\\(\\s*([a-zA-Z0-9$]+)\\(",
@"\\bc\\s*&&\\s*[a-zA-Z0-9]+\\.set\\([^,]+\\s*,\\s*\\([^)]*\\)\\s*\\(\\s*([a-zA-Z0-9$]+)\\("
];

NSMutableArray<NSRegularExpression *>*validRegularExpressions = [NSMutableArray new];

for (NSString *pattern in patterns) {
Expand Down

0 comments on commit c31851f

Please sign in to comment.