def __init__(self, parent, default_url=""): wx.Frame.__init__(self, parent=parent, title=_("تنزيل")) self.path = config_get("path") self.Centre() self.downloading = False self.panel = wx.Panel(self) sizer = wx.BoxSizer(wx.VERTICAL) sizer1 = wx.BoxSizer(wx.HORIZONTAL) sizer2 = wx.BoxSizer(wx.HORIZONTAL) lbl = wx.StaticText(self.panel, -1, _("رابط التنزيل: : ")) self.videoLink = wx.TextCtrl(self.panel, -1, value=default_url) self.downloadingFormat = wx.RadioBox(self.panel, -1, _("نوع المقطع"), choices=[_("صوت"), _("فيديو")]) lbl2 = wx.StaticText(self.panel, -1, _("صيغة المقطع"), name="convert") self.convertingFormat = wx.Choice(self.panel, -1, choices=["m4a", "mp3"], name="convert") self.convertingFormat.SetSelection(int(config_get("defaultaudio"))) self.downloadButton = wx.Button(self.panel, -1, _("تنزيل")) self.downloadButton.SetDefault() self.changePath = wx.Button(self.panel, -1, f"{_('مسار مجلد التنزيل: ')} {self.path}") self.changePath.Bind(wx.EVT_BUTTON, self.onChangePath) sizer1.Add(lbl, 1) sizer1.Add(self.videoLink, 1, wx.EXPAND) sizer.Add(sizer1, 1, wx.EXPAND) sizer.Add(self.downloadingFormat, 1, wx.EXPAND) sizer2.Add(lbl2) sizer2.Add(self.convertingFormat, 1, wx.EXPAND) sizer.Add(sizer2, 1, wx.EXPAND) sizer.Add(self.downloadButton, 1, wx.EXPAND) sizer.Add(self.changePath, 1, wx.EXPAND) self.panel.SetSizer(sizer) # event bindings self.downloadButton.Bind(wx.EVT_BUTTON, self.onDownload) self.Bind(wx.EVT_ACTIVATE, self.onActivate) self.Bind(wx.EVT_RADIOBOX, self.onRadioBox) self.Bind(wx.EVT_CHAR_HOOK, self.onHook)
def init_translation(domain): try: tr = gettext.translation(domain, localedir="languages", languages=[config_get("lang")]) except: tr = gettext.translation(domain, fallback=True) tr.install()
def directDownload(self): n = self.searchResults.Selection if self.search.get_views(n) is None: return url = self.search.get_url(self.searchResults.Selection) title = self.search.get_title(self.searchResults.Selection) dlg = DownloadProgress(self.Parent, title) direct_download(int(config_get('defaultformat')), url, dlg)
def onListBox(self, event): self.togleDownload() if self.searchResults.Selection == len(self.searchResults.Strings)-1: if not config_get("autoload"): self.loadMoreButton.Enabled = True return Thread(target=self.loadMore).start() else: self.loadMoreButton.Enabled = False
def direct_download(option, url, dlg): path = config_get("path") if option == 0: format = "bestvideo[ext=mp4]+bestaudio[ext=m4a]/mp4" else: format = "bestaudio[ext=m4a]" convert = True if option == 2 else False trd = Thread(target=downloadAction, args=[url, path, dlg, format, dlg.gaugeProgress, dlg.textProgress, convert]) trd.start()
def onDownloadChannel(self, event): n = self.searchResults.Selection channel = self.search.get_channel(n) title = channel["name"] url = channel["url"] download_type = "channel" dlg = DownloadProgress(self.Parent, title) direct_download(int(config_get('defaultformat')), url, dlg, download_type)
def togleControls(self): if self.searchResults.Strings == []: for control in self.panel.GetChildren(): if control.Name == "controls": control.Hide() self.loadMoreButton.Hide() else: for control in self.panel.GetChildren(): if control.Name == "controls": control.Show() self.loadMoreButton.Show(not config_get("autoload"))
def __init__(self,filename, hwnd): self.do_reset = False self.filename = filename self.hwnd = hwnd self.media = media_player self.set_media(self.filename) self.media.set_hwnd(self.hwnd) self.manager = self.media.event_manager() self.manager.event_attach(vlc.EventType.MediaPlayerEndReached,self.onEnd) self.media.play() self.volume = int(config_get("volume")) self.media.audio_set_volume(self.volume)
def onOk(self, event): for key, item in self.preferences.items(): config_set(key, item) if not self.mp3Quality.Selection == int(config_get("conversion")): config_set("conversion", self.mp3Quality.Selection) config_set( "defaultformat", self.formats.Selection) if not self.formats.Selection == int( config_get('defaultformat')) else None lang = {value: key for key, value in languages.items()} if not lang[self.languageBox.Selection] == config_get("lang"): config_set("lang", lang[self.languageBox.Selection]) msg = wx.MessageBox(_( "لقد قمت بتغيير لغة البرنامج إلى {}, مما يعني أنه ينبغي عليك إعادة تشغيل البرنامج لتطبيق التعديلات. هل تريد القيام بذلك حالًا?" ).format(self.languageBox.StringSelection), _("تنبيه"), style=wx.YES_NO, parent=self) os.execl(sys.executable, sys.executable, * sys.argv) if msg == 2 else None self.Destroy()
def documentation_get(): lang = config_get("lang") if not lang in available_languages: lang = "ar" path = os.path.join(os.getcwd(), f"docs\\{lang}\\guide.txt") if not os.path.exists(path): return with open(path, "r", encoding="utf-8") as file: namespace = { "name": application.name, "version": application.version, "author": application.author } return file.read().format(**namespace)
def __init__(self): wx.Frame.__init__(self, parent=None, title=application.name) self.Centre() self.Maximize(True) panel = wx.Panel(self) self.instruction = CustomLabel(panel, -1, _("اضغط على مفتاح القوائم alt للوصول إلى خيارات البرنامج, أو تنقل بزر التاب للوصول سريعًا إلى أهم الخيارات المتاحة.")) # a breafe instruction message witch is shown by the custome StaticText to automaticly be focused when launching the app youtubeBrowseButton = wx.Button(panel, -1, _("البحث في youtube\tctrl+f"), name="tab") downloadFromLinkButton = wx.Button(panel, -1, _("التنزيل من خلال رابط\tctrl+d"), name="tab") playYoutubeLinkButton = wx.Button(panel, -1, _("تشغيل فيديو youtube من خلال الرابط\tctrl+y"), name="tab") # quick access buttons sizer = wx.BoxSizer(wx.VERTICAL) # the main sizer sizer1 = wx.BoxSizer(wx.HORIZONTAL) # quick access buttons sizer for control in panel.GetChildren(): if control.Name == "tab": sizer1.Add(control, 1) # adding quick access buttons using for loop sins that eatch button named by the "tab" word sizer.Add(self.instruction, 1) sizer.AddStretchSpacer() sizer.Add(sizer1, 1, wx.EXPAND) panel.SetSizer(sizer) # adding the sizer to the main panel menuBar = wx.MenuBar() # seting up the menu bar mainMenu = wx.Menu() searchItem = mainMenu.Append(-1, _("البحث في youtube\tctrl+f")) # search in youtube item downloadItem = mainMenu.Append(-1, _("التنزيل من خلال رابط\tctrl+d"))# download link item playItem = mainMenu.Append(-1, _("تشغيل فيديو youtube من خلال الرابط\tctrl+y")) # play youtube link item openDownloadingPathItem = mainMenu.Append(-1, _("فتح مجلد التنزيل\tctrl+p")) # open downloading folder item settingsItem = mainMenu.Append(-1, _("الإعدادات...\talt+s")) # settings item exitItem = mainMenu.Append(-1, _("خروج\tctrl+w")) # quit item menuBar.Append(mainMenu, _("القائمة الرئيسية")) # append the main menu to the menu bar aboutMenu = wx.Menu() userGuideItem = aboutMenu.Append(-1, _("دليل المستخدم...\tf1")) # userguide aboutItem = aboutMenu.Append(-1, _("عن البرنامج...")) # about item menuBar.Append(aboutMenu, _("حول")) # append the about menu to the menu bar self.SetMenuBar(menuBar) # add the menu bar to the window # event bindings self.Bind(wx.EVT_MENU, self.onSearch, searchItem) youtubeBrowseButton.Bind(wx.EVT_BUTTON, self.onSearch) self.Bind(wx.EVT_MENU, self.onDownload, downloadItem) downloadFromLinkButton.Bind(wx.EVT_BUTTON, self.onDownload) self.Bind(wx.EVT_MENU, self.onPlay, playItem) playYoutubeLinkButton.Bind(wx.EVT_BUTTON, self.onPlay) self.Bind(wx.EVT_MENU, self.onOpen, openDownloadingPathItem) self.Bind(wx.EVT_MENU, lambda event: SettingsDialog(self), settingsItem) self.Bind(wx.EVT_MENU, lambda event: wx.Exit(), exitItem) self.Bind(wx.EVT_MENU, self.onGuide, userGuideItem) self.Bind(wx.EVT_MENU, self.onAbout, aboutItem) self.Bind(wx.EVT_CHAR_HOOK, self.onHook) self.Show() self.detectFromClipboard(settings_handler.config_get("autodetect"))
def __init__(self, parent): wx.Frame.__init__(self, parent=parent, title=parent.Title) self.Centre() self.Maximize(True) self.panel = wx.Panel(self) lbl = wx.StaticText(self.panel, -1, _("نتائج البحث: ")) self.searchResults = wx.ListBox(self.panel, -1, choices=[]) self.loadMoreButton = wx.Button(self.panel, -1, _("تحميل المزيد من النتائج")) self.loadMoreButton.Enabled = False self.loadMoreButton.Show(not config_get("autoload")) playButton = wx.Button(self.panel, -1, _("تشغيل (enter)"), name="controls") self.downloadButton = wx.Button(self.panel, -1, _("تنزيل"), name="controls") searchButton = wx.Button(self.panel, -1, _("بحث... (ctrl+f)")) backButton = wx.Button(self.panel, -1, _("العودة إلى النافذة الرئيسية")) sizer = wx.BoxSizer(wx.VERTICAL) sizer1 = wx.BoxSizer(wx.HORIZONTAL) sizer1.Add(backButton, 1, wx.ALL) sizer1.Add(searchButton, 1, wx.ALL) sizer2 = wx.BoxSizer(wx.HORIZONTAL) for control in self.panel.GetChildren(): if control.Name == "controls": sizer2.Add(control, 1) control.Bind(wx.EVT_KEY_DOWN, self.onKeyDown) sizer.Add(sizer1, 1, wx.EXPAND) sizer.Add(lbl, 1, wx.ALL) sizer.Add(self.searchResults, 1, wx.EXPAND) sizer.Add(self.loadMoreButton, 1) sizer.Add(sizer2, 1) self.panel.SetSizer(sizer) self.contextSetup() menuBar = wx.MenuBar() optionsMenu = wx.Menu() settingsItem = optionsMenu.Append(-1, _("الإعدادات...\talt+s")) menuBar.Append(optionsMenu, _("خيارات")) self.SetMenuBar(menuBar) self.Bind(wx.EVT_MENU, lambda event: SettingsDialog(self), settingsItem) self.loadMoreButton.Bind(wx.EVT_BUTTON, self.onLoadMore) playButton.Bind(wx.EVT_BUTTON, lambda event: self.playVideo()) self.downloadButton.Bind(wx.EVT_BUTTON, self.onDownload) searchButton.Bind(wx.EVT_BUTTON, self.onSearch) backButton.Bind(wx.EVT_BUTTON, lambda event: self.backAction()) self.searchResults.Bind(wx.EVT_CHAR_HOOK, self.onHook) self.Bind(wx.EVT_LISTBOX_DCLICK, lambda event: self.playVideo(), self.searchResults) self.searchResults.Bind(wx.EVT_LISTBOX, self.onListBox) self.Bind(wx.EVT_CLOSE, lambda event: wx.Exit()) self.Show() self.Parent.Hide() self.searchAction()
def get_quality(self): qualities = {0: '96', 1: '128', 2: '192'} return qualities[int(config_get("conversion"))]
def __init__(self, parent): wx.Dialog.__init__(self, parent, title=_("الإعدادات")) self.SetSize(500, 500) self.Centre() self.preferences = {} panel = wx.Panel(self) lbl = wx.StaticText(panel, -1, _("لغة البرنامج: "), name="language") self.languageBox = wx.Choice(panel, -1, name="language") self.languageBox.Set(list(supported_languages.keys())) try: self.languageBox.Selection = languages[config_get("lang")] except KeyError: self.languageBox.Selection = 0 lbl1 = wx.StaticText(panel, -1, _("مسار مجلد التنزيل: "), name="path") self.pathField = wx.TextCtrl(panel, -1, value=config_get("path"), name="path", style=wx.TE_READONLY | wx.TE_MULTILINE | wx.HSCROLL) changeButton = wx.Button(panel, -1, _("&تغيير المسار"), name="path") preferencesBox = wx.StaticBox(panel, -1, _("التفضيلات العامة")) self.autoDetectItem = wx.CheckBox( preferencesBox, -1, _("اكتشاف الروابط تلقائيًا عند فتح البرنامج"), name="autodetect") self.autoCheckForUpdates = wx.CheckBox( preferencesBox, -1, _("الكشف عن التحديثات الجديدة تلقائيًا عند فتح البرنامج"), name="checkupdates") self.autoLoadItem = wx.CheckBox( preferencesBox, -1, _("تحميل المزيد من نتائج البحث عند الوصول إلى نهاية قائمة الفيديوهات المعروضة" ), name="autoload") self.autoCheckForUpdates.SetValue(config_get("checkupdates")) self.autoDetectItem.SetValue(config_get("autodetect")) self.autoLoadItem.SetValue(config_get("autoload")) downloadPreferencesBox = wx.StaticBox(panel, -1, _("إعدادات التنزيل")) lbl2 = wx.StaticText(downloadPreferencesBox, -1, _("صيغة التحميل المباشر: ")) self.formats = wx.Choice( downloadPreferencesBox, -1, choices=[_("فيديو (mp4)"), _("صوت (m4a)"), _("صوت (mp3)")]) self.formats.Selection = int(config_get('defaultformat')) lbl3 = wx.StaticText(downloadPreferencesBox, -1, _("جودة تحويل ملفات mp3: ")) self.mp3Quality = wx.Choice( downloadPreferencesBox, -1, choices=["96 kbps", "128 kbps", "192 kbps"], name="conversion") self.mp3Quality.Selection = int(config_get("conversion")) playerOptions = wx.StaticBox(panel, -1, _("إعدادات المشغل")) self.repeateTracks = wx.CheckBox( playerOptions, -1, _("إعادة تشغيل المقطع تلقائيًا عند انتهائه"), name="repeatetracks") self.repeateTracks.Value = config_get("repeatetracks") okButton = wx.Button(panel, wx.ID_OK, _("مواف&ق"), name="ok_cancel") okButton.SetDefault() cancelButton = wx.Button(panel, wx.ID_CANCEL, _("إل&غاء"), name="ok_cancel") sizer = wx.BoxSizer(wx.VERTICAL) sizer1 = wx.BoxSizer(wx.HORIZONTAL) sizer2 = wx.BoxSizer(wx.HORIZONTAL) sizer3 = wx.BoxSizer(wx.HORIZONTAL) sizer4 = wx.BoxSizer(wx.VERTICAL) sizer5 = wx.BoxSizer(wx.HORIZONTAL) sizer6 = wx.BoxSizer(wx.HORIZONTAL) sizer7 = wx.BoxSizer(wx.HORIZONTAL) okCancelSizer = wx.BoxSizer(wx.HORIZONTAL) sizer1.Add(lbl, 1) sizer1.Add(self.languageBox, 1, wx.EXPAND) for control in panel.GetChildren(): if control.Name == "ok_cancel": okCancelSizer.Add(control, 1) elif control.Name == "path": sizer2.Add(control, 1) for item in preferencesBox.GetChildren(): sizer3.Add(item, 1) preferencesBox.SetSizer(sizer3) sizer5.Add(lbl3, 1) sizer5.Add(self.mp3Quality, 1) sizer6.Add(lbl2, 1) sizer6.Add(self.formats, 1) sizer4.Add(sizer5) sizer4.Add(sizer6) downloadPreferencesBox.SetSizer(sizer4) for ctrl in playerOptions.GetChildren(): sizer7.Add(ctrl, 1) playerOptions.SetSizer(sizer7) sizer.Add(sizer1, 1, wx.EXPAND) sizer.Add(sizer2, 1, wx.EXPAND) sizer.Add(preferencesBox, 1, wx.EXPAND) sizer.Add(downloadPreferencesBox, 1, wx.EXPAND) sizer.Add(playerOptions, 1, wx.EXPAND) sizer.Add(okCancelSizer, 1, wx.EXPAND) panel.SetSizer(sizer) changeButton.Bind(wx.EVT_BUTTON, self.onChange) self.autoDetectItem.Bind(wx.EVT_CHECKBOX, self.onCheck) self.autoLoadItem.Bind(wx.EVT_CHECKBOX, self.onCheck) self.autoCheckForUpdates.Bind(wx.EVT_CHECKBOX, self.onCheck) self.repeateTracks.Bind(wx.EVT_CHECKBOX, self.onCheck) okButton.Bind(wx.EVT_BUTTON, self.onOk) self.ShowModal()
def __init__(self): wx.Frame.__init__(self, parent=None, title=application.name) self.Centre() self.SetSize(wx.DisplaySize()) self.Maximize(True) panel = wx.Panel(self) self.instruction = CustomLabel(panel, -1, _("اضغط على مفتاح القوائم alt للوصول إلى خيارات البرنامج, أو تنقل بزر التاب للوصول سريعًا إلى أهم الخيارات المتاحة.")) # a breafe instruction message witch is shown by the custome StaticText to automaticly be focused when launching the app youtubeBrowseButton = wx.Button(panel, -1, _("البحث في youtube\tctrl+f"), name="tab") downloadFromLinkButton = wx.Button(panel, -1, _("التنزيل من خلال رابط\tctrl+d"), name="tab") playYoutubeLinkButton = wx.Button(panel, -1, _("تشغيل فيديو youtube من خلال الرابط\tctrl+y"), name="tab") # quick access buttons sizer = wx.BoxSizer(wx.VERTICAL) # the main sizer sizer1 = wx.BoxSizer(wx.HORIZONTAL) # quick access buttons sizer for control in panel.GetChildren(): if control.Name == "tab": sizer1.Add(control, 1) # adding quick access buttons using for loop sins that eatch button named by the "tab" word sizer.Add(self.instruction, 1) sizer.AddStretchSpacer() sizer.Add(sizer1, 1, wx.EXPAND) panel.SetSizer(sizer) # adding the sizer to the main panel menuBar = wx.MenuBar() # seting up the menu bar mainMenu = wx.Menu() searchItem = mainMenu.Append(-1, _("البحث في youtube\tctrl+f")) # search in youtube item downloadItem = mainMenu.Append(-1, _("التنزيل من خلال رابط\tctrl+d"))# download link item playItem = mainMenu.Append(-1, _("تشغيل فيديو youtube من خلال الرابط\tctrl+y")) # play youtube link item openDownloadingPathItem = mainMenu.Append(-1, _("فتح مجلد التنزيل\tctrl+p")) # open downloading folder item settingsItem = mainMenu.Append(-1, _("الإعدادات...\talt+s")) # settings item exitItem = mainMenu.Append(-1, _("خروج\tctrl+w")) # quit item hotKeys = wx.AcceleratorTable([ (wx.ACCEL_CTRL, ord("F"), searchItem.GetId()), (wx.ACCEL_CTRL, ord("D"), downloadItem.GetId()), (wx.ACCEL_CTRL, ord("Y"), playItem.GetId()), (wx.ACCEL_CTRL, ord("P"), openDownloadingPathItem.GetId()), (wx.ACCEL_ALT, ord("S"), settingsItem.GetId()), (wx.ACCEL_CTRL, ord("W"), exitItem.GetId()) ]) # the accelerator table asociated with the menu items self.SetAcceleratorTable(hotKeys) # adding the accelerator table to the frame menuBar.Append(mainMenu, _("القائمة الرئيسية")) # append the main menu to the menu bar aboutMenu = wx.Menu() userGuideItem = aboutMenu.Append(-1, _("دليل المستخدم...\tf1")) # userguide checkForUpdatesItem = aboutMenu.Append(-1, _("البحث عن التحديثات")) aboutItem = aboutMenu.Append(-1, _("عن البرنامج...")) # about item contactMenu = wx.Menu() emailItem = contactMenu.Append(-1, _("البريد الالكتروني...")) twitterItem = contactMenu.Append(-1, _("تويتر...")) aboutMenu.AppendSubMenu(contactMenu, _("تواصل معي")) menuBar.Append(aboutMenu, _("حول")) # append the about menu to the menu bar self.SetMenuBar(menuBar) # add the menu bar to the window # event bindings self.Bind(wx.EVT_MENU, self.onSearch, searchItem) youtubeBrowseButton.Bind(wx.EVT_BUTTON, self.onSearch) self.Bind(wx.EVT_MENU, self.onDownload, downloadItem) downloadFromLinkButton.Bind(wx.EVT_BUTTON, self.onDownload) self.Bind(wx.EVT_MENU, self.onPlay, playItem) playYoutubeLinkButton.Bind(wx.EVT_BUTTON, self.onPlay) self.Bind(wx.EVT_MENU, self.onOpen, openDownloadingPathItem) self.Bind(wx.EVT_MENU, lambda event: SettingsDialog(self), settingsItem) self.Bind(wx.EVT_MENU, lambda event: wx.Exit(), exitItem) self.Bind(wx.EVT_MENU, self.onGuide, userGuideItem) self.Bind(wx.EVT_MENU, self.onCheckForUpdates, checkForUpdatesItem) self.Bind(wx.EVT_MENU, self.onAbout, aboutItem) self.Bind(wx.EVT_MENU, lambda event: webbrowser.open("mailto:[email protected]"), emailItem) self.Bind(wx.EVT_MENU, lambda event: webbrowser.open("https://twitter.com/suleiman3ahmed"), twitterItem) self.Bind(wx.EVT_CHAR_HOOK, self.onHook) self.Bind(wx.EVT_SHOW, self.onShow) self.Show() self.detectFromClipboard(settings_handler.config_get("autodetect")) if settings_handler.config_get("checkupdates"): Thread(target=check_for_updates, args=[True]).start()
def onDirect(self, event): dlg = DownloadProgress(self.Parent.Parent, self.title) direct_download(int(config_get('defaultformat')), self.url, dlg)
def onCheck(self, event): obj = event.EventObject if obj.Name in self.preferences and config_get(obj.Name) == obj.Value: del self.preferences[obj.Name] elif not obj.Value == config_get(obj.Name): self.preferences[obj.Name] = obj.Value
def __init__(self, parent, title, url, can_download=True, results=None, audio_mode=False): wx.Frame.__init__(self, parent, title=f'{title} - {application.name}') self.title = title self.stream = not can_download self.seek = int(config_get("seek")) self.results = results self.audio_mode = audio_mode self.Centre() self.SetSize(wx.DisplaySize()) self.Maximize(True) self.SetBackgroundColour(wx.BLACK) self.player = None self.url = url previousButton = CustomButton(self, -1, _("المقطع السابق"), name="controls") previousButton.Show( ) if self.results is not None else previousButton.Hide() beginingButton = CustomButton(self, -1, _("بداية المقطع"), name="controls") rewindButton = CustomButton(self, -1, _("إرجاع المقطع <"), name="controls") playButton = CustomButton(self, -1, _("تشغيل\إيقاف"), name="controls") forwardButton = CustomButton(self, -1, _("تقديم المقطع >"), name="controls") nextButton = CustomButton(self, -1, _("المقطع التالي"), name="controls") nextButton.Show() if self.results is not None else nextButton.Hide() sizer = wx.BoxSizer(wx.VERTICAL) sizer1 = wx.BoxSizer(wx.HORIZONTAL) for control in self.GetChildren(): if control.Name == "controls": sizer1.Add(control, 1) sizer.AddStretchSpacer() sizer.Add(sizer1) self.SetSizer(sizer) menuBar = wx.MenuBar() trackOptions = wx.Menu() downloadMenu = wx.Menu() videoItem = downloadMenu.Append(-1, _("فيديو")) audioMenu = wx.Menu() m4aItem = audioMenu.Append(-1, "m4a") mp3Item = audioMenu.Append(-1, "mp3") downloadMenu.AppendSubMenu(audioMenu, _("صوت")) downloadId = trackOptions.AppendSubMenu(downloadMenu, _("تنزيل")).GetId() trackOptions.Enable(downloadId, can_download) directDownloadItem = trackOptions.Append( -1, _("التنزيل المباشر...\tctrl+d")) directDownloadItem.Enable(can_download) descriptionItem = trackOptions.Append(-1, _("وصف الفيديو\tctrl+shift+d")) copyItem = trackOptions.Append(-1, _("نسخ رابط المقطع\tctrl+l")) browserItem = trackOptions.Append( -1, _("الفتح من خلال متصفح الإنترنت\tctrl+b")) settingsItem = trackOptions.Append(-1, _("الإعدادات.\talt+s")) hotKeys = wx.AcceleratorTable([ (wx.ACCEL_CTRL, ord("D"), directDownloadItem.GetId()), (wx.ACCEL_CTRL | wx.ACCEL_SHIFT, ord("D"), descriptionItem.GetId()), (wx.ACCEL_CTRL, ord("L"), copyItem.GetId()), (wx.ACCEL_CTRL, ord("B"), browserItem.GetId()), (wx.ACCEL_ALT, ord("S"), settingsItem.GetId()) ]) self.SetAcceleratorTable(hotKeys) menuBar.Append(trackOptions, _("خيارات المقطع")) self.SetMenuBar(menuBar) self.Bind(wx.EVT_MENU, self.onVideoDownload, videoItem) self.Bind(wx.EVT_MENU, self.onM4aDownload, m4aItem) self.Bind(wx.EVT_MENU, self.onMp3Download, mp3Item) self.Bind(wx.EVT_MENU, self.onDirect, directDownloadItem) self.Bind(wx.EVT_MENU, self.onDescription, descriptionItem) self.Bind(wx.EVT_MENU, self.onCopy, copyItem) self.Bind(wx.EVT_MENU, self.onBrowser, browserItem) self.Bind(wx.EVT_MENU, lambda event: SettingsDialog(self), settingsItem) self.Bind(wx.EVT_KEY_DOWN, self.onKeyDown) for control in self.GetChildren(): control.Bind(wx.EVT_KEY_DOWN, self.onKeyDown) previousButton.Bind(wx.EVT_BUTTON, lambda event: self.previous()) beginingButton.Bind(wx.EVT_BUTTON, lambda event: self.beginingAction()) rewindButton.Bind(wx.EVT_BUTTON, lambda event: self.rewindAction()) playButton.Bind(wx.EVT_BUTTON, lambda event: self.playAction()) forwardButton.Bind(wx.EVT_BUTTON, lambda event: self.forwardAction()) nextButton.Bind(wx.EVT_BUTTON, lambda event: self.next()) self.Bind(wx.EVT_CLOSE, lambda event: self.closeAction()) Thread(target=self.extract_description).start()
def onKeyDown(self, event): event.Skip() if event.GetKeyCode() in (wx.WXK_SPACE, wx.WXK_PAUSE, 430): self.playAction() elif event.GetKeyCode( ) == wx.WXK_RIGHT and not event.HasAnyModifiers(): self.forwardAction() elif event.GetKeyCode() == wx.WXK_LEFT and not event.HasAnyModifiers(): self.rewindAction() elif event.controlDown and event.KeyCode == wx.WXK_RIGHT: self.next() elif event.controlDown and event.KeyCode == wx.WXK_LEFT: self.previous() elif event.GetKeyCode() == wx.WXK_UP: self.increase_volume() elif event.GetKeyCode() == wx.WXK_DOWN: self.decrease_volume() elif event.GetKeyCode() == wx.WXK_HOME: self.beginingAction() elif event.KeyCode in range(49, 58): self.set_position(event.KeyCode) elif event.controlDown and event.shiftDown and event.KeyCode == ord( "L"): self.get_duration() elif event.controlDown and event.shiftDown and event.KeyCode == ord( "T"): if self.player is not None: speak(_("الوقت المنقضي: {}").format(self.player.get_elapsed())) elif event.KeyCode == ord("S"): if self.player is not None: self.player.media.set_rate(1.4) speak(_("سريع")) elif event.KeyCode == ord("D"): if self.player is not None: self.player.media.set_rate(1.0) speak(_("معتدل")) elif event.KeyCode == ord("F"): if self.player is not None: self.player.media.set_rate(0.6) speak(_("بطيء")) elif event.GetKeyCode() in (ord("-"), wx.WXK_NUMPAD_SUBTRACT): self.seek -= 1 if self.seek < 1: self.seek = 1 speak("{} {} {}".format(_("تحريك المقطع"), self.seek, _("ثانية/ثواني"))) config_set("seek", self.seek) elif event.GetKeyCode() in (ord("="), wx.WXK_NUMPAD_ADD): self.seek += 1 if self.seek > 10: self.seek = 10 speak("{} {} {}".format(_("تحريك المقطع"), self.seek, _("ثانية/ثواني"))) config_set("seek", self.seek) elif event.KeyCode == ord("R"): if config_get("repeatetracks"): config_set("repeatetracks", False) speak(_("التكرار متوقف")) else: config_set("repeatetracks", True) speak(_("التكرار مفعل")) elif event.KeyCode in (wx.WXK_RETURN, wx.WXK_NUMPAD_ENTER): self.togleFullScreen() elif event.KeyCode == wx.WXK_ALT: if self.IsFullScreen(): self.ShowFullScreen(False) elif event.GetKeyCode() == wx.WXK_ESCAPE: self.closeAction()
def onOpen(self, event): path = settings_handler.config_get("path") if not os.path.exists(path): os.mkdir(path) explorer = os.path.join(os.getenv("SYSTEMDRIVE"), "\\windows\\explorer") subprocess.call(f"{explorer} {path}")
def __init__(self, parent, title, url, can_download=True): wx.Frame.__init__(self, parent, title=f'{title} - {application.name}') self.title = title self.stream = not can_download self.seek = int(config_get("seek")) self.Centre() self.Maximize(True) self.SetBackgroundColour(wx.BLACK) self.player = None self.url = url beginingButton = CustomeButton(self, -1, _("بداية المقطع"), "controls") rewindButton = CustomeButton(self, -1, _("إرجاع المقطع <"), "controls") playButton = CustomeButton(self, -1, _("تشغيل\إيقاف"), "controls") forwardButton = CustomeButton(self, -1, _("تقديم المقطع >"), "controls") sizer = wx.BoxSizer(wx.VERTICAL) sizer1 = wx.BoxSizer(wx.HORIZONTAL) for control in self.GetChildren(): if control.Name == "controls": sizer1.Add(control, 1) sizer.AddStretchSpacer() sizer.Add(sizer1) self.SetSizer(sizer) menuBar = wx.MenuBar() trackOptions = wx.Menu() downloadMenu = wx.Menu() downloadId = wx.NewId() videoItem = downloadMenu.Append(-1, _("فيديو")) audioMenu = wx.Menu() m4aItem = audioMenu.Append(-1, "m4a") mp3Item = audioMenu.Append(-1, "mp3") downloadMenu.Append(-1, _("صوت"), audioMenu) trackOptions.Append(downloadId, _("تنزيل"), downloadMenu) trackOptions.Enable(downloadId, can_download) directDownloadItem = trackOptions.Append( -1, _("التنزيل المباشر...\tctrl+d")) directDownloadItem.Enable(can_download) descriptionItem = trackOptions.Append(-1, _("وصف الفيديو\tctrl+shift+d")) copyItem = trackOptions.Append(-1, _("نسخ رابط المقطع\tctrl+l")) browserItem = trackOptions.Append( -1, _("الفتح من خلال متصفح الإنترنت\tctrl+b")) settingsItem = trackOptions.Append(-1, _("الإعدادات.\talt+s")) menuBar.Append(trackOptions, _("خيارات المقطع")) self.SetMenuBar(menuBar) self.Bind(wx.EVT_MENU, self.onVideoDownload, videoItem) self.Bind(wx.EVT_MENU, self.onM4aDownload, m4aItem) self.Bind(wx.EVT_MENU, self.onMp3Download, mp3Item) self.Bind(wx.EVT_MENU, self.onDirect, directDownloadItem) self.Bind(wx.EVT_MENU, self.onDescription, descriptionItem) self.Bind(wx.EVT_MENU, self.onCopy, copyItem) self.Bind(wx.EVT_MENU, self.onBrowser, browserItem) self.Bind(wx.EVT_MENU, lambda event: SettingsDialog(self), settingsItem) self.Bind(wx.EVT_KEY_DOWN, self.onKeyDown) for control in self.GetChildren(): control.Bind(wx.EVT_KEY_DOWN, self.onKeyDown) beginingButton.Bind(wx.EVT_BUTTON, lambda event: self.beginingAction()) rewindButton.Bind(wx.EVT_BUTTON, lambda event: self.rewindAction()) playButton.Bind(wx.EVT_BUTTON, lambda event: self.playAction()) forwardButton.Bind(wx.EVT_BUTTON, lambda event: self.forwardAction()) self.Bind(wx.EVT_CLOSE, lambda event: self.closeAction()) Thread(target=self.extract_description).start()
def reset(self): self.do_reset = False self.media.set_media(self.media.get_media()) if config_get("repeatetracks"): self.media.play()