~davidc3/onehundredscopes/musicfolder

« back to all changes in this revision

Viewing changes to src/musicfolder.py

  • Committer: David Callé
  • Date: 2011-10-15 18:26:13 UTC
  • Revision ID: davidc@framli.eu-20111015182613-x89xpbczs95bgeg9
Don't mess with encoding and non ID3 tagged files.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
1
#! /usr/bin/python
 
2
# -*- coding: latin-1 -*-
2
3
 
3
4
#    Copyright (c) 2011 David Calle <davidc@framli.eu>
4
5
 
47
48
 
48
49
        def update_results_model(self, search, model):
49
50
                for i in self.musicfolder(search):
50
 
                        title = i[0]
51
 
                        comment = i[1]
 
51
                        print i
 
52
                        title = unicode(i[0], "latin-1")
 
53
                        comment = unicode(i[1], "latin-1")
52
54
                        uri = "file://"+ i[2]
53
55
                        icon_hint = i[3]
54
56
                        model.append (uri, icon_hint, 0,"text/html", title, comment, uri)
57
59
 
58
60
        def searchid3(self, files, search):
59
61
                result = []
60
 
                title = ""
61
 
                artist = ""
62
 
                album = ""
 
62
 
63
63
                for f in files:
 
64
                        title = ""
 
65
                        artist = ""
 
66
                        album = ""
64
67
                        if not os.path.isdir(f):
65
68
                                id3info = ID3(f)
66
69
                                try :
75
78
                                        album = id3info['ALBUM']
76
79
                                except KeyError:
77
80
                                        pass
78
 
                                if title.lower().find(search.lower()) > -1 or artist.lower().find(search.lower()) > -1 or album.lower().find(search.lower()) > -1:
79
 
                                        result.append(self.get_info(f, title, artist, album))
 
81
                                if title.lower().find(search.lower()) > -1 or artist.lower().find(search.lower()) > -1 or album.lower().find(search.lower()) > -1 or f.lower().find(search.lower()) > -1 or search == "":
 
82
                                        if title != "":
 
83
                                                result.append(self.get_info(f, title, artist, album))
80
84
                return result
81
85
 
82
86
        def musicfolder(self, search):
111
115
                if not icon:
112
116
                        icon = "sound"
113
117
                item_list.append(str(title))
114
 
                item_list.append(str(artist))
 
118
                item_list.append(str(artist+"\n"+album))
115
119
                item_list.append(str(item))
116
120
                item_list.append(str(icon))
117
121
                return item_list