Comparing version 1.0.4 to 1.0.5
@@ -12,3 +12,2 @@ { | ||
"main": "src/index.js", | ||
"browser": "browser/index.js", | ||
"homepage": "https://github.com/kimcore/simpleYT", | ||
@@ -21,3 +20,3 @@ "bugs": { | ||
"description": "Simple youtube search library without need of an api key", | ||
"version": "1.0.4", | ||
"version": "1.0.5", | ||
"dependencies": { | ||
@@ -24,0 +23,0 @@ "miniget": "^2.0.1" |
@@ -11,2 +11,7 @@ # simpleYT | ||
## Usage | ||
If you intend to use this library in a browser, use jsDelivr: | ||
```html | ||
<script src="https://cdn.jsdelivr.net/gh/kimcore/simpleyt/browser/simpleyt.js"></script> | ||
``` | ||
Or in Node.JS: | ||
```js | ||
@@ -16,6 +21,8 @@ const simpleYT = require('simpleyt') | ||
simpleYT(query, { | ||
filter: 'video', // Filter only videos | ||
filter: 'video', | ||
// Available filters: video, playlist | ||
localAddress: '2001:470:1234:5678::a', | ||
family: 6 | ||
// Other parameters are passed to miniget | ||
// Other parameters are passed to miniget (https) | ||
}).then(console.log) | ||
@@ -27,16 +34,29 @@ ``` | ||
{ | ||
type: 'video', | ||
identifier: 'iMTblJbmam4', | ||
uri: 'https://www.youtube.com/watch?v=iMTblJbmam4', | ||
title: "[ENG/CC][4K] JUSTHIS(저스디스)의 킬링벌스를 라이브로! I IndiGO, Diablo, Gone, DF KV Freestyle, That Ain't Real 등", | ||
author: { | ||
name: 'dingo freestyle', | ||
profile: 'https://yt3.ggpht.com/a-/AOh14GiiLlR1duwARrL4IWqmVVZcuH-mdVnQLunfTw=s68-c-k-c0x00ffffff-no-rj-mo', | ||
uri: 'https://www.youtube.com/user/nunnaamo' | ||
type: 'video', | ||
identifier: 'nPuHl_Hl2xI', | ||
uri: 'https://www.youtube.com/watch?v=nPuHl_Hl2xI', | ||
title: '12 HOURS LONG RELAX MUSIC - Relaxation, Meditation, Sleep and Spa Music by RELAX CHANNEL ☯188', | ||
author: { | ||
name: 'RELAX CHANNEL', | ||
profile: 'https://yt3.ggpht.com/a-/AOh14GiqEKfh0k2lWpQVJU18CYULkb9XL2g8i7Jd2A=s68-c-k-c0x00ffffff-no-rj-mo', | ||
uri: 'https://www.youtube.com/user/relaxvideoschannel' | ||
}, | ||
length: { ms: 42888000, sec: 42888 }, | ||
isStream: false, | ||
thumbnails: [ [Object], [Object], [Object], [Object] ] | ||
}, | ||
length: { ms: 794000, sec: 794 }, | ||
isStream: false, | ||
thumbnails: [ [Object], [Object], [Object], [Object] ] | ||
}, | ||
... | ||
... | ||
{ | ||
type: 'playlist', | ||
identifier: 'PLAhZL8hvPmBGp4RpHNHThexBegcjYxcC-', | ||
uri: 'https://www.youtube.com/playlist?list=PLAhZL8hvPmBGp4RpHNHThexBegcjYxcC-', | ||
title: 'The very long music playlist', | ||
author: { | ||
name: 'Humphreys Samuel', | ||
uri: 'https://www.youtube.com/channel/UC0fAfWQXyTVN-R7NP0BWwGA' | ||
}, | ||
count: 1000, | ||
thumbnails: [ [Object], [Object], [Object], [Object], [Object] ] | ||
}, | ||
... | ||
] | ||
@@ -43,0 +63,0 @@ ``` |
@@ -5,3 +5,3 @@ const miniget = require('miniget') | ||
const response = await miniget( | ||
'https://www.youtube.com/results?search_query=' + encodeURIComponent(query), options | ||
'https://www.youtube.com/results?search_query=' + encodeURIComponent(query), {...options, ...{filter: undefined}} | ||
).text() | ||
@@ -15,3 +15,5 @@ const line = response.match(/window\["ytInitialData"]\s*=\s*(.*);+\n/)[0] | ||
const type = Object.keys(video)[0].replace('Renderer', '') | ||
return ['video', 'playlist'].includes(type) | ||
if (options.filter === 'video') return type === 'video' | ||
else if (options.filter === 'playlist') return type === 'playlist' | ||
else return ['video', 'playlist'].includes(type) | ||
}).map(video => { | ||
@@ -63,7 +65,3 @@ const type = Object.keys(video)[0].replace('Renderer', '') | ||
} | ||
}).filter(it => { | ||
if (options.filter === 'video') return it.type === 'video' | ||
else if (options.filter === 'playlist') return it.type === 'playlist' | ||
else return true | ||
}) | ||
} |
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
Network access
Supply chain riskThis module accesses the network.
Found 2 instances in 1 package
Dynamic require
Supply chain riskDynamic require can indicate the package is performing dangerous or unsafe dynamic code execution.
Found 1 instance in 1 package
Environment variable access
Supply chain riskPackage accesses environment variables, which may be a sign of credential stuffing or data theft.
Found 1 instance in 1 package
11
66
1
1
18889
67