Skip to content

Commit

Permalink
Added response timeout option for TV playlists
Browse files Browse the repository at this point in the history
  • Loading branch information
AndreyPavlenko committed Sep 30, 2023
1 parent 522c66f commit 4345a93
Show file tree
Hide file tree
Showing 5 changed files with 19 additions and 2 deletions.
9 changes: 9 additions & 0 deletions fermata/src/main/java/me/aap/fermata/vfs/m3u/M3uFile.java
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
import static me.aap.utils.net.http.HttpFileDownloader.CHARSET;
import static me.aap.utils.net.http.HttpFileDownloader.ENCODING;
import static me.aap.utils.net.http.HttpFileDownloader.MAX_AGE;
import static me.aap.utils.net.http.HttpFileDownloader.RESP_TIMEOUT;
import static me.aap.utils.text.TextUtils.isInt;
import static me.aap.utils.text.TextUtils.trim;

Expand Down Expand Up @@ -103,6 +104,14 @@ public void setUserAgent(String agent) {
getPrefs().applyStringPref(AGENT, trim(agent));
}

public int getResponseTimeout() {
return getPrefs().getIntPref(RESP_TIMEOUT);
}

public void setResponseTimeout(int timeout) {
getPrefs().applyIntPref(RESP_TIMEOUT, timeout);
}

@NonNull
@Override
public Rid getRid() {
Expand Down
1 change: 0 additions & 1 deletion fermata/src/main/res/values-ru/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -229,7 +229,6 @@
<string name="m3u_playlist_name">Название</string>
<string name="m3u_playlist_location">Расположение</string>
<string name="m3u_playlist_location_hint">Файл или http(s) URL</string>
<string name="m3u_playlist_agent" translatable="false">User-Agent</string>
<string name="m3u_playlist_video">Видео плейлист</string>

<string name="eq_manual">Ручные</string>
Expand Down
1 change: 0 additions & 1 deletion fermata/src/main/res/values-tr/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,6 @@
<string name="lang">Diller</string>
<string name="loading">Yükleniyor…</string>
<string name="m3u_playlist">M3U oynatma listesi</string>
<string name="m3u_playlist_agent">User-Agent</string>
<string name="m3u_playlist_location">Konum</string>
<string name="m3u_playlist_location_hint">"Dosya veya Http URL'si"</string>
<string name="m3u_playlist_name">Adı</string>
Expand Down
1 change: 1 addition & 0 deletions fermata/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -258,6 +258,7 @@
<string name="m3u_playlist_location">Location</string>
<string name="m3u_playlist_location_hint">File or http(s) URL</string>
<string name="m3u_playlist_agent" translatable="false">User-Agent</string>
<string name="m3u_playlist_timeout" translatable="false">Response timeout</string>
<string name="m3u_playlist_video">Video playlist</string>

<string name="eq_manual">Manual</string>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
import static me.aap.fermata.vfs.m3u.M3uFile.URL;
import static me.aap.utils.async.Completed.completedNull;
import static me.aap.utils.net.http.HttpFileDownloader.AGENT;
import static me.aap.utils.net.http.HttpFileDownloader.RESP_TIMEOUT;

import java.util.List;
import java.util.Objects;
Expand All @@ -26,6 +27,7 @@
import me.aap.fermata.vfs.m3u.M3uFileSystemProvider;
import me.aap.utils.async.FutureSupplier;
import me.aap.utils.log.Log;
import me.aap.utils.net.http.HttpFileDownloader;
import me.aap.utils.pref.BasicPreferenceStore;
import me.aap.utils.pref.PrefCondition;
import me.aap.utils.pref.PreferenceSet;
Expand Down Expand Up @@ -65,6 +67,7 @@ public FutureSupplier<Boolean> edit(MainActivityDelegate a, TvM3uFile f) {
e.setStringPref(CATCHUP_QUERY, f.getCatchupQuery());
e.setStringPref(LOGO_URL, f.getLogoUrl());
e.setStringPref(AGENT, f.getUserAgent());
e.setIntPref(RESP_TIMEOUT, f.getResponseTimeout());
}

return requestPrefs(a, ps).thenRun(ps::removeBroadcastListeners).map(ok -> {
Expand Down Expand Up @@ -170,6 +173,11 @@ private FutureSupplier<Boolean> requestPrefs(MainActivityDelegate a, PreferenceS
o.title = me.aap.fermata.R.string.m3u_playlist_agent;
o.stringHint = "Fermata/" + BuildConfig.VERSION_NAME;
});
sub.addIntPref(o -> {
o.store = ps;
o.pref = RESP_TIMEOUT;
o.title = me.aap.fermata.R.string.m3u_playlist_timeout;
});

return requestPrefs(a, prefs, ps);
}
Expand Down Expand Up @@ -206,6 +214,7 @@ protected void setPrefs(PreferenceStore ps, M3uFile m3u) {
f.setLogoUrl(ps.getStringPref(LOGO_URL));
f.setPreferEpgLogo(ps.getBooleanPref(LOGO_PREFER_EPG));
f.setEpgMaxAge(EPG_FILE_AGE);
f.setResponseTimeout(ps.getIntPref(RESP_TIMEOUT));
}

public static void removeSource(TvM3uFile f) {
Expand Down

0 comments on commit 4345a93

Please sign in to comment.