1
0
mirror of https://github.com/spl0k/supysonic.git synced 2024-11-09 19:52:16 +00:00

Support for eyeD3 version 0.7

This commit is contained in:
Alban 2013-06-07 19:18:24 +02:00
parent 197722c3ed
commit 6160a4990f
2 changed files with 13 additions and 14 deletions

View File

@ -25,7 +25,7 @@ or as a WSGI application (on Apache for instance). But first:
* Python Imaging Library (`apt-get install python-imaging`) * Python Imaging Library (`apt-get install python-imaging`)
* simplejson (`apt-get install python-simplejson`) * simplejson (`apt-get install python-simplejson`)
* [requests](http://docs.python-requests.org/) >= 0.12.1 (`pip install requests`) * [requests](http://docs.python-requests.org/) >= 0.12.1 (`pip install requests`)
* [eyeD3](http://eyed3.nicfit.net/) (`apt-get install python-eyed3`) * [eyeD3](http://eyed3.nicfit.net/) >= 0.7 (`pip install eyed3`)
### Configuration ### Configuration

View File

@ -2,8 +2,7 @@
import os, os.path import os, os.path
import datetime import datetime
import eyeD3 import eyed3.id3, eyed3.mp3
import db import db
class Scanner: class Scanner:
@ -61,18 +60,18 @@ class Scanner:
if not os.path.getmtime(path) > tr.last_modification: if not os.path.getmtime(path) > tr.last_modification:
return return
tag = eyeD3.Tag() tag = eyed3.id3.Tag()
tag.link(path) tag.parse(path)
audio_file = eyeD3.Mp3AudioFile(path) info = eyed3.mp3.Mp3AudioFile(path).info
tr.disc = tag.getDiscNum()[0] or 1 tr.disc = tag.disc_num[0] or 1
tr.number = tag.getTrackNum()[0] or 1 tr.number = tag.track_num[0] or 1
tr.title = tag.getTitle() tr.title = tag.title
tr.year = tag.getYear() tr.year = tag.release_date.year if tag.release_date else None
tr.genre = tag.getGenre().name if tag.getGenre() else None tr.genre = tag.genre.name if tag.genre else None
tr.duration = audio_file.getPlayTime() tr.duration = info.time_secs
tr.album = self.__find_album(tag.getArtist(), tag.getAlbum()) tr.album = self.__find_album(tag.artist, tag.album)
tr.bitrate = audio_file.getBitRate()[1] tr.bitrate = info.bit_rate[1]
tr.last_modification = os.path.getmtime(path) tr.last_modification = os.path.getmtime(path)
def __find_album(self, artist, album): def __find_album(self, artist, album):