示例#1
0
    def LoadSettings(self):
        """Loads the goddamn stuff from the db."""
        key_list = [
            ('hotkey-play', self.tc_play),
            ('hotkey-stop', self.tc_stop),
            ('hotkey-next', self.tc_next),
            ('hotkey-volume-up', self.tc_volume_up),
            ('hotkey-volume-down', self.tc_volume_down),
            #('hotkey-modifier',self.tc_acc_modifier),
            ('hotkey-previous', self.tc_previous),
            ('hotkey-volume-mute', self.tc_volume_mute),
            ('hotkey-repeat', self.tc_repeat),
            ('hotkey-shuffle', self.tc_shuffle),
            ('acc-play', self.tc_acc_play),
            ('acc-stop', self.tc_acc_stop),
            ('acc-next', self.tc_acc_next),
            ('acc-volume-up', self.tc_acc_volume_up),
            ('acc-volume-down', self.tc_acc_volume_down),
            #('hotkey-modifier',self.tc_acc_modifier),
            ('acc-previous', self.tc_acc_previous),
            ('acc-volume-mute', self.tc_acc_volume_mute),
            ('acc-repeat', self.tc_acc_repeat),
            ('acc-shuffle', self.tc_acc_shuffle),
        ]
        for key_name in key_list:
            y = options.GetSetting(key_name[0], self.FILEDB)
            if y:
                key_name[1].SetValue(y)

        rb = options.GetSetting('hotkey-modifier-type', self.FILEDB)
        if rb:
            self.rb_modifier.SetSelection(int(rb))
        ch = options.GetSetting('hotkey-modifier', self.FILEDB)
        if ch:
            self.ch_modifier.SetSelection(int(ch))
示例#2
0
    def FillSearchListLocal(self, query_results, query):
        # search field, then search
        counter = 0
        # calc how many time to run through the loop, based on 8 items per result
        #times_to_run = divmod(len(query_results), 8)[0]
        #print times_to_run
        self.lc_search.DeleteAllItems()
        for x in query_results:
            if len(x) > 0:
                
                found_exact_match = False                
                # put results that match exactly at the top of the list
                if query.upper() == (x[0] + ' ' + x[1]).upper():
                    found_exact_match = True
                        
                if found_exact_match == True:    
                    #add artist, song, album, path, add at top
                    index = self.lc_search.InsertStringItem(0, '')
                    self.lc_search.SetStringItem(0, 1, x[0])
                    self.lc_search.SetStringItem(0, 2, x[1])
                    self.lc_search.SetStringItem(0, 3, x[2])
                    if options.GetSetting('search-results-drop-id', self.FILEDB) != '1':
                        self.lc_search.SetStringItem(0, 4, x[3])

                else:
                    #add artist, song, album, path
                    index = self.lc_search.InsertStringItem(counter, '')
                    self.lc_search.SetStringItem(counter, 1, x[0])
                    self.lc_search.SetStringItem(counter, 2, x[1])
                    self.lc_search.SetStringItem(counter, 3, x[2])
                    if options.GetSetting('search-results-drop-id', self.FILEDB) != '1':
                        self.lc_search.SetStringItem(counter, 4, x[3])

                counter = counter + 1
        self.ResizeColumns()
示例#3
0
 def OnMyLastWebClick(self, event):
     # open website
     lw = 'http://www.last.fm/user/'
     if len(self.tc_mylast_search_user.GetValue()) > 0:
         address = lw + self.tc_mylast_search_user.GetValue()
     elif options.GetSetting('lastfm-username', self.FILEDB):
         address = lw + options.GetSetting('lastfm-username', self.FILEDB)
     else:
         address = lw
     default_app_open.dopen(address)
示例#4
0
    def FillSearchList(self, event):
        # search field, then search
        counter = 0
        # calc how many time to run through the loop, based on 8 items per result
        #times_to_run = divmod(len(query_results), 8)[0]
        #print times_to_run
        self.lc_search.DeleteAllItems()
        for x in event.data:
            self.parent.SetNetworkStatus('grooveshark', 0)
            if len(x) > 0:
                #print counter
                #split_array = x.split('; ')
                if len(x) > 5:
                    play_url = x['SongID']#split_array[1]
                    # http://listen.grooveshark.com/songWidget.swf?hostname=cowbell.grooveshark.com&songID=13721223&style=metal&p=0

                    # artist
                    index = self.lc_search.InsertStringItem(counter, '')
                    self.lc_search.SetStringItem(counter, 1, x['ArtistName'])
                    # title
                    self.lc_search.SetStringItem(counter, 2, x['SongName'])
                    #album
                    self.lc_search.SetStringItem(counter, 3, x['AlbumName'])
                    if options.GetSetting('search-results-drop-id', self.FILEDB) != '1':
                        #print play_url
                        self.lc_search.SetStringItem(counter, 4, str(play_url))
                    self.lc_search.SetStringItem(counter, 6, x['ArtistID'])
                    
                else:
                    index = self.lc_search.InsertStringItem(counter, '')
                    # title
                    self.lc_search.SetStringItem(counter, 1, 'No Results Found')

                counter = counter + 1
        self.ResizeColumns()
