add title to chromecast

This commit is contained in:
Roy Olav Purser 2021-05-19 08:55:20 +02:00
parent dca632e28c
commit d443fc74bf
Signed by: roypur
GPG Key ID: E14D26A036F21656
7 changed files with 28 additions and 33 deletions

View File

@ -10,8 +10,8 @@ android {
applicationId "it.purser.stream"
minSdkVersion 25
targetSdkVersion 29
versionCode 103
versionName "103.0"
versionCode 104
versionName "104.0"
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
}

View File

@ -8,12 +8,6 @@
android:roundIcon="@mipmap/ic_launcher_round"
android:supportsRtl="true"
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">
<intent-filter>
<action android:name="android.intent.action.SEND" />

View File

@ -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);
}
}

View File

@ -29,7 +29,6 @@ public class ShareActivity extends Activity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
Uri uri = getSharedLink();
if(uri != null) {
Uri.Builder builder = new Uri.Builder();
@ -38,7 +37,6 @@ public class ShareActivity extends Activity {
builder.path(uri.getPath());
builder.appendQueryParameter("provider", "youtube");
builder.appendQueryParameter("render", "true");
builder.appendQueryParameter("cast", "true");
Intent launch = new Intent(Intent.ACTION_VIEW, builder.build());
launch.setPackage("com.android.chrome");
launch.putExtra("android.support.customtabs.extra.SESSION", "Proxy Stream");

View File

@ -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>

View File

@ -28,6 +28,10 @@
options.techOrder = ["chromecast", "html5"];
options.plugins = {};
options.plugins.chromecast = {};
player.plugins.chromecast.requestTitleFn = (src) => {
return "{{ title }}";
}
let player = videojs(video, options);
let source = {};
source.type = ctype;

View File

@ -131,7 +131,7 @@ class UpstreamHandler():
self.upstream = None
self.upstream_safe = None
self.render = False
self.stream = True
self.stream = False
async def setup(self, handler):
self.provider = handler.get_query_argument("provider", None)
render_str = handler.get_query_argument("render", "false")
@ -142,6 +142,7 @@ class UpstreamHandler():
self.render = True
else:
self.stream = True
path = handler.request.path
if self.provider == "youtube":
path = path.strip("/")
@ -213,6 +214,7 @@ class UpstreamHandler():
data = list(data_new.items())
except Exception as e:
logger.info(e)
logger.info(data)
return data
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):
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")
script = f'data:text/javascript;charset=utf-8;base64,{b64_js}'
meta = await handler.meta()
data["script"] = script
data["videojs_version"] = videojs_version
data["chromecast_version"] = chromecast_version