Support youtube desc

pull/594/head
jhengazuki 4 months ago
parent dea186465c
commit 60861fe16e
  1. 15
      app/src/leanback/java/com/fongmi/android/tv/ui/activity/VideoActivity.java
  2. 8
      app/src/main/java/com/fongmi/android/tv/bean/Vod.java
  3. 18
      app/src/main/java/com/fongmi/android/tv/event/RefreshEvent.java
  4. 19
      app/src/main/java/com/fongmi/android/tv/player/extractor/Youtube.java
  5. 14
      app/src/mobile/java/com/fongmi/android/tv/ui/activity/VideoActivity.java

@ -6,7 +6,6 @@ import android.app.Activity;
import android.content.Intent; import android.content.Intent;
import android.graphics.drawable.Drawable; import android.graphics.drawable.Drawable;
import android.net.Uri; import android.net.Uri;
import android.text.Html;
import android.text.SpannableStringBuilder; import android.text.SpannableStringBuilder;
import android.text.Spanned; import android.text.Spanned;
import android.text.TextUtils; import android.text.TextUtils;
@ -996,6 +995,19 @@ public class VideoActivity extends BaseActivity implements CustomKeyDownVod.List
keep.save(); keep.save();
} }
private void updateVod(Vod item) {
mHistory.setVodPic(item.getVodPic());
mHistory.setVodName(item.getVodName());
mBinding.video.setTag(item.getVodPic());
mBinding.name.setText(item.getVodName());
mBinding.widget.title.setText(item.getVodName());
setText(mBinding.content, R.string.detail_content, item.getVodContent());
setText(mBinding.director, R.string.detail_director, item.getVodDirector());
mBinding.content.setMaxLines(getMaxLines());
setArtwork(item.getVodPic());
setMetadata();
}
@Override @Override
public void onSubtitleClick() { public void onSubtitleClick() {
App.post(this::hideControl, 200); App.post(this::hideControl, 200);
@ -1032,6 +1044,7 @@ public class VideoActivity extends BaseActivity implements CustomKeyDownVod.List
if (isRedirect()) return; if (isRedirect()) return;
if (event.getType() == RefreshEvent.Type.DETAIL) getDetail(); if (event.getType() == RefreshEvent.Type.DETAIL) getDetail();
else if (event.getType() == RefreshEvent.Type.PLAYER) onRefresh(); else if (event.getType() == RefreshEvent.Type.PLAYER) onRefresh();
else if (event.getType() == RefreshEvent.Type.VOD) updateVod(event.getVod());
else if (event.getType() == RefreshEvent.Type.SUBTITLE) mPlayers.setSub(Sub.from(event.getPath())); else if (event.getType() == RefreshEvent.Type.SUBTITLE) mPlayers.setSub(Sub.from(event.getPath()));
else if (event.getType() == RefreshEvent.Type.DANMAKU) mPlayers.setDanmaku(Danmaku.from(event.getPath())); else if (event.getType() == RefreshEvent.Type.DANMAKU) mPlayers.setDanmaku(Danmaku.from(event.getPath()));
} }

@ -154,6 +154,10 @@ public class Vod implements Parcelable {
return TextUtils.isEmpty(vodDirector) ? "" : Util.clean(vodDirector); return TextUtils.isEmpty(vodDirector) ? "" : Util.clean(vodDirector);
} }
public void setVodDirector(String vodDirector) {
this.vodDirector = vodDirector;
}
public String getVodActor() { public String getVodActor() {
return TextUtils.isEmpty(vodActor) ? "" : Util.clean(vodActor); return TextUtils.isEmpty(vodActor) ? "" : Util.clean(vodActor);
} }
@ -162,6 +166,10 @@ public class Vod implements Parcelable {
return TextUtils.isEmpty(vodContent) ? "" : Util.clean(vodContent); return TextUtils.isEmpty(vodContent) ? "" : Util.clean(vodContent);
} }
public void setVodContent(String vodContent) {
this.vodContent = vodContent;
}
public String getVodPlayFrom() { public String getVodPlayFrom() {
return TextUtils.isEmpty(vodPlayFrom) ? "" : vodPlayFrom; return TextUtils.isEmpty(vodPlayFrom) ? "" : vodPlayFrom;
} }