示例#5
0
 def OnMyLastNeighClick(self, event):
     # search for user
     self.user = options.GetSetting(
         'lastfm-username',
         self.FILEDB)  # self.parent.tc_options_username.GetValue()
     if self.user:
         self.MyLastThread('neighbours')
         self.get_type = 'neighbours'
示例#6
0
 def OnMyLastLovedClick(self, event):
     #grab your loved tracks
     self.user = self.tc_mylast_search_user.GetValue()
     if self.user == '':
         self.user = options.GetSetting(
             'lastfm-username',
             self.FILEDB)  # self.parent.tc_options_username.GetValue()
     if self.user:
         self.MyLastThread('loved_songs')
         self.get_type = 'loved_songs'
示例#7
0
 def RegisterHotkeys(self, modc, h1, h2, h3, h4, h5, h6, h7, h8, h9):
     #assign the keys
     the_keys = [h1, h2, h3, h4, h5, h6, h7, h8, h9]
     mod_type = options.GetSetting('hotkey-modifier-type', self.FILEDB)
     if (mod_type == '1'):
         counter = 100
         for x in the_keys:
             try:
                 self.parent.RegisterHotKey(counter, 0, int(x))
             except Exception, expt:
                 print str(Exception) + str(expt)
             counter = counter + 1
示例#8
0
 def LoadOptions(self):
     """ load options from file, populate options tabs """
     for x in OP_ARR:
         setting_value = options.GetSetting(x[0].rsplit('_', 1)[1], self.FILEDB)            
         if setting_value:
             try:
                 xrc.XRCCTRL(self, x[0]).SetValue(setting_value)
             except TypeError:
                 #print xrc.XRCCTRL(self, x[0])
                 if setting_value == 'False':
                     setting_value = '0'
                 if setting_value == 'True':
                     setting_value = '1'
                 xrc.XRCCTRL(self, x[0]).SetValue(int(setting_value))                    
示例#9
0
    def SetBioText(self, bio_text, artist):
        """ sets the biography text """

        # get albumcover for artist/song from last.fm
        bio_text_str = StripTags(bio_text)
        tranny = 'en'
        lang_set = options.GetSetting('language-selected', self.parent.FILEDB)
        if (lang_set != False):  #& (lang != None):
            tranny = wx.Locale(int(lang_set)).GetCanonicalName()[0:2]
        if tranny != 'en':
            try:
                bio_text_str = google_translation.translate(bio_text_str,
                                                            to=tranny)
            except Exception, expt:
                print "biography_tab:" + str(Exception) + str(expt)
示例#10
0
 def OnMyLastMeClick(self, event):
     # search for user
     self.user = options.GetSetting(
         'lastfm-username',
         self.FILEDB)  #self.parent.tc_options_username.GetValue()
     tperiod = self.rx_mylast_period.GetSelection()
     period = PER_TIMES[tperiod]
     page = 1
     if self.user:
         if period == 'recent':
             self.MyLastThread('user')
             self.get_type = 'user'
         else:
             self.MyLastThread('user_top_tracks', page, period)
             self.get_type = 'user_top_tracks'
