Simp-O-Matic

Dumb Discord bot in TS.
git clone git://git.knutsen.co/Simp-O-Matic
Log | Files | Refs | README | LICENSE

commit e9a7a9f3a55cff0aa0339f933217c74704ded787
parent 11889493d748483ff11b283ef9f523259aa87c2d
Author: Demonstrandum <moi@knutsen.co>
Date:   Mon,  6 Jul 2020 17:42:00 +0100

Exclude hours when duration is <1 hour.

Diffstat:
Mlib/commands/youtube.ts | 13++++++++++---
1 file changed, 10 insertions(+), 3 deletions(-)

diff --git a/lib/commands/youtube.ts b/lib/commands/youtube.ts @@ -24,11 +24,18 @@ export default async (home_scope: HomeScope) => { const result = await fetch(`https://invidio.us/api/v1/search?q=${query}&sort_by=${sort_by}&type=${type}`); const res_json = await result.json(); const res = res_json[Math.abs(num - 1)]; - const duration = new Date(res.lengthSeconds * 1000) + let duration = new Date(res.lengthSeconds * 1000) .toISOString() .substr(11, 8); - const views = Number(res.viewCount).to_abbrev(2); - message.answer(`Search for '${query}' (result №${num}): https://youtu.be/${res.videoId} \n published ${res.publishedText} view count: ${views} duration: ${duration}`); + if (duration.substr(0, 2) == '00') + duration = duration.slice(3); + + const views = Number(res.viewCount).to_abbrev(1); + + message.answer(`Search for '${query}' (result №${num}):` + + ` https://youtu.be/${res.videoId}\n` + + `published ${res.publishedText},` + + ` view count: ${views}, duration: ${duration}`); // TODO timestamp generation /*yt_search({ query })