]> git.bitcoin.ninja Git - youtube-dl/commitdiff
Merge pull request #8245 from dstftw/auto-generate-title-fields
authorSergey M <dstftw@gmail.com>
Sat, 16 Jan 2016 01:20:03 +0000 (07:20 +0600)
committerSergey M <dstftw@gmail.com>
Sat, 16 Jan 2016 01:20:03 +0000 (07:20 +0600)
[YoutubeDL] Auto generate title fields corresponding to the *_number fields

youtube_dl/YoutubeDL.py

index 6b73b8e06e0b53e5fb7764deaa349d8370f313dd..0748fbba0262cb29b90b73bba749d802f2b3bcc1 100755 (executable)
@@ -1244,6 +1244,12 @@ class YoutubeDL(object):
             except (ValueError, OverflowError, OSError):
                 pass
 
+        # Auto generate title fields corresponding to the *_number fields when missing
+        # in order to always have clean titles. This is very common for TV series.
+        for field in ('chapter', 'season', 'episode'):
+            if info_dict.get('%s_number' % field) is not None and not info_dict.get(field):
+                info_dict[field] = '%s %d' % (field.capitalize(), info_dict['%s_number' % field])
+
         subtitles = info_dict.get('subtitles')
         if subtitles:
             for _, subtitle in subtitles.items():