Skip to content

Commit

Permalink
moooore
Browse files Browse the repository at this point in the history
  • Loading branch information
Tom Petr committed Feb 2, 2011
1 parent 052fcdc commit 5b189dd
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 3 deletions.
10 changes: 9 additions & 1 deletion muxlist/music/forms.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,9 @@

import mad

import urllib2
from BeautifulSoup import BeautifulSoup

AUDIO_MIMETYPES = ('audio/mp3', 'application/mp3', 'audio/mpeg3')

class SliceUploadForm(forms.Form):
Expand Down Expand Up @@ -73,7 +76,12 @@ def save(self, user):
artist = None

if album_name != '':
album = Album.objects.get_or_create(artist=artist, name=album_name)[0]
album, created = Album.objects.get_or_create(artist=artist, name=album_name)
if created:
r = urllib2.urlopen('http://ws.audioscrobbler.com/2.0/?method=album.getinfo&api_key=b25b959554ed76058ac220b7b2e0a026&artist=%s&album=%s')
bs = BeautifulSoup(r.read())
album.image = bs.image[1]
album.save()
else:
album = None

Expand Down
2 changes: 2 additions & 0 deletions muxlist/music/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@ class Album(models.Model):
artist = models.ForeignKey(Artist, related_name='albums')
year = models.PositiveSmallIntegerField(blank=True, null=True)

image = models.URLField(max_length=128, blank=True, null=True)

created_on = models.DateTimeField(auto_now_add=True)
last_updated = models.DateTimeField(auto_now=True, auto_now_add=True)

Expand Down
4 changes: 2 additions & 2 deletions templates/mix/group.html
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@
$('<li><b>' + data.user + '</b> is playing <b>' + data.artist + ' - ' + data.title + '</b></li>').appendTo('#stream');
var jp = $('#jplayer');
jp.jPlayer('stop');
jp.jPlayer('setFile', data.url);
jp.jPlayer('setMedia',{mp3: data.url});
jp.jPlayer('load');
if ('time' in data) {
console.log("time:", data.time)
Expand Down Expand Up @@ -112,7 +112,7 @@
}

$('#jplayer').jPlayer({
ended: function (event) { alert('ended'); },
ended: song_ended,
swfPath: '/static/',
solution: $.browser.webkit ? 'flash, html' : 'html, flash',
supplied: 'mp3',
Expand Down

0 comments on commit 5b189dd

Please sign in to comment.