示例#11
0
    def run(self):
        """ plays a god-damn song """

        #local mp3 playback
        print self.file_name.encode('utf-8')
        self.parent.current_song.status = 'loading'
        while os.path.isfile(self.file_name) != True:
            time.sleep(1)

        get_buffer = options.GetSetting('buffer-size-bytes',
                                        self.parent.FILEDB)
        if get_buffer != False:
            buffer_sz = int(get_buffer)
        else:
            buffer_sz = BUFFER_SIZE
        while os.path.getsize(self.file_name) < buffer_sz:
            time.sleep(2)
            #print os.path.getsize(file_name)
        self.parent.time_count = -1
        self.parent.current_song.status = 'playing'

        card = int(self.output_device)
        rate = 1
        tt = -1
        #dm= muxer.Demuxer( str.split( name, '.' )[ -1 ].lower() )
        dm = muxer.Demuxer('mp3')
        snds = sound.getODevices()
        if card not in range(len(snds)):
            raise 'Cannot play sound to non existent device %d out of %d' % (
                card + 1, len(snds))
        f = open(self.file_name, 'rb')
        self.snd = resampler = dec = None
        s = f.read(32000)
        t = 0
        while (len(s)):
            #print self.local_play_status
            frames = dm.parse(s)
            if frames:
                for fr in frames:
                    # Assume for now only audio streams

                    if dec == None:
                        #print dm.getHeaderInfo(), dm.streams
                        dec = acodec.Decoder(dm.streams[fr[0]])

                    r = dec.decode(fr[1])
                    if r and r.data:
                        if self.snd == None:
                            #print 'Opening sound with %d channels -> %s' % ( r.channels, snds[ card ][ 'name' ] )
                            self.snd = sound.Output(int(r.sample_rate * rate),
                                                    r.channels,
                                                    sound.AFMT_S16_LE, card)
                            #print r.channels
                            if rate < 1 or rate > 1:
                                resampler = sound.Resampler(
                                    (r.sample_rate, r.channels),
                                    (int(r.sample_rate / rate), r.channels))
                                #print 'Sound resampling %d->%d' % ( r.sample_rate, r.sample_rate/rate )

                        data = r.data
                        if resampler:
                            data = resampler.resample(data)
                        if EMULATE:
                            # Calc delay we should wait to emulate snd.play()

                            d = len(data) / float(
                                r.sample_rate * r.channels * 2)
                            time.sleep(d)
                            #if int( t+d )!= int( t ):
                            #    print 'playing: %d sec\r' % ( t+d ),
                            t += d
                        else:
                            self.snd.play(data)
                        #print snd.getPosition()
            if tt > 0:
                if self.snd and self.snd.getPosition() < tt:
                    break

            s = f.read(512)
            if self.local_play_status == False:
                break

        while self.snd.isPlaying():
            time.sleep(0.05)
示例#12
0
    def GetSavedHotkeys(self):
        #grabbed the saved keys from the settings db, or not

        self.FILEDB = system_files.GetDirectories(self).DatabaseLocation()
        # hotkey-modifier, hotkey-previous, hotkey-play, hotkey-next, hotkey-stop
        hotkey_modifier = options.GetSetting('hotkey-modifier', self.FILEDB)
        if hotkey_modifier == '0':
            if os.name == 'nt':
                hotkey_modifier = win32con.MOD_CONTROL
            else:
                hotkey_modifier = wx.MOD_CONTROL
        if hotkey_modifier == '1':
            if os.name == 'nt':
                hotkey_modifier = win32con.MOD_SHIFT
            else:
                hotkey_modifier = wx.MOD_SHIFT
        if hotkey_modifier == '2':
            if os.name == 'nt':
                hotkey_modifier = win32con.MOD_WIN
            else:
                hotkey_modifier = wx.MOD_WIN

        h1 = options.GetSetting('hotkey-previous', self.FILEDB)
        h2 = options.GetSetting('hotkey-play', self.FILEDB)
        h3 = options.GetSetting('hotkey-stop', self.FILEDB)
        h4 = options.GetSetting('hotkey-next', self.FILEDB)
        h5 = options.GetSetting('hotkey-volume-down', self.FILEDB)
        h6 = options.GetSetting('hotkey-volume-up', self.FILEDB)
        h7 = options.GetSetting('hotkey-volume-mute', self.FILEDB)
        h8 = options.GetSetting('hotkey-shuffle', self.FILEDB)
        h9 = options.GetSetting('hotkey-repeat', self.FILEDB)

        if (hotkey_modifier == False) & (h1 == False):
            #use defaults
            if os.name == 'nt':
                modc = win32con.MOD_CONTROL
                h1 = win32con.VK_F1
                h2 = win32con.VK_F2
                h3 = win32con.VK_F3
                h4 = win32con.VK_F4
                h5 = win32con.VK_F5
                h6 = win32con.VK_F6
                h7 = win32con.VK_F7
                h8 = win32con.VK_F9
                h9 = win32con.VK_F10
            else:
                modc = wx.MOD_CONTROL
                h1 = wx.WXK_F1
                h2 = wx.WXK_F2
                h3 = wx.WXK_F3
                h4 = wx.WXK_F4
                h5 = wx.WXK_F5
                h6 = wx.WXK_F6
                h7 = wx.WXK_F7
                h8 = wx.WXK_F9
                h9 = wx.WXK_F10

            self.RegisterHotkeys(str(modc), h1, h2, h3, h4, h5, h6, h7, h8, h9)
        else:
            #use stored values
            self.RegisterHotkeys(hotkey_modifier, h1, h2, h3, h4, h5, h6, h7,
                                 h8, h9)
