def start_palying_listener(output): """ Riceive messages from MyLogger to start ffplay in at a given time. """ IO_tools.stream_play(output, '', '') return
def playSelurl(self, event): """ Playback urls """ tstamp = '-vf "%s"' % self.parent.cmdtimestamp if \ self.parent.checktimestamp else '' if self.fcode.GetSelectedItemCount() == 0: self.parent.statusbar_msg( _('An item must be selected in the ' 'URLs checklist'), Downloader.YELLOW, Downloader.BLACK) return else: self.parent.statusbar_msg(_('YouTube Downloader'), None) item = self.fcode.GetFocusedItem() url = self.fcode.GetItemText(item, 1) if 'playlist' in url: # prevent opening too many of ffplay windows wx.MessageBox(_('Videomass cannot play playlists for now'), _('Videomass'), wx.ICON_INFORMATION, self) return if self.choice.GetSelection() in [0, 1, 2]: quality = self.fcode.GetItemText(item, 3) elif self.choice.GetSelection() == 3: quality = self.fcode.GetItemText(item, 0) IO_tools.url_play(url, quality, tstamp)
def start_palying_listener(output): """ Riceive message from Exec_Download_Stream class to start ffplay in at a given time. """ IO_tools.stream_play(output, '', '') return
def playSelect(self, event): """ Playback the selected file """ if not self.selected: self.parent.statusbar_msg(_('No file selected'), 'GOLDENROD', FileDnD.WHITE) else: self.parent.statusbar_msg(_('Add Files'), None) index = self.flCtrl.GetFocusedItem() item = self.flCtrl.GetItemText(index) if self.parent.checktimestamp: tstamp = '-vf "%s"' % (self.parent.cmdtimestamp) else: tstamp = "" IO_tools.stream_play(item, self.parent.time_seq, tstamp)
def dropUpdate(self, path): """ Update list-control during drag and drop """ self.index = self.GetItemCount() msg_dir = _("Directories are not allowed, just add files, please.") msg_noext = _("File without format extension: please give an " "appropriate extension to the file name, example " "'.mkv', '.avi', '.mp3', etc.") if os.path.isdir(path): self.parent.statusbar_msg(msg_dir, MyListCtrl.ORANGE, MyListCtrl.WHITE) return elif os.path.splitext(os.path.basename(path))[1] == '': self.parent.statusbar_msg(msg_noext, MyListCtrl.ORANGE, MyListCtrl.WHITE) return if not [x for x in self.data if x['format']['filename'] == path]: data = IO_tools.probeInfo(path) if data[1]: self.parent.statusbar_msg(data[1], MyListCtrl.RED, MyListCtrl.WHITE) return data = eval(data[0]) self.InsertItem(self.index, path) if 'duration' not in data['format'].keys(): self.SetItem(self.index, 1, 'N/A') # NOTE these are my adds in ffprobe data data['format']['time'] = '00:00:00.000' data['format']['duration'] = 0 else: t = data['format']['duration'].split(':') s, ms = t[2].split('.')[0], t[2].split('.')[1] t = '%sh : %sm : %ss : %sms' % (t[0], t[1], s, ms) self.SetItem(self.index, 1, t) data.get('format')['time'] = data.get('format').pop('duration') time = get_milliseconds(data.get('format')['time']) data['format']['duration'] = time media = data['streams'][0]['codec_type'] formatname = data['format']['format_long_name'] self.SetItem(self.index, 2, '%s: %s' % (media, formatname)) self.SetItem(self.index, 3, data['format']['size']) self.index += 1 self.data.append(data) self.parent.statusbar_msg('', None) self.parent.reset_tl() else: mess = _("Duplicate files are rejected: > '%s'") % path self.parent.statusbar_msg(mess, MyListCtrl.YELLOW, MyListCtrl.WHITE)
def get_libraryformatcode(self): """ Get URLs data and format codes by generator object *youtubedl_getstatistics* (using youtube_dl library) and set the list control with new entries. Return `True` if `meta[1]` (error), otherwise return None as exit staus. """ self.fcode.ClearAll() if self.oldwx is False: self.fcode.EnableCheckBoxes(enable=True) self.fcode.InsertColumn(0, (_('Format Code')), width=120) self.fcode.InsertColumn(1, (_('Url')), width=60) self.fcode.InsertColumn(2, (_('Title')), width=200) self.fcode.InsertColumn(3, (_('Extension')), width=80) self.fcode.InsertColumn(4, (_('Resolution')), width=160) self.fcode.InsertColumn(5, (_('Video Codec')), width=110) self.fcode.InsertColumn(6, (_('fps')), width=80) self.fcode.InsertColumn(7, (_('Audio Codec')), width=110) self.fcode.InsertColumn(8, (_('Size')), width=100) index = 0 for link in self.parent.data_url: data = IO_tools.youtubedl_getstatistics(link) for meta in data: if meta[1]: # self.parent.statusbar_msg('Youtube Downloader', None) wx.MessageBox(meta[1], 'Videomass', wx.ICON_ERROR) return True formats = iter(meta[0].get('formats', [meta[0]])) for n, f in enumerate(formats): if f.get('vcodec'): vcodec, fps = f['vcodec'], '%sfps' % f.get('fps') else: vcodec, fps = '', '' if f.get('acodec'): acodec = f['acodec'] else: acodec = 'Video only' if f.get('filesize'): size = format_bytes(float(f['filesize'])) else: size = 'N/A' self.fcode.InsertItem(index, f['format_id']) self.fcode.SetItem(index, 1, link) self.fcode.SetItem(index, 2, meta[0]['title']) self.fcode.SetItem(index, 3, f['ext']) self.fcode.SetItem(index, 4, f['format'].split('-')[1]) self.fcode.SetItem(index, 5, vcodec) self.fcode.SetItem(index, 6, fps) self.fcode.SetItem(index, 7, acodec) self.fcode.SetItem(index, 8, size) if n == 0: self.fcode.SetItemBackgroundColour(index, Downloader.GREEN) index += 1 return None
def get_statistics(self): """ Get media URLs informations by generator object *youtubedl_getstatistics* . Return `True` if `meta[1]` (error), otherwise return None as exit staus. """ for link in self.parent.data_url: data = IO_tools.youtubedl_getstatistics(link) for meta in data: if meta[1]: # self.parent.statusbar_msg('Youtube Downloader', None) wx.MessageBox(meta[1], 'Videomass', wx.ICON_ERROR) del self.info[:] return True if 'entries' in meta[0]: meta[0]['entries'][0] # not parse all playlist if 'duration' in meta[0]: ftime = '%s (%s sec.)' % (timehuman( meta[0]['duration']), meta[0]['duration']) else: ftime = 'N/A' date = meta[0].get('upload_date') self.info.append({ 'url': link, 'title': meta[0].get('title'), 'categories': meta[0].get('categories'), 'license': meta[0].get('license'), 'format': meta[0].get('format'), 'upload_date': date, 'uploader': meta[0].get('uploader'), 'view': meta[0].get('view_count'), 'like': meta[0].get('like_count'), 'dislike': meta[0].get('dislike_count'), 'average_rating': meta[0].get('average_rating'), 'id': meta[0].get('id'), 'duration': ftime, 'description': meta[0].get('description'), }) return None
def get_executableformatcode(self): """ Get URLs format codes data by generator object (using executable) *youtube_getformatcode_exec* and set list control. Return `True` if `meta[1]` (error), otherwise return None as exit staus. """ self.fcode.ClearAll() if self.oldwx is False: self.fcode.EnableCheckBoxes(enable=True) self.fcode.InsertColumn(0, (_('Format Code')), width=120) self.fcode.InsertColumn(1, (_('Url')), width=200) self.fcode.InsertColumn(2, (_('Title')), width=50) self.fcode.InsertColumn(3, (_('Extension')), width=80) self.fcode.InsertColumn(4, (_('Resolution note')), width=500) index = 0 for link in self.parent.data_url: data = IO_tools.youtube_getformatcode_exec(link) for meta in data: if meta[1]: wx.MessageBox(meta[0], 'Videomass', wx.ICON_ERROR) self.info = [] return True self.info.append(link) i = 0 for count, fc in enumerate(meta[0].split('\n')): if not count > i: i += 1 elif fc != '': self.fcode.InsertItem(index, fc.split()[0]) self.fcode.SetItem(index, 1, link) self.fcode.SetItem(index, 2, 'N/A') self.fcode.SetItem(index, 3, fc.split()[1]) note = ' '.join(fc.split()[2:]) self.fcode.SetItem(index, 4, note) if i + 1 == count: self.fcode.SetItemBackgroundColour(index, Downloader.GREEN ) index += 1 if fc.startswith('format code '): i = count # limit return None
def on_Selected(self, event): """ Gets output given ffmpeg `-arg` and fills the textctrl. The topic options are values of the arg_opt dictionary. """ arg_opt = { _("Topic List..."): 'None', _("print basic options"): ['-h'], _("print more options"): ['-h', 'long'], _("print all options (very long)"): ['-h', 'full'], _("show available devices"): ['-devices'], _("show available bit stream filters"): ['-bsfs'], _("show available protocols"): ['-protocols'], _("show available filters"): ['-filters'], _("show available pixel formats"): ['-pix_fmts'], _("show available audio sample formats"): ['-sample_fmts'], _("show available color names"): ['-colors'], _("list sources of the input device"): ['-sources', 'device'], _("list sinks of the output device"): ['-sinks', 'device'], _("show available HW acceleration methods"): ['-hwaccels'], } if "None" in arg_opt[self.cmbx_choice.GetValue()]: self.row = None self.texthelp.Clear() # reset textctrl self.texthelp.AppendText(_("Choose one of the topics in the list")) else: self.texthelp.Clear() # reset textctrl topic = arg_opt[self.cmbx_choice.GetValue()] self.row = IO_tools.findtopic(topic) if self.row: self.texthelp.AppendText(self.row) search = self.search.GetValue().strip() if search: # start already with text searching self.on_type_Text(self, True) else: self.texthelp.AppendText(_("\n ..Nothing available"))
def on_YoutubeDL(self, event): """ Check the existence of youtube-dl based on the set attributes of the bootstrap, then open the text interface, otherwise it requires installation. """ if self.oS == 'Windows': msg_windows = (_( '- Requires: Microsoft Visual C++ 2010 ' 'Redistributable Package (x86)\n\nfor major ' 'information visit: <http://ytdl-org.github.io' '/youtube-dl/download.html>' )) if self.oS == 'Darwin': msg_windows = '' else: msg_windows = '' msg_error = _('{}\n\nyoutube-dl: no library or executable ' 'found .').format(self.PYLIB_YDL) msg_required = (_( 'An updated version of youtube-dl is required to download ' 'videos from YouTube.com and other video sites. Videomass ' 'can download an updated copy of youtube-dl locally.\n\n' '- Web site: <https://github.com/ytdl-org/youtube-dl/' 'releases>\n{}\n\n' '...Do you wish to continue?' )).format(msg_windows) msg_ready = (_( 'Successful! \n\n' 'Important: youtube-dl is very often updated, be sure ' 'to always use the latest version available. Use the ' 'dedicated functions on menu bar > Tools > youtube-dl.\n\n' 'Re-start is required. Do you want to close Videomass now?' )) msg_system_used = (_( 'Note: the youtube-dl executable previously downloaded ' 'with Videomass is no longer in use, since the one ' 'included in the system is now used.\n\n' 'Do you want to remove the one no longer in use?' )) if self.PYLIB_YDL is None: fydl = os.path.join(self.CACHEDIR, self.YOUTUBE_DL) if self.WARN_YDL == 'false': if not self.EXEC_YDL and os.path.isfile(fydl): if self.store_ydl_on_cache: dlg = wx.RichMessageDialog(self, msg_system_used, _("Please confirm"), wx.ICON_QUESTION | wx.YES_NO ) dlg.ShowCheckBox(_("Don't show this dialog again")) if dlg.ShowModal() == wx.ID_NO: if dlg.IsCheckBoxChecked(): # make sure we won't show it # again the next time self.store_ydl_on_cache = False else: os.remove(fydl) if dlg.IsCheckBoxChecked(): self.store_ydl_on_cache = False self.parent.switch_text_import(self, 'Youtube Downloader') return elif self.EXEC_YDL: if os.path.isfile(self.EXEC_YDL): self.parent.switch_text_import(self, 'Youtube Downloader') return else: if wx.MessageBox(msg_required, _("Please confirm"), wx.ICON_QUESTION | wx.YES_NO, self) == wx.NO: return latest = self.parent.ydl_latest(self, msgbox=False) if latest[1]: return else: upgrade = IO_tools.youtubedl_upgrade(latest[0], self.EXEC_YDL) if upgrade[1]: # failed wx.MessageBox("%s" % (upgrade[1]), "Videomass", wx.ICON_ERROR, self) return else: if wx.MessageBox(msg_ready, "Videomass", wx.ICON_QUESTION | wx.YES_NO, self) == wx.NO: return self.parent.on_Kill() return elif self.EXEC_YDL is False: wx.MessageBox(msg_error, 'Videomass', wx.ICON_ERROR) return