This repository has been archived by the owner on Jun 3, 2020. It is now read-only.
-
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
5 changed files
with
437 additions
and
33 deletions.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -6,5 +6,4 @@ install: | |
script: | ||
- yarn run lint | ||
- yarn build | ||
|
||
|
||
- yarn run test |
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
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,26 +1,66 @@ | ||
// | ||
// Example streaming audio track from S3 buckets into music-metadata parser | ||
// | ||
|
||
const { MusicMetadataS3Client } = require('../lib'); | ||
const {MMS3Client} = require('../lib'); | ||
const S3 = require('aws-sdk/clients/s3'); | ||
const {assert} = require('chai'); | ||
|
||
describe('Parse audio files from AWS S3 cloud', function() { | ||
|
||
this.timeout(20000); | ||
|
||
describe('Transfer mode: chunked', () => { | ||
|
||
it('explicitly set', async () => { | ||
|
||
const s3 = new S3(); | ||
const mmS3client = new MMS3Client(s3); // Pass s3 client to music-metadata-s3-client | ||
|
||
(async () => { | ||
const metadata = await mmS3client.parseS3Object({ | ||
Bucket: 'music-metadata', | ||
Key: 'Various Artists - 2008 - netBloc Vol 13 (color in a world of monochrome) {BSCOMP0013} [MP3-V0]/01 - Nils Hoffmann - Sweet Man Like Me.mp3' | ||
}, { | ||
disableChunked: false | ||
} | ||
); | ||
const {format} = metadata; | ||
assert.equal(format.container, 'MPEG', 'format.container'); | ||
assert.equal(format.sampleRate, 44100, 'format.sampleRate'); | ||
assert.deepEqual(format.tagTypes, ['ID3v2.4'], 'format.tagTypes'); | ||
}); | ||
|
||
const s3 = new S3(); | ||
const mmS3client = new MusicMetadataS3Client(s3); // Pass s3 client to music-metadata-s3-client | ||
it('default options', async () => { | ||
|
||
console.log('Parsing...'); | ||
try { | ||
const data = await mmS3client.parseS3Object({ | ||
const s3 = new S3(); | ||
const mmS3client = new MMS3Client(s3); // Pass s3 client to music-metadata-s3-client | ||
|
||
const metadata = await mmS3client.parseS3Object({ | ||
Bucket: 'music-metadata', | ||
Key: 'Various Artists - 2008 - netBloc Vol 13 (color in a world of monochrome) {BSCOMP0013} [MP3-V0]/01 - Nils Hoffmann - Sweet Man Like Me.mp3' | ||
} | ||
); | ||
const {format} = metadata; | ||
assert.equal(format.container, 'MPEG', 'format.container'); | ||
assert.equal(format.sampleRate, 44100, 'format.sampleRate'); | ||
assert.deepEqual(format.tagTypes, ['ID3v2.4'], 'format.tagTypes'); | ||
}); | ||
|
||
}); | ||
|
||
it('Transfer mode: conventional', async () => { | ||
|
||
const s3 = new S3(); | ||
const mmS3client = new MMS3Client(s3); // Pass s3 client to music-metadata-s3-client | ||
|
||
const metadata = await mmS3client.parseS3Object({ | ||
Bucket: 'music-metadata', | ||
Key: 'Various Artists - 2008 - netBloc Vol 13 (color in a world of monochrome) {BSCOMP0013} [MP3-V0]/01 - Nils Hoffmann - Sweet Man Like Me.mp3' | ||
}, { | ||
disableChunked: false // If set to true, fall back to conventional stream | ||
disableChunked: true | ||
} | ||
); | ||
console.log('metadata:', data); | ||
} catch (e) { | ||
console.error(`Oops: ${e.message}`); | ||
} | ||
})(); | ||
const {format} = metadata; | ||
assert.equal(format.container, 'MPEG', 'format.container'); | ||
assert.equal(format.sampleRate, 44100, 'format.sampleRate'); | ||
assert.deepEqual(format.tagTypes, ['ID3v2.4'], 'format.tagTypes'); | ||
}); | ||
|
||
}) | ||
; |
Oops, something went wrong.