update lbry.getMediaType function logic

This commit is contained in:
Baltazar Gomez 2018-07-04 17:06:13 -06:00 committed by GitHub
parent 201d78b68a
commit 6eba5f8823
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -110,9 +110,7 @@ Lbry.connect = () => {
};
Lbry.getMediaType = (contentType, fileName) => {
if (contentType) {
return /^[^/]+/.exec(contentType)[0];
} else if (fileName) {
if (fileName) {
const formats = [
[/^.+\.(mp4|m4v|webm|flv|f4v|ogv)$/i, 'video'],
[/^.+\.(mp3|m4a|aac|wav|flac|ogg|opus)$/i, 'audio'],
@ -128,7 +126,9 @@ Lbry.getMediaType = (contentType, fileName) => {
}
}, fileName);
return res === fileName ? 'unknown' : res;
}
} else if (contentType) {
return /^[^/]+/.exec(contentType)[0];
}
return 'unknown';
};