Security News
Fluent Assertions Faces Backlash After Abandoning Open Source Licensing
Fluent Assertions is facing backlash after dropping the Apache license for a commercial model, leaving users blindsided and questioning contributor rights.
js-video-url-parser
Advanced tools
A parser to extract provider, video id, starttime and others from YouTube, Vimeo, ... urls
A javascript parser to extract informations like provider, id, channel, start time from media urls.
npm install
npm run lint
npm run test
npm run build
npm install js-video-url-parser
bower install js-video-url-parser
// All plugins
import urlParser from "js-video-url-parser";
// Choose individual plugins
import urlParser from "js-video-url-parser/lib/base";
import "js-video-url-parser/lib/provider/canalplus";
import "js-video-url-parser/lib/provider/coub";
import "js-video-url-parser/lib/provider/dailymotion";
import "js-video-url-parser/lib/provider/twitch";
import "js-video-url-parser/lib/provider/vimeo";
import "js-video-url-parser/lib/provider/wistia";
import "js-video-url-parser/lib/provider/youku";
import "js-video-url-parser/lib/provider/youtube";
import "js-video-url-parser/lib/provider/teachertube";
Parsing a url will return a videoInfo object with all the information
> urlParser.parse('http://www.youtube.com/watch?v=HRb7B9fPhfA')
{
mediaType: 'video',
id: 'HRb7B9fPhfA',
provider: 'youtube'
}
> urlParser.parse('https://vimeo.com/97276391')
{
mediaType: 'video',
id: '97276391',
provider: 'vimeo'
}
Any url parameters expect for ids will be saved in the params object. Some providers have special parameters for example the start parameter which dictates at how many seconds the video starts. Special parameters can be found in the different descriptions for the providers.
> urlParser.parse('https://www.youtube.com/watch?v=6xLcSTDeB7A&index=25&list=PL46F0A159EC02DF82&t=1m40')
{
provider: 'youtube',
id: 'yQaAGmHNn9s',
list: 'PL46F0A159EC02DF82',
mediaType: 'video',
params: {
start: 100,
index: '25'
}
}
Parsing an incorrect url or trying to create one with an invalid object will return undefined
> urlParser.parse('https://www.youuutube.com/watch?v=97276391')
> urlParser.create({ videoInfo: { provider: 'youtube' })
undefined
The videoInfo objects can be turned back into urls with the .create
function.
The required parameter for this is the videoInfo object itself. Optional ones are
the format of the url and the url parameters that should be added. Each provider
has it's own default format.
> urlParser.create({
videoInfo: {
provider: 'youtube',
id: 'HRb7B9fPhfA',
mediaType: 'video'
},
format: 'long',
params: {
foo: 'bar'
}
})
'https://www.youtube.com/watch?foo=bar&v=HRb7B9fPhfA'
Parsing and creating can also be chained together to clean up an url for example.
If you still want to reuse the generated parameters object you can use the keyword
'internal'
as params.
> urlParser.create({
videoInfo: urlParser.parse('https://youtube.com/watch?foo=bar&v=HRb7B9fPhfA')
})
'https://www.youtube.com/watch?v=HRb7B9fPhfA'
> urlParser.create({
videoInfo: urlParser.parse('https://youtube.com/watch?foo=bar&v=HRb7B9fPhfA'),
params: 'internal'
})
'https://www.youtube.com/watch?foo=bar&v=HRb7B9fPhfA'
Add a new file in the lib/provider/
directory with the template found here and also add it to index.js.
Add some tests in lib/provider/
with the template found
here.
Run npm run test
to create the parser and test your plugin.
FAQs
A parser to extract provider, video id, starttime and others from YouTube, Vimeo, ... urls
We found that js-video-url-parser demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Fluent Assertions is facing backlash after dropping the Apache license for a commercial model, leaving users blindsided and questioning contributor rights.
Research
Security News
Socket researchers uncover the risks of a malicious Python package targeting Discord developers.
Security News
The UK is proposing a bold ban on ransomware payments by public entities to disrupt cybercrime, protect critical services, and lead global cybersecurity efforts.