diff options
| author | RblSb <msrblsb@gmail.com> | 2020-02-29 14:01:12 +0300 |
|---|---|---|
| committer | RblSb <msrblsb@gmail.com> | 2020-02-29 14:01:12 +0300 |
| commit | 2ade04273717807096a07b6eb132b7677917392d (patch) | |
| tree | 1598ad62bcb1f3c42b37edb7383df2704005bee5 /src/client/Main.hx | |
| parent | ec7e4b5ad120828f1464cf4186287d4928b462a8 (diff) | |
Get youtube video title/duration with api
Diffstat (limited to 'src/client/Main.hx')
| -rw-r--r-- | src/client/Main.hx | 17 |
1 files changed, 8 insertions, 9 deletions
diff --git a/src/client/Main.hx b/src/client/Main.hx index d3271e9..c74a600 100644 --- a/src/client/Main.hx +++ b/src/client/Main.hx @@ -12,7 +12,9 @@ import js.Browser; import js.Browser.document; import js.lib.Date; import Client.ClientData; -import Types; +import Types.VideoData; +import Types.Config; +import Types.WsEvent; using StringTools; using ClientTools; @@ -156,23 +158,20 @@ class Main { url = '$protocol//$host:$port$url'; } if (!url.startsWith("http")) url = '$protocol//$url'; - var name = url.substr(url.lastIndexOf('/') + 1); - final matchName = ~/^(.+)\./; - if (matchName.match(name)) name = matchName.matched(1); - else name = Lang.get("rawVideo"); - player.getRemoteDuration(url, (duration:Float) -> { - if (duration == 0) { + player.getVideoData(url, (data:VideoData) -> { + if (data.duration == 0) { serverMessage(4, Lang.get("addVideoError")); return; } + if (data.title == null) data.title = Lang.get("rawVideo"); send({ type: AddVideo, addVideo: { item: { url: url, - title: name, + title: data.title, author: personal.name, - duration: duration, + duration: data.duration, isTemp: isTemp }, atEnd: atEnd |
