-
Notifications
You must be signed in to change notification settings - Fork 54
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
closes #49
- Loading branch information
Showing
21 changed files
with
187 additions
and
94 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,66 @@ | ||
package client.players; | ||
|
||
import Types.VideoData; | ||
import Types.VideoDataRequest; | ||
import haxe.DynamicAccess; | ||
import haxe.Http; | ||
import haxe.Json; | ||
|
||
class Streamable extends Raw { | ||
final matchStreamable = ~/streamable\.com\/(.+)/g; | ||
final matchBadStreamableId = ~/[^0-9A-z-_]/g; | ||
|
||
override function isSupportedLink(url:String):Bool { | ||
if (!matchStreamable.match(url)) return false; | ||
final id = matchStreamable.matched(1); | ||
if (matchBadStreamableId.match(id)) return false; | ||
return true; | ||
} | ||
|
||
override function getVideoData(data:VideoDataRequest, callback:(data:VideoData) -> Void) { | ||
getStreamableVideoData(data.url, info -> { | ||
if (info == null) { | ||
callback({duration: 0}); | ||
return; | ||
} | ||
|
||
getRawVideoData({url: info.url, atEnd: data.atEnd}, data -> { | ||
// set new url instead of using input one to load video | ||
data.url = info.url; | ||
data.title = info.title; | ||
callback(data); | ||
}); | ||
}); | ||
} | ||
|
||
function getRawVideoData(data:VideoDataRequest, callback:(data:VideoData) -> Void):Void { | ||
super.getVideoData(data, callback); | ||
} | ||
|
||
function getStreamableVideoData(url:String, callback:(info:Null<{url:String, title:String}>) -> Void):Void { | ||
if (!matchStreamable.match(url)) { | ||
callback(null); | ||
return; | ||
} | ||
final id = matchStreamable.matched(1); | ||
final http = new Http('https://api.streamable.com/videos/$id'); | ||
http.onData = text -> { | ||
try { | ||
final json:{title:String, ?files:DynamicAccess<Dynamic>} = Json.parse(text); | ||
final files = json?.files; | ||
var item = files["mp4"]; | ||
if (item == null) { | ||
final key = files.keys()[0]; | ||
item = files[key]; | ||
} | ||
callback({ | ||
url: item.url, | ||
title: json.title | ||
}); | ||
} catch (e) { | ||
callback(null); | ||
} | ||
} | ||
http.request(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
using Lambda; | ||
using StringTools; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters