~mmcg069/totallywired/trunk

« back to all changes in this revision

Viewing changes to totallywired/player/common.py

  • Committer: Matthew McGowan
  • Date: 2013-04-20 08:47:54 UTC
  • Revision ID: matthew.joseph.mcgowan@gmail.com-20130420084754-c3jzh7vz4chb1ai8
small position bubble pointer fixes.

Show diffs side-by-side

added added

removed removed

Lines of Context:
3
3
from totallywired.db.collectors.enums import DbEnums
4
4
from totallywired.utils.db import get_qterm
5
5
from totallywired.utils.misc import tail
 
6
from totallywired.lastfm import Scrobbler
 
7
from totallywired.lastfm.auth import Auth
6
8
 
7
9
 
8
10
SECOND = Gst.SECOND
132
134
            uri = ""
133
135
        else:
134
136
            uri = model.get_document_from_docid(docid).get_data()
135
 
        return Track(uri, docid)
 
137
        return Track(model, uri, docid)
136
138
 
137
139
    @staticmethod
138
140
    def from_uri(model, uri):
139
141
        docid = model.get_docid_from_uri(uri)
140
 
        return Track(uri, docid)
 
142
        return Track(model, uri, docid)
141
143
 
142
 
    def __init__(self, uri, docid):
 
144
    def __init__(self, model, uri, docid):
 
145
        self.model = model
143
146
        self.uri = uri
144
147
        self.docid = int(docid)
145
148
        self.active = True
171
174
            print(("Could not update docid for doc with uri: %s" % self.uri))
172
175
        return self.active
173
176
 
174
 
    def title(self, model):
175
 
        doc = model.get_document_from_docid(self.docid)
 
177
    def title(self):
 
178
        doc = self.model.get_document_from_docid(self.docid)
176
179
        return "%s" % str(doc.get_value(DbEnums.V_TITLE)).decode("utf-8", "ignore")
177
180
 
 
181
    def scrobble(self, timestamp):
 
182
        if not Auth.sk or self.scrobbled or timestamp == 0:
 
183
            return
 
184
        doc = self.model.get_document_from_docid(self.docid)
 
185
        scrobbler = Scrobbler(
 
186
            doc.get_value(DbEnums.V_ARTIST),
 
187
            doc.get_value(DbEnums.V_ALBUM),
 
188
            doc.get_value(DbEnums.V_TITLE),
 
189
            timestamp,
 
190
            Auth.sk,
 
191
        )
 
192
        scrobbler.start()
 
193
        self.scrobbled = True
 
194
        return
 
195
 
178
196
 
179
197
class RadioStationLiveStream(Track):
180
198