diff options
Diffstat (limited to 'gallery_dl/text.py')
| -rw-r--r-- | gallery_dl/text.py | 9 |
1 files changed, 9 insertions, 0 deletions
diff --git a/gallery_dl/text.py b/gallery_dl/text.py index 79cf016..1fb1851 100644 --- a/gallery_dl/text.py +++ b/gallery_dl/text.py @@ -120,6 +120,15 @@ def extract(txt, begin, end, pos=0): return None, pos +def extr(txt, begin, end, default=""): + """Stripped-down version of 'extract()'""" + try: + first = txt.index(begin) + len(begin) + return txt[first:txt.index(end, first)] + except (ValueError, TypeError, AttributeError): + return default + + def rextract(txt, begin, end, pos=-1): try: lbeg = len(begin) |
