-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add lastfm scrobble abilities, in test mode
- Loading branch information
Showing
5 changed files
with
62 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,5 @@ | ||
# pyrana.plugins module | ||
from notify import Notify | ||
from pidginstatus import PidginStatus | ||
from lastfmscrobbler import LastFmScrobbler | ||
from metadatareader import MetadataReader |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
import pylast | ||
|
||
from feather import Plugin | ||
|
||
class LastFmScrobbler(Plugin): | ||
listeners = set(['songstart', 'songend', 'metadataread']) | ||
messengers = set() | ||
|
||
API_KEY = 'fd0c0272688b807631f12d91ce6d3afb' | ||
SECRET = 'fb1f796931a24717dd2ac8e1f4789912' | ||
CLIENT_ID = 'tst' | ||
CLIENT_VERSION = 1.0 | ||
|
||
def __init__(self, username, password) : | ||
super(LastFmScrobbler, self).__init__() | ||
self.username = username | ||
self.password_hash = pylast.md5(password) | ||
self.network = pylast.LastFMNetwork( | ||
api_key = self.API_KEY, | ||
api_secret = self.SECRET, | ||
username = self.username, | ||
password_hash = self.password_hash | ||
) | ||
|
||
|
||
def songstart(self, payload=None): | ||
from time import time | ||
self.started_at = int(time()) | ||
|
||
def metadataread(self, payload): | ||
self.metadata = payload | ||
|
||
def songend(self, payload=None): | ||
self.network.scrobble( | ||
self.metadata['artist'][0], | ||
self.metadata['title'][0], | ||
self.started_at, | ||
self.metadata['album'][0] | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
from feather import Plugin | ||
|
||
class MetadataReader(Plugin): | ||
listeners = set(['songstart']) | ||
messengers = set(['metadataread']) | ||
|
||
def songstart(self, payload): | ||
import mutagen | ||
info = mutagen.File(payload, easy=True) | ||
self.send('metadataread', dict(info)) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters