~oly/rhythmboxwebremote/trunk

« back to all changes in this revision

Viewing changes to WebRemote.py

  • Committer: Oliver Marks
  • Date: 2012-05-20 15:45:35 UTC
  • Revision ID: oly@digitaloctave.com-20120520154535-m7m0n41g6p4a6lus
multi user search implemented needs testing, but looking good so far

Show diffs side-by-side

added added

removed removed

Lines of Context:
34
34
import cStringIO
35
35
import gettext
36
36
import time
 
37
import urllib
37
38
 
38
39
#pull in custom ipc library
39
40
sys.path.append(os.path.dirname(__file__))
127
128
                                
128
129
                        if cmd=='play':
129
130
                                self.play()             
130
 
                                                
131
 
 
 
131
                                
 
132
                        if cmd=='reset':
 
133
                                self.debug('clear_history')
 
134
                                self.debug(self.command[1])
 
135
                                self.clear_history(self.command[1])
132
136
 
133
137
                        #parameter commands
134
138
                        result=self.command[2].strip('\n').split('/',1)
135
139
                        cmd=result[0]
136
140
                        self.debug(result)
137
141
                        if len(result)==2:
138
 
                                if cmd=='reset':
139
 
                                        self.clear_history(result[1])
140
142
                                if cmd=='volume':
141
143
                                        fp=open(self.ipc.log,'a')
142
144
                                        fp.write('\wipc read'+str(cmd)+' from '+self.ipc.readfile+'\n')
163
165
                return True
164
166
 
165
167
        #clear out history updates because we got a recieved response
166
 
        def clear_history(self,uid):
167
 
                self.history['search']=[]
168
 
                if uid in self.history['search']:
169
 
                        del(self.history['search'][uid])
 
168
        def clear_history(self,uid=None):
 
169
                #self.history['search']=[]
 
170
                count=0
 
171
                for item in self.history['search']:
 
172
                        if uid==item:
 
173
                                del(self.history['search'][count])
 
174
                        count+=1
 
175
                self.update=True
170
176
        
171
177
        def queue_track(self,uri):
172
178
                self.update=True
237
243
 
238
244
        #may be worth saving the files with the search string as filename that way we could detect if the search has recently been done and save some load
239
245
        def find_tracks(self,session,search_string,field=None):
240
 
                #################### Print all artists in the library ####################
241
 
        tracks = [] # unique keys, no duplicates
242
 
        self.debug(search_string)
243
 
        #filename_page=filename+'_'+str(pagenum)+'.htm'
244
 
        search_htm = open(self.path+'/generate/search/search.htm','w')
 
246
                #decode url string so we can search properly
 
247
                search_string=urllib.unquote(search_string)
 
248
 
 
249
 
 
250
        search_htm = open(self.path+'/generate/search/'+str(session)+'.htm','w')
245
251
        web.table.start('Search Results',('N','Track','Artist','Album'),id="searchlist")
246
 
        #search_htm.write('<table id="searchlist"><tbody>')
247
252
        matches=0
248
 
        
 
253
        #loop over results and save output
249
254
        for row in self.object.props.library_source.props.base_query_model:
250
255
            entry = row[0]
251
256
            fields={}