]> git.bitcoin.ninja Git - youtube-dl/blobdiff - youtube_dl/utils.py
[facebook] Fix support for untitled videos (Fixes #3757)
[youtube-dl] / youtube_dl / utils.py
index 24778807813ec0b6303b6daf849c047b950b98e3..3ac0f1f541745b1ec34f1245574ea82387c3115d 100644 (file)
@@ -1571,3 +1571,13 @@ except AttributeError:
         if ret:
             raise subprocess.CalledProcessError(ret, p.args, output=output)
         return output
+
+
+def limit_length(s, length):
+    """ Add ellipses to overly long strings """
+    if s is None:
+        return None
+    ELLIPSES = '...'
+    if len(s) > length:
+        return s[:length - len(ELLIPSES)] + ELLIPSES
+    return s