def on_info(self, event): description = _("hometape is a tool for downloading music\nvideos from tape.tv.") licence = ( _("hometape is licensed under the MIT license for free software.") + """ Copyright (c) 2010 Kevin Chabowski Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHE- THER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE""" ) info = wx.AboutDialogInfo() info.SetIcon(wx.Icon(os.path.join(tools.progdir(), "hometape_slogan.png"), wx.BITMAP_TYPE_PNG)) info.SetName("hometape") info.SetVersion("0.3.8") info.SetDescription(description) info.SetCopyright("(C) 2010 Kevin Chabowski") info.SetLicence(licence) info.AddDeveloper("Kevin Chabowski") wx.AboutBox(info)
def make_default(): config = {} if os.name == 'nt': for appname in ['rtmpdump','ffmpeg']: try: config[appname+'_path'] = tools.findapp(appname+'.exe', [tools.progdir()+'\\tooldir\\%s\\bin'%appname]) except tools.NotFoundError: config[appname+'_path'] = '' config['temp_dir'] = os.environ['TEMP'] else: # posix for appname in ['rtmpdump','ffmpeg']: try: config[appname+'_path'] = tools.findapp(appname) except tools.NotFoundError: config[appname+'_path'] = '' config['temp_dir'] = '/tmp' return config
def __init__(self): # Load our configuration self.config = config.read_conf() self.lastdir = os.getcwd() self.dldr_instances = [] self.results = [] # Force User to input a valid config if not (self.config["temp_dir"] and self.config["rtmpdump_path"] and self.config["ffmpeg_path"]): conf_dlg = config.ConfDlg(self.config) if conf_dlg.ShowModal() == wx.ID_OK: self.config = conf_dlg.getconf() conf_dlg.Destroy() else: conf_dlg.Destroy() fuckedup_dlg = wx.MessageDialog( None, _("hometape can not work without a valid configuration."), _("Exiting"), wx.OK | wx.ICON_ERROR ) fuckedup_dlg.ShowModal() fuckedup_dlg.Destroy() sys.exit() # All the GUI stuff wx.Frame.__init__(self, None, title="hometape") menubar = wx.MenuBar() m_file = wx.Menu() m_quit = wx.MenuItem(m_file, wx.ID_EXIT, _("&Exit")) m_file.AppendItem(m_quit) m_edit = wx.Menu() m_preferences = wx.MenuItem(m_edit, wx.ID_PREFERENCES, _("&Preferences")) m_edit.AppendItem(m_preferences) m_help = wx.Menu() m_info = wx.MenuItem(m_help, wx.ID_ABOUT, _("&About")) m_help.AppendItem(m_info) menubar.Append(m_file, _("&File")) menubar.Append(m_edit, _("&Edit")) menubar.Append(m_help, _("&Help")) self.SetMenuBar(menubar) self.mainpanel = wx.Panel(self, -1) vbox = wx.BoxSizer(wx.VERTICAL) vbox.Add((-1, 2)) hbox1 = wx.BoxSizer(wx.HORIZONTAL) grid = wx.FlexGridSizer(2, 2, 5, 5) search_label = wx.StaticText(self.mainpanel, label=_("Search:")) self.search_box = wx.TextCtrl(self.mainpanel, style=wx.TE_PROCESS_ENTER) search_by_label = wx.StaticText(self.mainpanel, label=_("Search by:")) search_by_choices = [_("Artist + Title"), _("Artist"), _("Artist (exactly)"), _("Title"), _("Title (exact)")] if os.name == "nt": self.search_by_cb = wx.ComboBox( self.mainpanel, choices=search_by_choices, value=search_by_choices[0], style=wx.CB_READONLY | wx.CB_DROPDOWN, ) else: self.search_by_cb = wx.Choice(self.mainpanel, choices=search_by_choices) grid.AddMany( [ (search_label, 0, wx.ALIGN_CENTER_VERTICAL), (self.search_box, 1, wx.EXPAND), (search_by_label, 0, wx.ALIGN_CENTER_VERTICAL), (self.search_by_cb, 1, wx.EXPAND), ] ) grid.AddGrowableCol(1, 1) hbox1.Add(grid, 1, wx.EXPAND, 0) search_btn = wx.Button(self.mainpanel, id=wx.ID_FIND, label=_("Find")) hbox1.Add(search_btn, 0, wx.EXPAND | wx.LEFT, 5) vbox.Add(hbox1, 0, wx.LEFT | wx.RIGHT | wx.BOTTOM | wx.EXPAND, 2) hline = wx.StaticLine(self.mainpanel, style=wx.LI_HORIZONTAL) vbox.Add(hline, 0, wx.ALL | wx.EXPAND, 5) results_cap = wx.StaticText(self.mainpanel, label=_("Search results:")) vbox.Add(results_cap, 0, wx.ALL | wx.EXPAND, 2) self.result_list = wx.ListBox(self.mainpanel, style=wx.LB_SINGLE) self.result_list.SetMinSize((200, 200)) vbox.Add(self.result_list, 1, wx.LEFT | wx.RIGHT | wx.EXPAND, 2) hbox2 = wx.BoxSizer(wx.HORIZONTAL) self.dl_flv = wx.Button(self.mainpanel, label=_("Download FLV Video")) self.dl_mp3 = wx.Button(self.mainpanel, label=_("Download MP3 Audio")) self.dl_flv.Disable() self.dl_mp3.Disable() hbox2.Add(self.dl_flv, 1, wx.RIGHT | wx.EXPAND, 5) hbox2.Add(self.dl_mp3, 1, wx.EXPAND, 0) vbox.Add(hbox2, 0, wx.EXPAND | wx.ALL, 2) self.mainpanel.SetSizer(vbox) vbox.Fit(self) self.SetMinSize(self.GetSize()) try: self.SetSize(self.config["last_size"]) except KeyError: pass self.SetIcon(wx.Icon(os.path.join(tools.progdir(), "wm_icon.png"), wx.BITMAP_TYPE_PNG)) # Events self.Bind(wx.EVT_MENU, self.on_info, id=m_info.GetId()) self.Bind(wx.EVT_MENU, self.on_prefs, id=m_preferences.GetId()) self.Bind(wx.EVT_MENU, self.on_close, id=m_quit.GetId()) self.Bind(wx.EVT_CLOSE, self.on_close) self.Bind(wx.EVT_BUTTON, self.on_search, id=search_btn.GetId()) self.Bind(wx.EVT_TEXT_ENTER, self.on_search, id=self.search_box.GetId()) self.Bind(wx.EVT_LISTBOX, self.on_select, id=self.result_list.GetId()) self.Bind(wx.EVT_BUTTON, self.on_dl_flv, id=self.dl_flv.GetId()) self.Bind(wx.EVT_BUTTON, self.on_dl_mp3, id=self.dl_mp3.GetId())
import os, sys import gettext, locale import tools if __name__ == "__main__": if os.name == "nt": # windows hack for locale setting lang = os.getenv("LANG") if lang is None: default_lang, default_enc = locale.getdefaultlocale() if default_lang: lang = default_lang if lang: os.environ["LANG"] = lang locale.setlocale(locale.LC_ALL, "") translator = gettext.translation("hometape", os.path.join(tools.progdir(), "locale"), fallback=True) translator.install(True) import config, tapetv from downloader import Downloader class HometapeFrame(wx.Frame): def __init__(self): # Load our configuration self.config = config.read_conf() self.lastdir = os.getcwd() self.dldr_instances = [] self.results = []