@ -1,11 +1,14 @@
package com.fongmi.android.tv.event; package com.fongmi.android.tv.event;
import com.fongmi.android.tv.bean.Vod;
import org.greenrobot.eventbus.EventBus; import org.greenrobot.eventbus.EventBus;
public class RefreshEvent { public class RefreshEvent {
private final Type type; private final Type type;
private String path; private String path;
private Vod vod;
public static void config() { public static void config() {
EventBus.getDefault().post(new RefreshEvent(Type.CONFIG)); EventBus.getDefault().post(new RefreshEvent(Type.CONFIG));
@ -55,6 +58,10 @@ public class RefreshEvent {
EventBus.getDefault().post(new RefreshEvent(Type.DANMAKU, path)); EventBus.getDefault().post(new RefreshEvent(Type.DANMAKU, path));
} }
public static void vod(Vod vod) {
EventBus.getDefault().post(new RefreshEvent(Type.VOD, vod));
}
private RefreshEvent(Type type) { private RefreshEvent(Type type) {
this.type = type; this.type = type;
} }
@ -64,6 +71,11 @@ public class RefreshEvent {
this.path = path; this.path = path;
} }
private RefreshEvent(Type type, Vod vod) {
this.type = type;
this.vod = vod;
}
public Type getType() { public Type getType() {
return type; return type;
} }
@ -72,7 +84,11 @@ public class RefreshEvent {
return path; return path;
} }
public Vod getVod() {
return vod;
}
public enum Type { public enum Type {
CONFIG, IMAGE, VIDEO, HISTORY, KEEP, SIZE, WALL, LIVE, DETAIL, PLAYER, SUBTITLE, DANMAKU CONFIG, IMAGE, VIDEO, HISTORY, KEEP, SIZE, WALL, LIVE, DETAIL, PLAYER, SUBTITLE, DANMAKU, VOD
} }
} }

@ -3,6 +3,8 @@ package com.fongmi.android.tv.player.extractor;
import android.util.Base64; import android.util.Base64;
import com.fongmi.android.tv.bean.Episode; import com.fongmi.android.tv.bean.Episode;
import com.fongmi.android.tv.bean.Vod;
import com.fongmi.android.tv.event.RefreshEvent;
import com.fongmi.android.tv.impl.NewPipeImpl; import com.fongmi.android.tv.impl.NewPipeImpl;
import com.fongmi.android.tv.player.Source; import com.fongmi.android.tv.player.Source;
@ -44,9 +46,26 @@ public class Youtube implements Source.Extractor {
@Override @Override
public String fetch(String url) throws Exception { public String fetch(String url) throws Exception {
StreamInfo info = StreamInfo.getInfo(url); StreamInfo info = StreamInfo.getInfo(url);
RefreshEvent.vod(convert(info));
return isLive(info) ? getLive(info) : getMpd(info); return isLive(info) ? getLive(info) : getMpd(info);
} }
private Vod convert(StreamInfo info) {
try {
Vod vod = new Vod();
vod.setVodName(info.getName());
vod.setVodDirector(info.getUploaderName());
vod.setVodContent(info.getDescription().getContent());
vod.setVodPic(info.getThumbnails().get(info.getThumbnails().size() - 1).getUrl());
return vod;
} catch (Exception e) {
Vod vod = new Vod();
vod.setVodName(info.getName());
vod.setVodContent(info.getDescription().getContent());
return vod;
}
}
private boolean isLive(StreamInfo info) { private boolean isLive(StreamInfo info) {
return StreamType.LIVE_STREAM.equals(info.getStreamType()); return StreamType.LIVE_STREAM.equals(info.getStreamType());
} }

@ -1071,6 +1071,19 @@ public class VideoActivity extends BaseActivity implements Clock.Callback, Custo
keep.save(); keep.save();
} }
private void updateVod(Vod item) {
mHistory.setVodPic(item.getVodPic());
mHistory.setVodName(item.getVodName());
mBinding.video.setTag(item.getVodPic());
mBinding.name.setText(item.getVodName());
mBinding.control.title.setText(item.getVodName());
setText(mBinding.content, 0, item.getVodContent());
setText(mBinding.director, R.string.detail_director, item.getVodDirector());
mBinding.contentLayout.setVisibility(mBinding.content.getVisibility());
setArtwork(item.getVodPic());
setMetadata();
}
@Override @Override
public void onSubtitleClick() { public void onSubtitleClick() {
App.post(this::hideControl, 200); App.post(this::hideControl, 200);
@ -1113,6 +1126,7 @@ public class VideoActivity extends BaseActivity implements Clock.Callback, Custo
if (isRedirect()) return; if (isRedirect()) return;
if (event.getType() == RefreshEvent.Type.DETAIL) getDetail(); if (event.getType() == RefreshEvent.Type.DETAIL) getDetail();
else if (event.getType() == RefreshEvent.Type.PLAYER) onRefresh(); else if (event.getType() == RefreshEvent.Type.PLAYER) onRefresh();
else if (event.getType() == RefreshEvent.Type.VOD) updateVod(event.getVod());
else if (event.getType() == RefreshEvent.Type.SUBTITLE) mPlayers.setSub(Sub.from(event.getPath())); else if (event.getType() == RefreshEvent.Type.SUBTITLE) mPlayers.setSub(Sub.from(event.getPath()));
else if (event.getType() == RefreshEvent.Type.DANMAKU) mPlayers.setDanmaku(Danmaku.from(event.getPath())); else if (event.getType() == RefreshEvent.Type.DANMAKU) mPlayers.setDanmaku(Danmaku.from(event.getPath()));
} }

Loading…
Cancel
Save