diff options
| author | RblSb <msrblsb@gmail.com> | 2022-11-24 23:17:19 +0300 |
|---|---|---|
| committer | RblSb <msrblsb@gmail.com> | 2022-11-24 23:17:19 +0300 |
| commit | e877f070e367a7a9d93b93bf676f4afdb948356f (patch) | |
| tree | 79a80fd8906ed7b421ba14c560e0bd50635267d0 | |
| parent | 7c346c43b54210f78f68815d26643ee8a8e949ee (diff) | |
Youtube shorts support
| -rw-r--r-- | README.md | 2 | ||||
| -rw-r--r-- | res/client.js | 6 | ||||
| -rw-r--r-- | src/client/players/Youtube.hx | 4 |
3 files changed, 10 insertions, 2 deletions
@@ -17,7 +17,7 @@ Default channel example: https://synctube.onrender.com/ - [Native mobile client](https://github.com/RblSb/SyncTubeApp)
### Supported players
-- Youtube (videos, streams and playlists)
+- Youtube (videos, shorts, streams and playlists)
- Raw mp4 videos and m3u8 playlists (or any other media format supported in browser)
- Iframes (without sync)
diff --git a/res/client.js b/res/client.js index 95ce777..c63a4ef 100644 --- a/res/client.js +++ b/res/client.js @@ -3196,6 +3196,7 @@ var client_players_Youtube = function(main,player) { this.videosUrl = "https://www.googleapis.com/youtube/v3/videos"; this.matchPlaylist = new EReg("youtube\\.com.*list=([A-z0-9_-]+)",""); this.matchEmbed = new EReg("youtube\\.com/embed/([A-z0-9_-]+)",""); + this.matchShorts = new EReg("youtube\\.com/shorts/([A-z0-9_-]+)",""); this.matchShort = new EReg("youtu\\.be/([A-z0-9_-]+)",""); this.matchId = new EReg("youtube\\.com.*v=([A-z0-9_-]+)",""); this.main = main; @@ -3217,6 +3218,9 @@ client_players_Youtube.prototype = { if(this.matchShort.match(url)) { return this.matchShort.matched(1); } + if(this.matchShorts.match(url)) { + return this.matchShorts.matched(1); + } if(this.matchEmbed.match(url)) { return this.matchEmbed.matched(1); } @@ -3354,7 +3358,7 @@ client_players_Youtube.prototype = { } callback({ duration : _gthis.tempYoutube.getDuration()}); }, onError : function(e) { - haxe_Log.trace("Error " + e.data,{ fileName : "src/client/players/Youtube.hx", lineNumber : 201, className : "client.players.Youtube", methodName : "getRemoteDataFallback"}); + haxe_Log.trace("Error " + e.data,{ fileName : "src/client/players/Youtube.hx", lineNumber : 205, className : "client.players.Youtube", methodName : "getRemoteDataFallback"}); if(_gthis.playerEl.contains(video)) { _gthis.playerEl.removeChild(video); } diff --git a/src/client/players/Youtube.hx b/src/client/players/Youtube.hx index 65a93c9..ca8d415 100644 --- a/src/client/players/Youtube.hx +++ b/src/client/players/Youtube.hx @@ -16,6 +16,7 @@ using StringTools; class Youtube implements IPlayer { final matchId = ~/youtube\.com.*v=([A-z0-9_-]+)/; final matchShort = ~/youtu\.be\/([A-z0-9_-]+)/; + final matchShorts = ~/youtube\.com\/shorts\/([A-z0-9_-]+)/; final matchEmbed = ~/youtube\.com\/embed\/([A-z0-9_-]+)/; final matchPlaylist = ~/youtube\.com.*list=([A-z0-9_-]+)/; final videosUrl = "https://www.googleapis.com/youtube/v3/videos"; @@ -47,6 +48,9 @@ class Youtube implements IPlayer { if (matchShort.match(url)) { return matchShort.matched(1); } + if (matchShorts.match(url)) { + return matchShorts.matched(1); + } if (matchEmbed.match(url)) { return matchEmbed.matched(1); } |
