Skip to content
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,4 @@ Playback-win32.zip
Playback.app
Playback.app.zip
.DS_Store
.idea
6 changes: 6 additions & 0 deletions playlist.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ var concat = require('concat-stream')

var noop = function () {}

var allowedExts = ["mpg", "mkv", "mp4", "mp3", "vtt", "srt"]

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please use ' instead of "


module.exports = function () {
var that = new events.EventEmitter()

Expand Down Expand Up @@ -141,6 +143,10 @@ module.exports = function () {

file.length = st.size
file.name = path.basename(link)
var filenameArr = file.name.split(".")
file.extension = filenameArr[filenameArr.length-1].toLowerCase()

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You can do file.name.split('.').pop() for the last one

if (allowedExts.indexOf(file.extension) == -1) return cb("File format not supported")

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please use the strict equality check, === instead of ==


file.createReadStream = function (opts) {
return fs.createReadStream(link, opts)
}
Expand Down