-
Notifications
You must be signed in to change notification settings - Fork 0
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Some changes to track parsing #1
base: master
Are you sure you want to change the base?
Conversation
Tracks may have tracknumber and discnumber formatted as "x/y" where: - x is the current track/disc number - y is the total number of tracks/discs For example this is the case for tracks downloaded from Google Play Music. Now `parse_resource` function considers this particular case, otherwise will stick with the normal behaviour
Since date tag inside tracks is a string, it can have any possible value. Previous code tried to parse date as an integer, but for example strings such as "2017-11-12 14:34" can't be cast to an integer value. As a workaround, date is now parsed as is, and the application client should handle its value as it sees fit
tersicore/formats.py
Outdated
track_number = None | ||
if total_tracks == "0": | ||
total_tracks = None | ||
if type(track_number) is str and len(track_number) == 1: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Use rjust
to pad here, like: track_number.rjust(2, "0")
.
tersicore/formats.py
Outdated
if disc_number == "0": | ||
disc_number = None | ||
if total_discs == "0": | ||
total_discs = None |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why track_number
is padded and disc_number
is not?
tersicore/formats.py
Outdated
@@ -101,8 +101,7 @@ def parse_resource(res, path): | |||
res.track.isrc = parse('isrc', media.tags) | |||
|
|||
raw_date = parse('date', media.tags) | |||
if raw_date not in [None, '']: | |||
res.track.date = date(int(raw_date), 1, 1) | |||
res.track.date = raw_date |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we just do some better parsing? Check out dateutil.parser.parse.
Hi, I've reviewed some of your commits, Thanks! |
For explanation about commits, check the full commit message