示例#13
0
    def SetHotkeys(self):
        backID = 701
        playID = 702
        stopID = 703
        forwID = 704
        #saveID = 705
        #loadID = 706
        randID = 707
        reapID = 708
        vlupID = 709
        vldnID = 7010
        #tbupID = 7012
        muteID = 7011
        #tbdnID = 7011
        #ctrldID = 801
        #ctrlrID = 802
        #ctrlbID = 803
        #ctrl9ID = 910
        #ctrl8ID = 911
        #ctrlfID = 804
        #ctrlmID = 805
        #ctrlgID = 806
        #ctrlperiodID = 807

        self.FILEDB = system_files.GetDirectories(self).DatabaseLocation()

        h1 = options.GetSetting('acc-previous', self.FILEDB)
        if h1:
            h1 = int(h1)
        else:
            h1 = wx.WXK_F1

        h2 = options.GetSetting('acc-play', self.FILEDB)
        if h2:
            h2 = int(h2)
        else:
            h2 = wx.WXK_F2

        h3 = options.GetSetting('acc-stop', self.FILEDB)
        if h3:
            h3 = int(h3)
        else:
            h3 = wx.WXK_F3

        h4 = options.GetSetting('acc-next', self.FILEDB)
        if h4:
            h4 = int(h4)
        else:
            h4 = wx.WXK_F4

        h5 = options.GetSetting('acc-volume-down', self.FILEDB)
        if h5:
            h5 = int(h5)
        else:
            h5 = wx.WXK_F5

        h6 = options.GetSetting('acc-volume-up', self.FILEDB)
        if h6:
            h6 = int(h6)
        else:
            h6 = wx.WXK_F6

        h7 = options.GetSetting('acc-volume-mute', self.FILEDB)
        if h7:
            h7 = int(h7)
        else:
            h7 = wx.WXK_F7

        h8 = options.GetSetting('acc-shuffle', self.FILEDB)
        if h8:
            h8 = int(h8)
        else:
            h8 = wx.WXK_F9

        h9 = options.GetSetting('acc-repeat', self.FILEDB)
        if h9:
            h9 = int(h9)
        else:
            h9 = wx.WXK_F10

        #clear acc table
        aTable = wx.NullAcceleratorTable
        self.parent.SetAcceleratorTable(aTable)
        self.parent.album_viewer.SetAcceleratorTable(aTable)

        self.parent.aTable_values = [
            (wx.ACCEL_NORMAL, h1, backID),
            (wx.ACCEL_NORMAL, h2, playID),
            (wx.ACCEL_NORMAL, h3, stopID),
            (wx.ACCEL_NORMAL, h4, forwID),
            (wx.ACCEL_NORMAL, h5, vldnID),
            (wx.ACCEL_NORMAL, h6, vlupID),
            (wx.ACCEL_NORMAL, h7, muteID),
            (wx.ACCEL_NORMAL, h8, randID),
            (wx.ACCEL_NORMAL, h9, reapID),

            #(wx.ACCEL_CTRL, ord('.'), ctrlperiodID)
        ]

        ###self.SetMenuAccel(h1, backID)
        counter = 0
        for menu_item in self.parent.parent.menu_playback.GetMenuItems():
            #print menu_item
            if counter == 9:
                break
            self.SetMenuAccel(menu_item, self.parent.aTable_values[counter][1],
                              self.parent.aTable_values[counter][2])
            counter = counter + 1

        aTable = wx.AcceleratorTable(self.parent.aTable_values)
        #add to main program
        ####self.parent.SetAcceleratorTable(aTable)
        #add to album viewer window too
        self.parent.album_viewer.SetAcceleratorTable(aTable)

        wx.EVT_MENU(self.parent, backID, self.parent.OnBackwardClick)
        wx.EVT_MENU(self.parent, playID, self.parent.OnPlayClick)
        wx.EVT_MENU(self.parent, stopID, self.parent.OnStopClick)
        wx.EVT_MENU(self.parent, forwID, self.parent.OnForwardClick)

        #wx.EVT_MENU(self, saveID, self.OnSavePlaylistClick)
        #wx.EVT_MENU(self, loadID, self.OnLoadPlaylistClick)
        wx.EVT_MENU(self.parent, randID, self.parent.OnRandomClick)
        wx.EVT_MENU(self.parent, reapID, self.parent.OnRepeatClick)

        wx.EVT_MENU(self.parent, vldnID, self.parent.OnVolumeDown)
        wx.EVT_MENU(self.parent, vlupID, self.parent.OnVolumeUp)
        wx.EVT_MENU(self.parent, muteID, self.parent.OnMuteClick)
示例#14
0
 def OnMyLastFriendsClick(self, event):
     # search for user
     self.user = options.GetSetting('lastfm-username', self.FILEDB)
     if self.user:
         self.MyLastThread('friends')
         self.get_type = 'friends'