Skip to content

Commit

Permalink
update
Browse files Browse the repository at this point in the history
  • Loading branch information
qidian55 committed Oct 11, 2024
1 parent 7233c4d commit 50c1f08
Show file tree
Hide file tree
Showing 16 changed files with 995 additions and 306 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,7 @@
- 测试性功能——CC字幕:采用高级弹幕实现
- 测试性功能——弹幕过滤
- 主页推荐接口调整,1.6.6版本的接口坏了时用1.6.4版本的接口
- 测试性功能——自定义CDN


## todo list
Expand Down
Binary file modified mybv.apk
Binary file not shown.
128 changes: 101 additions & 27 deletions mybv/java/classes/bl/afm3.java
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,22 @@
import com.bilibili.tv.MainApplication;
import android.view.inputmethod.EditorInfo;

import org.json.*;
import java.util.*;
import mybl.BiliFilter;
import mybl.VideoViewParams;
import android.app.AlertDialog;
import android.content.DialogInterface;

/* compiled from: BL */
/* loaded from: classes.dex */
public final class afm3 extends adw implements View.OnFocusChangeListener, View.OnClickListener, TextView.OnEditorActionListener {
public static final a Companion = new a(null);
public static List<String> tmp_cdns;
private DrawFrameLayout filter_button;
private DrawFrameLayout cdn_button;
private DrawEditText filter_path;
private DrawEditText cdn_value;

@Override // bl.adw
public boolean c() {
Expand All @@ -31,48 +39,102 @@ public View onCreateView(LayoutInflater inflater, ViewGroup viewGroup, Bundle bu
bbi.b(inflater, "inflater");
View inflate = inflater.inflate(R.layout.fragment_experiment, viewGroup, false);
this.filter_button = (DrawFrameLayout)inflate.findViewById(R.id.filter_button);
this.cdn_button = (DrawFrameLayout)inflate.findViewById(R.id.cdn_button);
this.filter_path = (DrawEditText)inflate.findViewById(R.id.filter_path);
this.cdn_value = (DrawEditText)inflate.findViewById(R.id.cdn_value);
this.filter_button.setUpDrawable(R.drawable.shadow_white_rect);
this.filter_button.setOnFocusChangeListener(this);
this.cdn_button.setUpDrawable(R.drawable.shadow_white_rect);
this.cdn_button.setOnFocusChangeListener(this);
if(BiliFilter.filter_on){
((ShadowTextView)((ViewGroup)this.filter_button).getChildAt(0)).setText("启用视频过滤");
this.filter_button.setBackgroundResource(R.drawable.shape_rectangle_trans_with_12corner_white_50);
this.filter_button.setNextFocusRightId(R.id.filter_path);
this.filter_path.setEnabled(true);
this.filter_path.setFocusable(true);
this.filter_path.setClickable(true);
this.filter_path.setText(abd.get_filter_path(MainApplication.a().getApplicationContext()));
}
this.cdn_button.setNextFocusRightId(R.id.cdn_value);
this.cdn_value.setEnabled(true);
this.cdn_value.setFocusable(true);
this.cdn_value.setClickable(true);
if(VideoViewParams.cdn_history.size()==0){
((ShadowTextView)((ViewGroup)this.cdn_button).getChildAt(0)).setText("通用CDN");
}
else{
((ShadowTextView)((ViewGroup)this.cdn_button).getChildAt(0)).setText("区域CDN");
}
this.cdn_value.setText(VideoViewParams.prefect_cdn);
this.filter_button.setOnClickListener(this);
this.cdn_button.setOnClickListener(this);
this.filter_path.setOnEditorActionListener(this);
this.cdn_value.setOnEditorActionListener(this);
return inflate;
}

@Override // android.view.View.OnClickListener
public final void onClick(View view) {
if(BiliFilter.filter_on){
((ShadowTextView)((ViewGroup)view).getChildAt(0)).setText("禁用视频过滤");
view.setBackgroundResource(R.drawable.shape_rectangle_trans_with_12corner_white_10);
this.filter_path.setEnabled(false);
this.filter_path.setFocusable(false);
this.filter_path.setClickable(false);
this.filter_path.setText("");
}
else{
((ShadowTextView)((ViewGroup)view).getChildAt(0)).setText("启用视频过滤");
view.setBackgroundResource(R.drawable.shape_rectangle_trans_with_12corner_white_50);
this.filter_path.setEnabled(true);
this.filter_path.setFocusable(true);
this.filter_path.setClickable(true);
try{
BiliFilter.updateConfig();
lr.b(afm3.this.getActivity(), "过滤器配置已更新");
if(view == this.filter_button){
if(BiliFilter.filter_on){
((ShadowTextView)((ViewGroup)view).getChildAt(0)).setText("禁用视频过滤");
view.setBackgroundResource(R.drawable.shape_rectangle_trans_with_12corner_white_10);
this.filter_button.setNextFocusRightId(R.id.filter_button);
this.filter_path.setEnabled(false);
this.filter_path.setFocusable(false);
this.filter_path.setClickable(false);
this.filter_path.setText("");
}
catch(Exception e){
lr.a(afm3.this.getActivity(), e.toString());
else{
((ShadowTextView)((ViewGroup)view).getChildAt(0)).setText("启用视频过滤");
view.setBackgroundResource(R.drawable.shape_rectangle_trans_with_12corner_white_50);
this.filter_button.setNextFocusRightId(R.id.filter_path);
this.filter_path.setEnabled(true);
this.filter_path.setFocusable(true);
this.filter_path.setClickable(true);
try{
BiliFilter.updateConfig();
lr.b(afm3.this.getActivity(), "过滤器配置已更新");
}
catch(Exception e){
lr.a(afm3.this.getActivity(), e.toString());
}
filter_path.setText(BiliFilter.filter_rule_path);
}
BiliFilter.filter_on=!BiliFilter.filter_on;
}
if(view == this.cdn_button){
afm3.tmp_cdns = VideoViewParams.cdn_history;
List<String> show_cdns = VideoViewParams.cdn_history;
if(afm3.tmp_cdns.size()==0){
try{
JSONObject default_cdns = new JSONObject("{\"腾讯\":[\"upos-sz-mirrorcos.bilivideo.com\",\"upos-sz-mirrorcosb.bilivideo.com\",\"upos-sz-mirrorcoso1.bilivideo.com\"],\"百度\":[\"upos-sz-mirrorbos.bilivideo.com\"],\"阿里\":[\"upos-sz-mirrorali.bilivideo.com\",\"upos-sz-mirroralib.bilivideo.com\",\"upos-sz-mirroralio1.bilivideo.com\"],\"华为\":[\"upos-sz-mirrorhw.bilivideo.com\",\"upos-sz-mirrorhwb.bilivideo.com\",\"upos-sz-mirrorhwo1.bilivideo.com\",\"upos-sz-mirror08c.bilivideo.com\",\"upos-sz-mirror08h.bilivideo.com\",\"upos-sz-mirror08ct.bilivideo.com\"],\"海外\":[\"upos-sz-mirroraliov.bilivideo.com\"],\"其它\":[\"upos-sz-upcdnbda2.bilivideo.com\",\"upos-sz-upcdnws.bilivideo.com\",\"upos-tf-all-tx.bilivideo.com\"]}");
afm3.tmp_cdns = new ArrayList<String>();
show_cdns = new ArrayList<String>();
for (Iterator iterator = default_cdns.keys(); iterator.hasNext();){
String cdn_provider = (String)iterator.next();
JSONArray values = default_cdns.getJSONArray(cdn_provider);
for(int i=0;i<values.length();i++){
String cdn_value=values.getString(i);
afm3.tmp_cdns.add(cdn_value);
show_cdns.add(cdn_value+"("+cdn_provider+")");
}
}
}
catch(Exception e){
e.printStackTrace();
}
}
filter_path.setText(BiliFilter.filter_rule_path);
AlertDialog dialog = new AlertDialog.Builder(getContext())
.setItems(show_cdns.toArray(new String[0]), new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
VideoViewParams.prefect_cdn=afm3.tmp_cdns.get(which);
afm3.this.cdn_value.setText(VideoViewParams.prefect_cdn);
}
}).create();
dialog.show();
}
BiliFilter.filter_on=!BiliFilter.filter_on;
}

@Override // android.view.View.OnFocusChangeListener
Expand All @@ -87,13 +149,25 @@ public final void onFocusChange(View view, boolean z) {
@Override
public boolean onEditorAction(TextView v, int actionId, KeyEvent event) {
if (actionId == EditorInfo.IME_ACTION_DONE) {
abd.set_filter_path(MainApplication.a().getApplicationContext(), v.getText().toString());
try{
BiliFilter.updateConfig();
lr.b(afm3.this.getActivity(), "过滤器配置已更新");
if(v==this.filter_path){
abd.set_filter_path(MainApplication.a().getApplicationContext(), v.getText().toString());
try{
BiliFilter.updateConfig();
v.setText(BiliFilter.filter_rule_path);
lr.b(afm3.this.getActivity(), "过滤器配置已更新");
}
catch(Exception e){
lr.a(afm3.this.getActivity(), e.toString());
}
}
catch(Exception e){
lr.a(afm3.this.getActivity(), e.toString());
if(v==this.cdn_value){
if(v.getText().toString().endsWith(".bilivideo.com")){
VideoViewParams.prefect_cdn=v.getText().toString();
lr.b(afm3.this.getActivity(), "已设置默认CDN");
}
else{
lr.a(afm3.this.getActivity(), "CDN不合法");
}
}
return false;
}
Expand Down
2 changes: 2 additions & 0 deletions mybv/java/classes/com/bilibili/tv/R.java
Original file line number Diff line number Diff line change
Expand Up @@ -2453,6 +2453,8 @@ public static final class id {
public static final int video_detail_episodes_video = 0x7f080171;
public static final int filter_button = 0x7f080172;
public static final int filter_path = 0x7f080173;
public static final int cdn_button = 0x7f080174;
public static final int cdn_value = 0x7f080175;
}

public static final class integer {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -599,11 +599,11 @@ public void init_mode(List<String> list, int i) {
}

public void init_subtitle(JSONObject subtitle_info) {
List<String> subtitle_list = new ArrayList<>();
subtitle_list.add("关闭字幕");
this.subtitle_list = new ArrayList<>();
this.subtitle_list.add("关闭字幕");
if(subtitle_info==null){this.subtitle_id = 0;return;}
JSONArray subtitles = subtitle_info.optJSONArray("subtitles");
for(int i=0;i<subtitles.length();i++)subtitle_list.add(subtitles.optJSONObject(i).optString("lan_doc"));
this.subtitle_list = subtitle_list;
for(int i=0;i<subtitles.length();i++)this.subtitle_list.add(subtitles.optJSONObject(i).optString("lan_doc"));
if(subtitles.length()>0 && !subtitles.optJSONObject(0).optString("lan").startsWith("ai-"))this.subtitle_id = 1;
else this.subtitle_id = 0;
}
Expand Down
7 changes: 3 additions & 4 deletions mybv/java/classes/mybl/BiliFilter.java
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,8 @@ public static void saveConfig(){
try {
inputStream = assetManager.open("data/filter_rule_example.json");
File f = new File(aj.a(MainApplication.a(),"data")[0],"filter_rule_example.json");
//BiliFilter.filter_rule_path = f.getPath();
//abd.set_filter_path(MainApplication.a().getApplicationContext(), BiliFilter.filter_rule_path);
BiliFilter.filter_rule_path = f.getPath();
abd.set_filter_path(MainApplication.a().getApplicationContext(), BiliFilter.filter_rule_path);
//if(f.exists()&&f.isFile())return;
outputStream = new FileOutputStream(f);
byte[] buffer = new byte[1024];
Expand Down Expand Up @@ -128,8 +128,7 @@ class Config{
List<String> filter_words;
Config() throws Exception{
try {
//if(BiliFilter.filter_rule_path.isEmpty())
BiliFilter.saveConfig();
if(BiliFilter.filter_rule_path.isEmpty())BiliFilter.saveConfig();
File f = new File(BiliFilter.filter_rule_path);
FileInputStream fileInputStream = new FileInputStream(f);
String content = kz.c(fileInputStream);
Expand Down
13 changes: 10 additions & 3 deletions mybv/java/classes/mybl/VideoViewParams.java
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,16 @@
import android.os.Bundle;

import java.util.*;
import android.net.Uri;

import tv.danmaku.ijk.media.player.IjkMediaMeta;

import org.json.JSONArray;
import org.json.JSONObject;
import org.json.*;

public class VideoViewParams {
public static List<String> cdn_history = new ArrayList<String>();
public static String prefect_cdn = null;

public static String CloestURL(String url,JSONObject dash){
JSONArray videos=dash.optJSONArray("video");
JSONArray audios=dash.optJSONArray("audio");
Expand All @@ -25,6 +28,7 @@ public static String CloestURL(String url,JSONObject dash){
info=s.split("\\?")[0].split("/");
if(info[info.length-1].equals(name))url=s;
}
if(VideoViewParams.prefect_cdn!=null)url = Uri.parse(url).buildUpon().authority(VideoViewParams.prefect_cdn).build().toString();
return url;
}

Expand All @@ -49,7 +53,10 @@ private static Bundle a(int num, boolean z, JSONArray list) {
int id = dashMediaIndex.optInt("id");
String idstr = String.valueOf(id);
Ids.add(id);
bundle2.putString(idstr, dashMediaIndex.optString("base_url"));
String base_url = dashMediaIndex.optString("base_url");
String cdn_host = Uri.parse(base_url).getHost();
if(!VideoViewParams.cdn_history.contains(cdn_host))VideoViewParams.cdn_history.add(cdn_host);
bundle2.putString(idstr, base_url);
JSONArray c = dashMediaIndex.optJSONArray("backup_url");
if (c != null) {
bundle3.putString(idstr, c.optString(0));
Expand Down
80 changes: 72 additions & 8 deletions mybv/res/layout/fragment_experiment.xml
Original file line number Diff line number Diff line change
Expand Up @@ -7,16 +7,15 @@
android:focusable="false"
android:clipChildren="false"
android:layout_width="match_parent"
android:layout_height="@dimen/px_300">
android:layout_height="@dimen/px_200">
<com.bilibili.tv.widget.DrawFrameLayout
android:id="@id/filter_button"
android:background="@drawable/shape_rectangle_trans_with_12corner_white_10"
android:focusable="true"
android:focusableInTouchMode="true"
android:nextFocusLeft="@id/filter_button"
android:nextFocusRight="@id/filter_path"
android:nextFocusRight="@id/filter_button"
android:nextFocusUp="@id/filter_button"
android:nextFocusDown="@id/filter_button"
android:nextFocusDown="@id/cdn_button"
android:layout_width="@dimen/px_350"
android:layout_height="@dimen/px_96"
android:layout_marginLeft="@dimen/px_30"
Expand All @@ -39,17 +38,82 @@
android:nextFocusLeft="@id/filter_button"
android:nextFocusRight="@id/filter_path"
android:nextFocusUp="@id/filter_path"
android:nextFocusDown="@id/filter_path"
android:layout_width="match_parent"
android:nextFocusDown="@id/cdn_value"
android:layout_width="fill_parent"
android:layout_height="@dimen/px_100"
android:background="@drawable/ic_login_edit_background"
android:hint="配置文件路径"
android:imeOptions="actionDone"
android:singleLine="true"
android:textColor="@color/white"
android:textColorHint="@color/white_50"
android:textSize="@dimen/px_36"
android:paddingLeft="@dimen/px_30"
android:paddingRight="@dimen/px_70"
android:paddingRight="@dimen/px_30"
android:layout_marginLeft="@dimen/px_30"
android:layout_marginRight="@dimen/px_30" />
</LinearLayout>
<LinearLayout
android:gravity="center"
android:orientation="horizontal"
android:focusable="false"
android:clipChildren="false"
android:layout_width="match_parent"
android:layout_height="@dimen/px_200">
<com.bilibili.tv.widget.ShadowTextView
android:gravity="center"
android:layout_gravity="center"
android:focusable="false"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="自定义CDN:"
android:textColor="@color/white"
android:textSize="@dimen/px_44"
android:layout_marginLeft="@dimen/px_30"
android:layout_marginRight="@dimen/px_30" />
<com.bilibili.tv.widget.DrawFrameLayout
android:id="@id/cdn_button"
android:background="@drawable/shape_rectangle_trans_with_12corner_white_10"
android:focusable="true"
android:focusableInTouchMode="true"
android:nextFocusRight="@id/cdn_value"
android:nextFocusUp="@id/filter_button"
android:nextFocusDown="@id/cdn_button"
android:paddingLeft="@dimen/px_30"
android:paddingRight="@dimen/px_30"
android:layout_width="wrap_content"
android:layout_height="@dimen/px_96">
<com.bilibili.tv.widget.ShadowTextView
android:gravity="center"
android:layout_gravity="center"
android:focusable="false"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="历史记录"
android:textColor="@color/white"
android:textSize="@dimen/px_44" />
</com.bilibili.tv.widget.DrawFrameLayout>
<com.bilibili.tv.widget.DrawEditText
android:id="@id/cdn_value"
android:enabled="true"
android:focusable="true"
android:focusableInTouchMode="true"
android:nextFocusLeft="@id/cdn_button"
android:nextFocusRight="@id/cdn_value"
android:nextFocusUp="@id/filter_path"
android:nextFocusDown="@id/cdn_value"
android:layout_width="fill_parent"
android:layout_height="@dimen/px_100"
android:background="@drawable/ic_login_edit_background"
android:hint="CDN域名"
android:imeOptions="actionDone"
android:paddingLeft="@dimen/px_30"
android:paddingRight="@dimen/px_30"
android:singleLine="true"
android:textColor="@color/white"
android:textColorHint="@color/white_50"
android:textSize="@dimen/px_36" />
android:textSize="@dimen/px_36"
android:layout_marginLeft="@dimen/px_30"
android:layout_marginRight="@dimen/px_30" />
</LinearLayout>
</LinearLayout>
2 changes: 2 additions & 0 deletions mybv/res/values/public.xml
Original file line number Diff line number Diff line change
Expand Up @@ -2430,6 +2430,8 @@
<public type="id" name="video_detail_episodes_video" id="0x7f080171" />
<public type="id" name="filter_button" id="0x7f080172" />
<public type="id" name="filter_path" id="0x7f080173" />
<public type="id" name="cdn_button" id="0x7f080174" />
<public type="id" name="cdn_value" id="0x7f080175" />

<public type="integer" name="config_danmaku_fly_duration" id="0x7f090003" />
<public type="integer" name="config_danmaku_max_danmaku_on_screen" id="0x7f090005" />
Expand Down
Loading

0 comments on commit 50c1f08

Please sign in to comment.