aboutsummaryrefslogtreecommitdiffstats
path: root/hypervideo_gui.py
diff options
context:
space:
mode:
Diffstat (limited to 'hypervideo_gui.py')
-rw-r--r--hypervideo_gui.py24
1 files changed, 16 insertions, 8 deletions
diff --git a/hypervideo_gui.py b/hypervideo_gui.py
index 748d97a..4f4ef42 100644
--- a/hypervideo_gui.py
+++ b/hypervideo_gui.py
@@ -214,16 +214,24 @@ class App(QMainWindow):
'noplaylist': True, # only download single song, not playlist
}
- with hypervideo.YoutubeDL(self.options) as ydl:
- meta = ydl.extract_info(url, download=False)
- formats = meta.get('formats', [meta])
+ try:
+ with hypervideo.YoutubeDL(self.options) as ydl:
+ meta = ydl.extract_info(url, download=False)
+ formats = meta.get('formats', [meta])
+ except TypeError:
+ self.statusBar().showMessage('Problem downloading %s' % url)
+ return None
# add formats to combobox
- item_list = self.default_video_formats_menu_items[0:2]
- item_list.extend([f['format_id'] + ' - ' + f['ext'] for f in formats])
- self.populateVideoFormatCombobox(item_list)
- self.statusBar().showMessage('Finished Downloading Video Formats')
- self.videoFormatCombobox.setCurrentIndex(0)
+ if format is None:
+ self.statusBar().showMessage('Formats not found')
+ else:
+ item_list = self.default_video_formats_menu_items[0:2]
+ item_list.extend([f['format_id'] + ' - ' + f['ext'] for f in formats])
+ self.populateVideoFormatCombobox(item_list)
+ self.statusBar().showMessage('Finished Downloading Video Formats')
+ # QTimer.singleShot(3000, lambda: self.videoFormatCombobox.setCurrentIndex(0))
+ self.videoFormatCombobox.setCurrentIndex(0)
# check if is valid url
# should probably be reworked to be compatible with non-YouTube websites