Skip to content

Commit

Permalink
add length and track for song
Browse files Browse the repository at this point in the history
  • Loading branch information
badetitou committed Jun 13, 2019
1 parent 8d9d480 commit bb70657
Show file tree
Hide file tree
Showing 3 changed files with 45 additions and 8 deletions.
17 changes: 13 additions & 4 deletions src/EMM-Importer/EMMLibraryImporter.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -14,19 +14,23 @@ EMMLibraryImporter >> artistsDelimiter [

{ #category : #'as yet unclassified' }
EMMLibraryImporter >> createSongFromFile: file [
| song artists id3parser folder |
| song artists id3parser folder |
song := EMMMSong new.
song name: file basenameWithoutExtension.
"Try to parse ID3 metadata for MP3 files"
id3parser := ID3Parser on: (File named: file originalString) readStream.
artists := (self ensureArtists: id3parser id3v2Tag artist).
artists do: [:artist | artist addSong: song].
artists := self ensureArtists: id3parser id3v2Tag artist.
artists do: [ :artist | artist addSong: song ].
song artists addAll: artists.
model songs add: song.
folder := (self ensureFolderFromFileReference: file parent).
folder := self ensureFolderFromFileReference: file parent.
folder addSong: song.
song folder: folder.
song title: id3parser id3v2Tag title.
song track: id3parser id3v2Tag track.
[ song length: id3parser id3v2Tag length ]
on: FrameNotFoundError
do: [ song length: self notDefineTextValue ].
song path: file.
^ song
]
Expand Down Expand Up @@ -73,3 +77,8 @@ EMMLibraryImporter >> importFromFolder: aFolder inAModel: anEMMModel [
ifTrue: [
self createSongFromFile: file ] ] ]
]

{ #category : #'as yet unclassified' }
EMMLibraryImporter >> notDefineTextValue [
^ 'NotDef'
]
12 changes: 9 additions & 3 deletions src/EMM-WebApplication/EMMListModule.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,10 @@ EMMListModule >> renderContentOn: html [
attributeAt: 'width' put: '100%';
with: [ html
tableHead: [ html
tableRow: [ html mdlTableHeading
tableRow: [
html mdlTableHeading
with: ''.
html mdlTableHeading
nonNumerical;
with: 'Title'.
html mdlTableHeading
Expand All @@ -46,13 +49,16 @@ EMMListModule >> renderContentOn: html [
tableBody: [ datas
do: [ :song |
html
tableRow: [ html mdlTableCell
tableRow: [
html mdlTableCell
with: song track.
html mdlTableCell
nonNumerical;
with: song title.
html mdlTableCell
nonNumerical;
with: song artists asOrderedCollection first name.
html mdlTableCell with: 'le'.
html mdlTableCell with: song length.
html mdlTableCell
nonNumerical;
with: [ html mdlAnchorButton
Expand Down
24 changes: 23 additions & 1 deletion src/EMM/EMMMSong.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,9 @@ Class {
'name',
'artists',
'path',
'title'
'title',
'track',
'length'
],
#category : #EMM
}
Expand Down Expand Up @@ -37,6 +39,16 @@ EMMMSong >> initialize [
artists := Set new
]

{ #category : #accessing }
EMMMSong >> length [
^ length
]

{ #category : #accessing }
EMMMSong >> length: anObject [
length := anObject
]

{ #category : #accessing }
EMMMSong >> name [
^ name
Expand Down Expand Up @@ -71,3 +83,13 @@ EMMMSong >> title [
EMMMSong >> title: anObject [
title := anObject
]

{ #category : #accessing }
EMMMSong >> track [
^ track
]

{ #category : #accessing }
EMMMSong >> track: anObject [
track := anObject
]

0 comments on commit bb70657

Please sign in to comment.