add title to chromecast
This commit is contained in:
parent
dca632e28c
commit
d443fc74bf
@ -10,8 +10,8 @@ android {
|
|||||||
applicationId "it.purser.stream"
|
applicationId "it.purser.stream"
|
||||||
minSdkVersion 25
|
minSdkVersion 25
|
||||||
targetSdkVersion 29
|
targetSdkVersion 29
|
||||||
versionCode 103
|
versionCode 104
|
||||||
versionName "103.0"
|
versionName "104.0"
|
||||||
|
|
||||||
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
|
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
|
||||||
}
|
}
|
||||||
|
@ -8,12 +8,6 @@
|
|||||||
android:roundIcon="@mipmap/ic_launcher_round"
|
android:roundIcon="@mipmap/ic_launcher_round"
|
||||||
android:supportsRtl="true"
|
android:supportsRtl="true"
|
||||||
android:theme="@style/Theme.ProxyStream">
|
android:theme="@style/Theme.ProxyStream">
|
||||||
<activity android:name="it.purser.stream.MainActivity">
|
|
||||||
<intent-filter>
|
|
||||||
<action android:name="android.intent.action.MAIN"/>
|
|
||||||
<category android:name="android.intent.category.LAUNCHER"/>
|
|
||||||
</intent-filter>
|
|
||||||
</activity>
|
|
||||||
<activity android:name="it.purser.stream.ShareActivity">
|
<activity android:name="it.purser.stream.ShareActivity">
|
||||||
<intent-filter>
|
<intent-filter>
|
||||||
<action android:name="android.intent.action.SEND" />
|
<action android:name="android.intent.action.SEND" />
|
||||||
|
@ -1,12 +0,0 @@
|
|||||||
package it.purser.stream;
|
|
||||||
|
|
||||||
import android.app.Activity;
|
|
||||||
import android.os.Bundle;
|
|
||||||
|
|
||||||
public class MainActivity extends Activity {
|
|
||||||
@Override
|
|
||||||
protected void onCreate(Bundle savedInstanceState) {
|
|
||||||
super.onCreate(savedInstanceState);
|
|
||||||
setContentView(R.layout.activity_main);
|
|
||||||
}
|
|
||||||
}
|
|
@ -29,7 +29,6 @@ public class ShareActivity extends Activity {
|
|||||||
@Override
|
@Override
|
||||||
protected void onCreate(Bundle savedInstanceState) {
|
protected void onCreate(Bundle savedInstanceState) {
|
||||||
super.onCreate(savedInstanceState);
|
super.onCreate(savedInstanceState);
|
||||||
setContentView(R.layout.activity_main);
|
|
||||||
Uri uri = getSharedLink();
|
Uri uri = getSharedLink();
|
||||||
if(uri != null) {
|
if(uri != null) {
|
||||||
Uri.Builder builder = new Uri.Builder();
|
Uri.Builder builder = new Uri.Builder();
|
||||||
@ -38,7 +37,6 @@ public class ShareActivity extends Activity {
|
|||||||
builder.path(uri.getPath());
|
builder.path(uri.getPath());
|
||||||
builder.appendQueryParameter("provider", "youtube");
|
builder.appendQueryParameter("provider", "youtube");
|
||||||
builder.appendQueryParameter("render", "true");
|
builder.appendQueryParameter("render", "true");
|
||||||
builder.appendQueryParameter("cast", "true");
|
|
||||||
Intent launch = new Intent(Intent.ACTION_VIEW, builder.build());
|
Intent launch = new Intent(Intent.ACTION_VIEW, builder.build());
|
||||||
launch.setPackage("com.android.chrome");
|
launch.setPackage("com.android.chrome");
|
||||||
launch.putExtra("android.support.customtabs.extra.SESSION", "Proxy Stream");
|
launch.putExtra("android.support.customtabs.extra.SESSION", "Proxy Stream");
|
||||||
|
@ -1,8 +0,0 @@
|
|||||||
<?xml version="1.0" encoding="utf-8"?>
|
|
||||||
<android.widget.RelativeLayout
|
|
||||||
xmlns:android="http://schemas.android.com/apk/res/android"
|
|
||||||
xmlns:tools="http://schemas.android.com/tools"
|
|
||||||
android:layout_width="match_parent"
|
|
||||||
android:layout_height="match_parent"
|
|
||||||
tools:context=".MainActivity">
|
|
||||||
</android.widget.RelativeLayout>
|
|
@ -28,6 +28,10 @@
|
|||||||
options.techOrder = ["chromecast", "html5"];
|
options.techOrder = ["chromecast", "html5"];
|
||||||
options.plugins = {};
|
options.plugins = {};
|
||||||
options.plugins.chromecast = {};
|
options.plugins.chromecast = {};
|
||||||
|
player.plugins.chromecast.requestTitleFn = (src) => {
|
||||||
|
return "{{ title }}";
|
||||||
|
}
|
||||||
|
|
||||||
let player = videojs(video, options);
|
let player = videojs(video, options);
|
||||||
let source = {};
|
let source = {};
|
||||||
source.type = ctype;
|
source.type = ctype;
|
||||||
|
25
stream.py
25
stream.py
@ -131,7 +131,7 @@ class UpstreamHandler():
|
|||||||
self.upstream = None
|
self.upstream = None
|
||||||
self.upstream_safe = None
|
self.upstream_safe = None
|
||||||
self.render = False
|
self.render = False
|
||||||
self.stream = True
|
self.stream = False
|
||||||
async def setup(self, handler):
|
async def setup(self, handler):
|
||||||
self.provider = handler.get_query_argument("provider", None)
|
self.provider = handler.get_query_argument("provider", None)
|
||||||
render_str = handler.get_query_argument("render", "false")
|
render_str = handler.get_query_argument("render", "false")
|
||||||
@ -142,6 +142,7 @@ class UpstreamHandler():
|
|||||||
self.render = True
|
self.render = True
|
||||||
else:
|
else:
|
||||||
self.stream = True
|
self.stream = True
|
||||||
|
|
||||||
path = handler.request.path
|
path = handler.request.path
|
||||||
if self.provider == "youtube":
|
if self.provider == "youtube":
|
||||||
path = path.strip("/")
|
path = path.strip("/")
|
||||||
@ -213,6 +214,7 @@ class UpstreamHandler():
|
|||||||
data = list(data_new.items())
|
data = list(data_new.items())
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
logger.info(e)
|
logger.info(e)
|
||||||
|
logger.info(data)
|
||||||
return data
|
return data
|
||||||
|
|
||||||
if icecast_server is not None and stream_server is not None:
|
if icecast_server is not None and stream_server is not None:
|
||||||
@ -324,10 +326,27 @@ class MainHandler(tornado.web.RequestHandler):
|
|||||||
|
|
||||||
async def handle_render(self, handler):
|
async def handle_render(self, handler):
|
||||||
if template_js is not None and template_html is not None:
|
if template_js is not None and template_html is not None:
|
||||||
rendered_js = template_js.generate(stream=handler.stream_url);
|
meta = await handler.meta()
|
||||||
|
title = handler.render_url
|
||||||
|
video_creator = None
|
||||||
|
video_title = None
|
||||||
|
for elem in meta:
|
||||||
|
if isinstance(elem[1], str):
|
||||||
|
if elem[0] == "og:title":
|
||||||
|
video_title = elem[1]
|
||||||
|
elif elem[0] == "og:description":
|
||||||
|
video_creator = elem[1]
|
||||||
|
|
||||||
|
if isinstance(video_creator, str) and isinstance(video_title, str):
|
||||||
|
title = f'{video_creator}: {video_title}'
|
||||||
|
elif isinstance(video_creator, str):
|
||||||
|
title = video_creator
|
||||||
|
elif isinstance(video_title, str):
|
||||||
|
title = video_title
|
||||||
|
|
||||||
|
rendered_js = template_js.generate(stream=handler.stream_url, title=title);
|
||||||
b64_js = str(base64.b64encode(rendered_js), "ascii")
|
b64_js = str(base64.b64encode(rendered_js), "ascii")
|
||||||
script = f'data:text/javascript;charset=utf-8;base64,{b64_js}'
|
script = f'data:text/javascript;charset=utf-8;base64,{b64_js}'
|
||||||
meta = await handler.meta()
|
|
||||||
data["script"] = script
|
data["script"] = script
|
||||||
data["videojs_version"] = videojs_version
|
data["videojs_version"] = videojs_version
|
||||||
data["chromecast_version"] = chromecast_version
|
data["chromecast_version"] = chromecast_version
|
||||||
|
Loading…
Reference in New Issue
Block a user