X-Git-Url: http://git.bitcoin.ninja/index.cgi?a=blobdiff_plain;f=youtube_dl%2Futils.py;h=1d9785341ec685071ea8fcc4846029a3e889bc72;hb=db477d3a37cbe5df5fd9151d557db33d8534e9f2;hp=833f981f24ca7b9dc2b2fd6cd79a40fe83afd019;hpb=9d4660cab15f374176f87d3f747a559142e4af9b;p=youtube-dl diff --git a/youtube_dl/utils.py b/youtube_dl/utils.py index 833f981f2..1d9785341 100644 --- a/youtube_dl/utils.py +++ b/youtube_dl/utils.py @@ -572,6 +572,11 @@ class ExtractorError(Exception): return u''.join(traceback.format_tb(self.traceback)) +class RegexNotFoundError(ExtractorError): + """Error when a regex didn't match""" + pass + + class DownloadError(Exception): """Download Error exception. @@ -947,6 +952,15 @@ def shell_quote(args): return ' '.join(map(pipes.quote, args)) +def takewhile_inclusive(pred, seq): + """ Like itertools.takewhile, but include the latest evaluated element + (the first element so that Not pred(e)) """ + for e in seq: + yield e + if not pred(e): + return + + def smuggle_url(url, data): """ Pass additional data in a URL for internal use. """