From e59057f53fc28aade0caf6f0f0b18ee1ff7c043e Mon Sep 17 00:00:00 2001 From: Subhamoy Biswas Date: Fri, 7 Mar 2025 10:04:43 +0530 Subject: [PATCH] (refactor): show published_on attribute only if available to avoid nonetype error --- pytubepp/main.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pytubepp/main.py b/pytubepp/main.py index c4c2e22..aae46a5 100644 --- a/pytubepp/main.py +++ b/pytubepp/main.py @@ -159,7 +159,7 @@ class YouTubeDownloader: print('Sorry, No video streams found....!!!') sys.exit() - print(f'\nTitle: {self.video.title}\nAuthor: {self.author}\nPublished On: {self.video.publish_date.strftime("%d/%m/%Y")}\nDuration: {f"{self.video.length//3600:02}:{(self.video.length%3600)//60:02}:{self.video.length%60:02}" if self.video.length >= 3600 else f"{(self.video.length%3600)//60:02}:{self.video.length%60:02}"}\nViews: {self.views}\nCaptions: {"Available" if self.captions else "Unavailable"}') + print(f'\nTitle: {self.video.title}\nAuthor: {self.author}\nPublished On: {self.video.publish_date.strftime("%d/%m/%Y") if self.video.publish_date else "Unknown"}\nDuration: {f"{self.video.length//3600:02}:{(self.video.length%3600)//60:02}:{self.video.length%60:02}" if self.video.length >= 3600 else f"{(self.video.length%3600)//60:02}:{self.video.length%60:02}"}\nViews: {self.views}\nCaptions: {"Available" if self.captions else "Unavailable"}') print('\n') print(tabulate(table, headers=['Stream', 'Alias (for -s flag)', 'Format', 'Size', 'FrameRate', 'V-Codec', 'A-Codec', 'V-BitRate', 'A-BitRate'])) @@ -237,7 +237,7 @@ class YouTubeDownloader: 'author': self.author, 'thumbnail_url': self.thumbnail, 'views': self.video.views, - 'published_on': self.video.publish_date.strftime('%d/%m/%Y'), + 'published_on': self.video.publish_date.strftime('%d/%m/%Y') if self.video.publish_date else None, 'duration': self.video.length, 'streams': streams_list, 'captions': captions_list or None