Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/internet4000/media-url-parser
Parses a url and returns a provider and id of the media it is pointing to
https://github.com/internet4000/media-url-parser
discogs javascript soundcloud url-parser vimeo youtube
Last synced: about 1 month ago
JSON representation
Parses a url and returns a provider and id of the media it is pointing to
- Host: GitHub
- URL: https://github.com/internet4000/media-url-parser
- Owner: internet4000
- Created: 2018-07-22T16:22:19.000Z (over 6 years ago)
- Default Branch: main
- Last Pushed: 2023-05-19T16:13:31.000Z (over 1 year ago)
- Last Synced: 2024-04-14T06:37:41.252Z (8 months ago)
- Topics: discogs, javascript, soundcloud, url-parser, vimeo, youtube
- Language: JavaScript
- Homepage: https://internet4000.github.io/media-url-parser/
- Size: 109 KB
- Stars: 0
- Watchers: 3
- Forks: 0
- Open Issues: 3
-
Metadata Files:
- Readme: readme.md
Awesome Lists containing this project
README
# media-url-parser
Install with `yarn add media-url-parser` as a [npm package](https://www.npmjs.com/package/media-url-parser).
Or load from a CDN
```html
import mediaUrlParser from 'https://unpkg.com/media-url-parser'
const x = mediaUrlParser('https://www.youtube.com/watch?v=EFh-vtZHjOQ')
console.log(x) // {url: "https://www.youtube.com/watch?v=EFh-vtZHjOQ", provider: "youtube", id: "EFh-vtZHjOQ"}```
Usage:
```javascript
const urlA = 'https://www.youtube.com/watch?v=OkR7UNnQU6c'
const urlB = '192.168.0.1/a/longer/path/podcast.ogg'const resultsA = mediaUrlParser(urlA)
const resultsB = mediaUrlParser(urlB)
```This code will output:
```javascript
// resultsA
{
url: 'https://www.youtube.com/watch?v=OkR7UNnQU6c',
provider: 'youtube',
id: 'OkR7UNnQU6c'
}// resultsB
{
url: 'https://192.168.0.1/a/longer/path/podcast.ogg',
provider: 'file',
id: 'podcast.ogg'
}```
Supported providers are:
- [youtube](https://www.youtube.com)
- file (only remote for now, not local files)
- [discogs](https://www.discogs.com)Possible future providers are:
- [bandcamp](https://bandcamp.com/)
- [musicbrainz](https://musicbrainz.org/)
- [mixcloud](https://www.mixcloud.com/)
- [spotify](https://www.spotify.com/)
- [soundcloud](https://soundcloud.com/)
- [youtube-music](https://music.youtube.com/)Suggestions and PR welcome.