aboutsummaryrefslogtreecommitdiffstats
path: root/hypervideo_gui.py
diff options
context:
space:
mode:
authorJesús <heckyel@hyperbola.info>2019-12-10 15:48:09 -0500
committerJesús <heckyel@hyperbola.info>2019-12-10 15:48:09 -0500
commit822b127074496b7510bd8208a374c0f7ac52253f (patch)
tree8bb3d81f616c59dc1cc7d617e1fd71b298fd3fb8 /hypervideo_gui.py
parentd900fcbd1d76ae877f58db9148599d4720ea76e1 (diff)
downloadhypervideo-gui-822b127074496b7510bd8208a374c0f7ac52253f.tar.lz
hypervideo-gui-822b127074496b7510bd8208a374c0f7ac52253f.tar.xz
hypervideo-gui-822b127074496b7510bd8208a374c0f7ac52253f.zip
check formats
- Added try to extract formats - Detect formats empty
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