youtube.ts
Advanced tools
Comparing version 0.2.4 to 0.2.5
@@ -19,17 +19,17 @@ import axios from "axios" | ||
if (resolvable.includes("channel")) { | ||
id = String(resolvable.match(/(?<=channel\/)(.*?)(?=(?:\?|\/|$))/)[0]) | ||
id = String(resolvable.match(/(channel\/)(.*?)(?=(?:\?|\/|$))/)[0].replace("channel/", "")) | ||
} else if (resolvable.includes("c/")) { | ||
const username = String(resolvable.match(/(?<=c\/)(.*?)(?=(?:\?|\/|$))/)[0]) | ||
const username = String(resolvable.match(/(c\/)(.*?)(?=(?:\?|\/|$))/)[0].replace("c/", "")) | ||
id = await this.api.part("search", "id", {q: username, type: "channel"}).then((r) => r.items[0] ? r.items[0].id.channelId : null) | ||
} else if (resolvable.includes("user/")) { | ||
const username = String(resolvable.match(/(?<=user\/)(.*?)(?=(?:\?|\/|$))/)[0]) | ||
const username = String(resolvable.match(/(user\/)(.*?)(?=(?:\?|\/|$))/)[0].replace("user/", "")) | ||
id = await this.api.part("channels", "id", {forUsername: username}).then((r) => r.items[0] ? r.items[0].id : null) | ||
} else if (resolvable.includes("watch?v=")) { | ||
id = String(resolvable.match(/(?<=watch\?v=)(.*?)(?=(?:&|$))/)[0]) | ||
id = String(resolvable.match(/(watch\?v=)(.*?)(?=(?:&|$))/)[0].replace("watch?v=", "")) | ||
} else if (resolvable.includes("youtu.be")) { | ||
id = String(resolvable.match(/(?<=youtu.be\/)(.*?)(?=(?:\?|$))/)[0]) | ||
id = String(resolvable.match(/(youtu.be\/)(.*?)(?=(?:\?|$))/)[0].replace("youtu.be/", "")) | ||
} else if (resolvable.includes("playlist?list=")) { | ||
id = String(resolvable.match(/(?<=playlist\?list=)(.*?)(?=(?:\?|$))/)[0]) | ||
id = String(resolvable.match(/(playlist\?list=)(.*?)(?=(?:\?|$))/)[0].replace("playlist?list=", "")) | ||
} else { | ||
const query = String(resolvable.match(/(?<=youtube.com\/)(.*?)(?=(?:\?|$))/)[0]) | ||
const query = String(resolvable.match(/(youtube.com\/)(.*?)(?=(?:\?|$))/)[0].replace("youtube.com/", "")) | ||
id = await this.api.part("search", "id", {q: query, type: "channel"}).then((r) => r.items[0] ? r.items[0].id.channelId : null) | ||
@@ -36,0 +36,0 @@ } |
{ | ||
"name": "youtube.ts", | ||
"version": "0.2.4", | ||
"version": "0.2.5", | ||
"description": "Wrapper for the YouTube API with typings.", | ||
@@ -35,9 +35,9 @@ "main": "dist/youtube.js", | ||
"mocha": "^6.2.2", | ||
"typescript": "^3.6.4" | ||
"typescript": "^3.6.4", | ||
"ts-mocha": "^8.0.0" | ||
}, | ||
"dependencies": { | ||
"axios": "^0.19.0", | ||
"tsc": "^2.0.3", | ||
"ytdl-core": "^4.9.1" | ||
} | ||
} |
@@ -7,3 +7,3 @@ import {assert} from "chai" | ||
it("should get a video", async function() { | ||
const response = await youtube.videos.get("https://www.youtube.com/watch?v=LT0gIN9agrM") | ||
const response = await youtube.videos.get("https://www.youtube.com/watch?v=ufXPPpeFJ6E") | ||
assert(response.hasOwnProperty("contentDetails")) | ||
@@ -18,5 +18,5 @@ }) | ||
it("should get all comments on a video", async function() { | ||
const response = await youtube.videos.comments("https://www.youtube.com/watch?v=-BW7kUAPZiA&t=47s") | ||
const response = await youtube.videos.comments("https://www.youtube.com/watch?v=ufXPPpeFJ6E") | ||
assert(response.hasOwnProperty("items")) | ||
}) | ||
}) |
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
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
156015
2
9
- Removedtsc@^2.0.3
- Removedtsc@2.0.4(transitive)