Compare commits
4 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
5bd1a2737d | ||
|
|
e3aafd3290 | ||
|
|
b6612c4544 | ||
|
|
df296d7172 |
@@ -8,8 +8,8 @@ android {
|
|||||||
applicationId "com.streamplayer"
|
applicationId "com.streamplayer"
|
||||||
minSdk 21
|
minSdk 21
|
||||||
targetSdk 33
|
targetSdk 33
|
||||||
versionCode 100100
|
versionCode 100500
|
||||||
versionName "10.0.1"
|
versionName "10.0.5"
|
||||||
buildConfigField "String", "DEVICE_REGISTRY_URL", '"http://194.163.191.200:4000"'
|
buildConfigField "String", "DEVICE_REGISTRY_URL", '"http://194.163.191.200:4000"'
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -12,72 +12,72 @@ public final class ChannelRepository {
|
|||||||
|
|
||||||
private static List<StreamChannel> createChannels() {
|
private static List<StreamChannel> createChannels() {
|
||||||
List<StreamChannel> channels = new ArrayList<>(Arrays.asList(
|
List<StreamChannel> channels = new ArrayList<>(Arrays.asList(
|
||||||
new StreamChannel("ESPN", "https://streamtpmedia.com/global2.php?stream=espn"),
|
new StreamChannel("ESPN", "https://streamtpcloud.com/global2.php?stream=espn"),
|
||||||
new StreamChannel("ESPN 2", "https://streamtpmedia.com/global2.php?stream=espn2"),
|
new StreamChannel("ESPN 2", "https://streamtpcloud.com/global2.php?stream=espn2"),
|
||||||
new StreamChannel("ESPN 3", "https://streamtpmedia.com/global2.php?stream=espn3"),
|
new StreamChannel("ESPN 3", "https://streamtpcloud.com/global2.php?stream=espn3"),
|
||||||
new StreamChannel("ESPN 4", "https://streamtpmedia.com/global2.php?stream=espn4"),
|
new StreamChannel("ESPN 4", "https://streamtpcloud.com/global2.php?stream=espn4"),
|
||||||
new StreamChannel("ESPN 3 MX", "https://streamtpmedia.com/global2.php?stream=espn3mx"),
|
new StreamChannel("ESPN 3 MX", "https://streamtpcloud.com/global2.php?stream=espn3mx"),
|
||||||
new StreamChannel("ESPN 5", "https://streamtpmedia.com/global2.php?stream=espn5"),
|
new StreamChannel("ESPN 5", "https://streamtpcloud.com/global2.php?stream=espn5"),
|
||||||
new StreamChannel("Fox Sports 3 MX", "https://streamtpmedia.com/global2.php?stream=foxsports3mx"),
|
new StreamChannel("Fox Sports 3 MX", "https://streamtpcloud.com/global2.php?stream=foxsports3mx"),
|
||||||
new StreamChannel("ESPN 6", "https://streamtpmedia.com/global2.php?stream=espn6"),
|
new StreamChannel("ESPN 6", "https://streamtpcloud.com/global2.php?stream=espn6"),
|
||||||
new StreamChannel("Fox Sports MX", "https://streamtpmedia.com/global2.php?stream=foxsportsmx"),
|
new StreamChannel("Fox Sports MX", "https://streamtpcloud.com/global2.php?stream=foxsportsmx"),
|
||||||
new StreamChannel("ESPN 7", "https://streamtpmedia.com/global2.php?stream=espn7"),
|
new StreamChannel("ESPN 7", "https://streamtpcloud.com/global2.php?stream=espn7"),
|
||||||
new StreamChannel("Azteca Deportes", "https://streamtpmedia.com/global2.php?stream=azteca_deportes"),
|
new StreamChannel("Azteca Deportes", "https://streamtpcloud.com/global2.php?stream=azteca_deportes"),
|
||||||
new StreamChannel("Win Plus", "https://streamtpmedia.com/global2.php?stream=winplus"),
|
new StreamChannel("Win Plus", "https://streamtpcloud.com/global2.php?stream=winplus"),
|
||||||
new StreamChannel("DAZN 1", "https://streamtpmedia.com/global2.php?stream=dazn1"),
|
new StreamChannel("DAZN 1", "https://streamtpcloud.com/global2.php?stream=dazn1"),
|
||||||
new StreamChannel("Win Plus 2", "https://streamtpmedia.com/global2.php?stream=winplus2"),
|
new StreamChannel("Win Plus 2", "https://streamtpcloud.com/global2.php?stream=winplus2"),
|
||||||
new StreamChannel("DAZN 2", "https://streamtpmedia.com/global2.php?stream=dazn2"),
|
new StreamChannel("DAZN 2", "https://streamtpcloud.com/global2.php?stream=dazn2"),
|
||||||
new StreamChannel("Win Sports", "https://streamtpmedia.com/global2.php?stream=winsports"),
|
new StreamChannel("Win Sports", "https://streamtpcloud.com/global2.php?stream=winsports"),
|
||||||
new StreamChannel("DAZN LaLiga", "https://streamtpmedia.com/global2.php?stream=dazn_laliga"),
|
new StreamChannel("DAZN LaLiga", "https://streamtpcloud.com/global2.php?stream=dazn_laliga"),
|
||||||
new StreamChannel("Win Plus Online 1", "https://streamtpmedia.com/global2.php?stream=winplusonline1"),
|
new StreamChannel("Win Plus Online 1", "https://streamtpcloud.com/global2.php?stream=winplusonline1"),
|
||||||
new StreamChannel("Caracol TV", "https://streamtpmedia.com/global2.php?stream=caracoltv"),
|
new StreamChannel("Caracol TV", "https://streamtpcloud.com/global2.php?stream=caracoltv"),
|
||||||
new StreamChannel("Fox 1 AR", "https://streamtpmedia.com/global2.php?stream=fox1ar"),
|
new StreamChannel("Fox 1 AR", "https://streamtpcloud.com/global2.php?stream=fox1ar"),
|
||||||
new StreamChannel("Fox 2 USA", "https://streamtpmedia.com/global2.php?stream=fox_2_usa"),
|
new StreamChannel("Fox 2 USA", "https://streamtpcloud.com/global2.php?stream=fox_2_usa"),
|
||||||
new StreamChannel("Fox 2 AR", "https://streamtpmedia.com/global2.php?stream=fox2ar"),
|
new StreamChannel("Fox 2 AR", "https://streamtpcloud.com/global2.php?stream=fox2ar"),
|
||||||
new StreamChannel("TNT 1 GB", "https://streamtpmedia.com/global2.php?stream=tnt_1_gb"),
|
new StreamChannel("TNT 1 GB", "https://streamtpcloud.com/global2.php?stream=tnt_1_gb"),
|
||||||
new StreamChannel("TNT 2 GB", "https://streamtpmedia.com/global2.php?stream=tnt_2_gb"),
|
new StreamChannel("TNT 2 GB", "https://streamtpcloud.com/global2.php?stream=tnt_2_gb"),
|
||||||
new StreamChannel("Fox 3 AR", "https://streamtpmedia.com/global2.php?stream=fox3ar"),
|
new StreamChannel("Fox 3 AR", "https://streamtpcloud.com/global2.php?stream=fox3ar"),
|
||||||
new StreamChannel("Universo USA", "https://streamtpmedia.com/global2.php?stream=universo_usa"),
|
new StreamChannel("Universo USA", "https://streamtpcloud.com/global2.php?stream=universo_usa"),
|
||||||
new StreamChannel("DSports", "https://streamtpmedia.com/global2.php?stream=dsports"),
|
new StreamChannel("DSports", "https://streamtpcloud.com/global2.php?stream=dsports"),
|
||||||
new StreamChannel("Univision USA", "https://streamtpmedia.com/global2.php?stream=univision_usa"),
|
new StreamChannel("Univision USA", "https://streamtpcloud.com/global2.php?stream=univision_usa"),
|
||||||
new StreamChannel("DSports 2", "https://streamtpmedia.com/global2.php?stream=dsports2"),
|
new StreamChannel("DSports 2", "https://streamtpcloud.com/global2.php?stream=dsports2"),
|
||||||
new StreamChannel("Fox Deportes USA", "https://streamtpmedia.com/global2.php?stream=fox_deportes_usa"),
|
new StreamChannel("Fox Deportes USA", "https://streamtpcloud.com/global2.php?stream=fox_deportes_usa"),
|
||||||
new StreamChannel("DSports Plus", "https://streamtpmedia.com/global2.php?stream=dsportsplus"),
|
new StreamChannel("DSports Plus", "https://streamtpcloud.com/global2.php?stream=dsportsplus"),
|
||||||
new StreamChannel("Fox Sports 2 MX", "https://streamtpmedia.com/global2.php?stream=foxsports2mx"),
|
new StreamChannel("Fox Sports 2 MX", "https://streamtpcloud.com/global2.php?stream=foxsports2mx"),
|
||||||
new StreamChannel("TNT Sports Chile", "https://streamtpmedia.com/global2.php?stream=tntsportschile"),
|
new StreamChannel("TNT Sports Chile", "https://streamtpcloud.com/global2.php?stream=tntsportschile"),
|
||||||
new StreamChannel("Fox Sports Premium", "https://streamtpmedia.com/global2.php?stream=foxsportspremium"),
|
new StreamChannel("Fox Sports Premium", "https://streamtpcloud.com/global2.php?stream=foxsportspremium"),
|
||||||
new StreamChannel("TNT Sports", "https://streamtpmedia.com/global2.php?stream=tntsports"),
|
new StreamChannel("TNT Sports", "https://streamtpcloud.com/global2.php?stream=tntsports"),
|
||||||
new StreamChannel("ESPN MX", "https://streamtpmedia.com/global2.php?stream=espnmx"),
|
new StreamChannel("ESPN MX", "https://streamtpcloud.com/global2.php?stream=espnmx"),
|
||||||
new StreamChannel("ESPN Premium", "https://streamtpmedia.com/global2.php?stream=espnpremium"),
|
new StreamChannel("ESPN Premium", "https://streamtpcloud.com/global2.php?stream=espnpremium"),
|
||||||
new StreamChannel("ESPN 2 MX", "https://streamtpmedia.com/global2.php?stream=espn2mx"),
|
new StreamChannel("ESPN 2 MX", "https://streamtpcloud.com/global2.php?stream=espn2mx"),
|
||||||
new StreamChannel("TyC Sports", "https://streamtpmedia.com/global2.php?stream=tycsports"),
|
new StreamChannel("TyC Sports", "https://streamtpcloud.com/global2.php?stream=tycsports"),
|
||||||
new StreamChannel("TUDN USA", "https://streamtpmedia.com/global2.php?stream=tudn_usa"),
|
new StreamChannel("TUDN USA", "https://streamtpcloud.com/global2.php?stream=tudn_usa"),
|
||||||
new StreamChannel("Telefe", "https://streamtpmedia.com/global2.php?stream=telefe"),
|
new StreamChannel("Telefe", "https://streamtpcloud.com/global2.php?stream=telefe"),
|
||||||
new StreamChannel("TNT 3 GB", "https://streamtpmedia.com/global2.php?stream=tnt_3_gb"),
|
new StreamChannel("TNT 3 GB", "https://streamtpcloud.com/global2.php?stream=tnt_3_gb"),
|
||||||
new StreamChannel("TV Pública", "https://streamtpmedia.com/global2.php?stream=tv_publica"),
|
new StreamChannel("TV Pública", "https://streamtpcloud.com/global2.php?stream=tv_publica"),
|
||||||
new StreamChannel("Fox 1 USA", "https://streamtpmedia.com/global2.php?stream=fox_1_usa"),
|
new StreamChannel("Fox 1 USA", "https://streamtpcloud.com/global2.php?stream=fox_1_usa"),
|
||||||
new StreamChannel("Liga 1 Max", "https://streamtpmedia.com/global2.php?stream=liga1max"),
|
new StreamChannel("Liga 1 Max", "https://streamtpcloud.com/global2.php?stream=liga1max"),
|
||||||
new StreamChannel("Gol TV", "https://streamtpmedia.com/global2.php?stream=goltv"),
|
new StreamChannel("Gol TV", "https://streamtpcloud.com/global2.php?stream=goltv"),
|
||||||
new StreamChannel("VTV Plus", "https://streamtpmedia.com/global2.php?stream=vtvplus"),
|
new StreamChannel("VTV Plus", "https://streamtpcloud.com/global2.php?stream=vtvplus"),
|
||||||
new StreamChannel("ESPN Deportes", "https://streamtpmedia.com/global2.php?stream=espndeportes"),
|
new StreamChannel("ESPN Deportes", "https://streamtpcloud.com/global2.php?stream=espndeportes"),
|
||||||
new StreamChannel("Gol Perú", "https://streamtpmedia.com/global2.php?stream=golperu"),
|
new StreamChannel("Gol Perú", "https://streamtpcloud.com/global2.php?stream=golperu"),
|
||||||
new StreamChannel("TNT 4 GB", "https://streamtpmedia.com/global2.php?stream=tnt_4_gb"),
|
new StreamChannel("TNT 4 GB", "https://streamtpcloud.com/global2.php?stream=tnt_4_gb"),
|
||||||
new StreamChannel("SportTV BR 1", "https://streamtpmedia.com/global2.php?stream=sporttvbr1"),
|
new StreamChannel("SportTV BR 1", "https://streamtpcloud.com/global2.php?stream=sporttvbr1"),
|
||||||
new StreamChannel("SportTV BR 2", "https://streamtpmedia.com/global2.php?stream=sporttvbr2"),
|
new StreamChannel("SportTV BR 2", "https://streamtpcloud.com/global2.php?stream=sporttvbr2"),
|
||||||
new StreamChannel("SportTV BR 3", "https://streamtpmedia.com/global2.php?stream=sporttvbr3"),
|
new StreamChannel("SportTV BR 3", "https://streamtpcloud.com/global2.php?stream=sporttvbr3"),
|
||||||
new StreamChannel("Premiere 1", "https://streamtpmedia.com/global2.php?stream=premiere1"),
|
new StreamChannel("Premiere 1", "https://streamtpcloud.com/global2.php?stream=premiere1"),
|
||||||
new StreamChannel("Premiere 2", "https://streamtpmedia.com/global2.php?stream=premiere2"),
|
new StreamChannel("Premiere 2", "https://streamtpcloud.com/global2.php?stream=premiere2"),
|
||||||
new StreamChannel("Premiere 3", "https://streamtpmedia.com/global2.php?stream=premiere3"),
|
new StreamChannel("Premiere 3", "https://streamtpcloud.com/global2.php?stream=premiere3"),
|
||||||
new StreamChannel("ESPN NL 1", "https://streamtpmedia.com/global2.php?stream=espn_nl1"),
|
new StreamChannel("ESPN NL 1", "https://streamtpcloud.com/global2.php?stream=espn_nl1"),
|
||||||
new StreamChannel("ESPN NL 2", "https://streamtpmedia.com/global2.php?stream=espn_nl2"),
|
new StreamChannel("ESPN NL 2", "https://streamtpcloud.com/global2.php?stream=espn_nl2"),
|
||||||
new StreamChannel("ESPN NL 3", "https://streamtpmedia.com/global2.php?stream=espn_nl3"),
|
new StreamChannel("ESPN NL 3", "https://streamtpcloud.com/global2.php?stream=espn_nl3"),
|
||||||
new StreamChannel("Caliente TV MX", "https://streamtpmedia.com/global2.php?stream=calientetvmx"),
|
new StreamChannel("Caliente TV MX", "https://streamtpcloud.com/global2.php?stream=calientetvmx"),
|
||||||
new StreamChannel("USA Network", "https://streamtpmedia.com/global2.php?stream=usa_network"),
|
new StreamChannel("USA Network", "https://streamtpcloud.com/global2.php?stream=usa_network"),
|
||||||
new StreamChannel("TyC Internacional", "https://streamtpmedia.com/global2.php?stream=tycinternacional"),
|
new StreamChannel("TyC Internacional", "https://streamtpcloud.com/global2.php?stream=tycinternacional"),
|
||||||
new StreamChannel("Canal 5 MX", "https://streamtpmedia.com/global2.php?stream=canal5mx"),
|
new StreamChannel("Canal 5 MX", "https://streamtpcloud.com/global2.php?stream=canal5mx"),
|
||||||
new StreamChannel("TUDN MX", "https://streamtpmedia.com/global2.php?stream=TUDNMX"),
|
new StreamChannel("TUDN MX", "https://streamtpcloud.com/global2.php?stream=TUDNMX"),
|
||||||
new StreamChannel("FUTV", "https://streamtpmedia.com/global2.php?stream=futv"),
|
new StreamChannel("FUTV", "https://streamtpcloud.com/global2.php?stream=futv"),
|
||||||
new StreamChannel("LaLiga Hypermotion", "https://streamtpmedia.com/global2.php?stream=laligahypermotion")
|
new StreamChannel("LaLiga Hypermotion", "https://streamtpcloud.com/global2.php?stream=laligahypermotion")
|
||||||
));
|
));
|
||||||
channels.sort(Comparator.comparing(StreamChannel::getName, String.CASE_INSENSITIVE_ORDER));
|
channels.sort(Comparator.comparing(StreamChannel::getName, String.CASE_INSENSITIVE_ORDER));
|
||||||
return Collections.unmodifiableList(channels);
|
return Collections.unmodifiableList(channels);
|
||||||
|
|||||||
@@ -30,7 +30,7 @@ public class EventRepository {
|
|||||||
private static final String KEY_JSON = "json";
|
private static final String KEY_JSON = "json";
|
||||||
private static final String KEY_TIMESTAMP = "timestamp";
|
private static final String KEY_TIMESTAMP = "timestamp";
|
||||||
private static final long CACHE_DURATION = 24L * 60 * 60 * 1000; // 24 horas
|
private static final long CACHE_DURATION = 24L * 60 * 60 * 1000; // 24 horas
|
||||||
private static final String EVENTS_URL = "https://streamtpmedia.com/eventos.json";
|
private static final String EVENTS_URL = "https://streamtpcloud.com/eventos.json";
|
||||||
|
|
||||||
public interface Callback {
|
public interface Callback {
|
||||||
void onSuccess(List<EventItem> events);
|
void onSuccess(List<EventItem> events);
|
||||||
@@ -89,7 +89,8 @@ public class EventRepository {
|
|||||||
}
|
}
|
||||||
|
|
||||||
String contentType = connection.getContentType();
|
String contentType = connection.getContentType();
|
||||||
if (contentType != null && !contentType.contains("json")) {
|
// Permitir json o text/plain (Raw de Gitea a veces es text/plain)
|
||||||
|
if (contentType != null && !contentType.contains("json") && !contentType.contains("text/plain")) {
|
||||||
throw new IOException("El servidor devolvió " + contentType + " en lugar de JSON. Verifica que la URL sea correcta.");
|
throw new IOException("El servidor devolvió " + contentType + " en lugar de JSON. Verifica que la URL sea correcta.");
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -144,7 +145,8 @@ public class EventRepository {
|
|||||||
if (link == null) {
|
if (link == null) {
|
||||||
return "";
|
return "";
|
||||||
}
|
}
|
||||||
return link.replace("global1.php", "global2.php");
|
String updated = link.replace("streamtpmedia.com", "streamtpcloud.com");
|
||||||
|
return updated.replace("global1.php", "global2.php");
|
||||||
}
|
}
|
||||||
|
|
||||||
private String extractChannelName(String link) {
|
private String extractChannelName(String link) {
|
||||||
|
|||||||
@@ -177,7 +177,7 @@ public class PlayerActivity extends AppCompatActivity {
|
|||||||
private MediaSource buildMediaSource(MediaItem mediaItem) {
|
private MediaSource buildMediaSource(MediaItem mediaItem) {
|
||||||
Map<String, String> headers = new HashMap<>();
|
Map<String, String> headers = new HashMap<>();
|
||||||
headers.put("Referer", channelUrl);
|
headers.put("Referer", channelUrl);
|
||||||
headers.put("Origin", "https://streamtpmedia.com");
|
headers.put("Origin", "https://streamtpcloud.com");
|
||||||
headers.put("Accept", "*/*");
|
headers.put("Accept", "*/*");
|
||||||
headers.put("Connection", "keep-alive");
|
headers.put("Connection", "keep-alive");
|
||||||
|
|
||||||
@@ -203,10 +203,10 @@ public class PlayerActivity extends AppCompatActivity {
|
|||||||
|
|
||||||
DnsOverHttps dohDns = new DnsOverHttps.Builder()
|
DnsOverHttps dohDns = new DnsOverHttps.Builder()
|
||||||
.client(bootstrap)
|
.client(bootstrap)
|
||||||
.url(HttpUrl.get("https://dns.adguard-dns.com/dns-query"))
|
.url(HttpUrl.get("https://dns.google/dns-query"))
|
||||||
.bootstrapDnsHosts(
|
.bootstrapDnsHosts(
|
||||||
InetAddress.getByName("94.140.14.14"),
|
InetAddress.getByName("8.8.8.8"),
|
||||||
InetAddress.getByName("94.140.15.15"))
|
InetAddress.getByName("8.8.4.4"))
|
||||||
.build();
|
.build();
|
||||||
|
|
||||||
okHttpClient = bootstrap.newBuilder()
|
okHttpClient = bootstrap.newBuilder()
|
||||||
|
|||||||
@@ -1,149 +1,94 @@
|
|||||||
package com.streamplayer;
|
package com.streamplayer;
|
||||||
|
|
||||||
import android.util.Base64;
|
|
||||||
|
|
||||||
import java.io.BufferedReader;
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.io.InputStreamReader;
|
import java.net.InetAddress;
|
||||||
import java.net.HttpURLConnection;
|
import java.net.UnknownHostException;
|
||||||
import java.net.URL;
|
import java.util.concurrent.TimeUnit;
|
||||||
import java.nio.charset.StandardCharsets;
|
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.Collections;
|
|
||||||
import java.util.Comparator;
|
|
||||||
import java.util.List;
|
|
||||||
import java.util.regex.Matcher;
|
import java.util.regex.Matcher;
|
||||||
import java.util.regex.Pattern;
|
import java.util.regex.Pattern;
|
||||||
|
|
||||||
|
import okhttp3.HttpUrl;
|
||||||
|
import okhttp3.OkHttpClient;
|
||||||
|
import okhttp3.Request;
|
||||||
|
import okhttp3.Response;
|
||||||
|
import okhttp3.dnsoverhttps.DnsOverHttps;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Resuelve la URL real del stream analizando el JavaScript ofuscado de streamtpmedia.
|
* Resuelve la URL real del stream extrayendo playbackURL de la página.
|
||||||
|
* Utiliza DNS de Google para evitar bloqueos.
|
||||||
*/
|
*/
|
||||||
public final class StreamUrlResolver {
|
public final class StreamUrlResolver {
|
||||||
|
|
||||||
private static final Pattern ARRAY_NAME_PATTERN =
|
// Patrón para extraer la URL del stream directamente
|
||||||
Pattern.compile("var\\s+playbackURL\\s*=\\s*\"\"\\s*,\\s*([A-Za-z0-9]+)\\s*=\\s*\\[\\]");
|
private static final Pattern PLAYBACK_URL_PATTERN =
|
||||||
private static final Pattern ENTRY_PATTERN = Pattern.compile("\\[(\\d+),\"([A-Za-z0-9+/=]+)\"\\]");
|
Pattern.compile("var\\s+playbackURL\\s*=\\s*[\"']([^\"']+)[\"']");
|
||||||
private static final Pattern KEY_FUNCTIONS_PATTERN = Pattern.compile("var\\s+k=(\\w+)\\(\\)\\+(\\w+)\\(\\);");
|
|
||||||
private static final String FUNCTION_TEMPLATE = "function\\s+%s\\(\\)\\s*\\{\\s*return\\s+(\\d+);\\s*\\}";
|
private static final String USER_AGENT = "Mozilla/5.0 (Linux; Android 13; Pixel 7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/120.0.0.0 Mobile Safari/537.36";
|
||||||
private static final String USER_AGENT = "Mozilla/5.0 (Linux; Android 13) ExoPlayerResolver/1.0";
|
|
||||||
|
private static final OkHttpClient CLIENT;
|
||||||
|
|
||||||
|
static {
|
||||||
|
OkHttpClient.Builder builder = new OkHttpClient.Builder()
|
||||||
|
.connectTimeout(15, TimeUnit.SECONDS)
|
||||||
|
.readTimeout(15, TimeUnit.SECONDS)
|
||||||
|
.followRedirects(true);
|
||||||
|
|
||||||
|
try {
|
||||||
|
// DNS de Google (8.8.8.8)
|
||||||
|
OkHttpClient bootstrap = new OkHttpClient.Builder().build();
|
||||||
|
DnsOverHttps dns = new DnsOverHttps.Builder()
|
||||||
|
.client(bootstrap)
|
||||||
|
.url(HttpUrl.get("https://dns.google/dns-query"))
|
||||||
|
.bootstrapDnsHosts(
|
||||||
|
InetAddress.getByName("8.8.8.8"),
|
||||||
|
InetAddress.getByName("8.8.4.4"))
|
||||||
|
.build();
|
||||||
|
builder.dns(dns);
|
||||||
|
} catch (UnknownHostException e) {
|
||||||
|
// Fallback a DNS del sistema
|
||||||
|
}
|
||||||
|
|
||||||
|
CLIENT = builder.build();
|
||||||
|
}
|
||||||
|
|
||||||
private StreamUrlResolver() {
|
private StreamUrlResolver() {
|
||||||
}
|
}
|
||||||
|
|
||||||
public static String resolve(String pageUrl) throws IOException {
|
public static String resolve(String pageUrl) throws IOException {
|
||||||
String html = downloadPage(pageUrl);
|
String html = downloadPage(pageUrl);
|
||||||
long keyOffset = extractKeyOffset(html);
|
|
||||||
List<Entry> entries = extractEntries(html);
|
// Buscar playbackURL directamente en el HTML
|
||||||
if (entries.isEmpty()) {
|
Matcher matcher = PLAYBACK_URL_PATTERN.matcher(html);
|
||||||
throw new IOException("No se pudieron obtener los fragmentos del stream");
|
if (matcher.find()) {
|
||||||
}
|
String url = matcher.group(1);
|
||||||
|
if (url != null && !url.isEmpty() && url.startsWith("http")) {
|
||||||
StringBuilder builder = new StringBuilder();
|
return url;
|
||||||
for (Entry entry : entries) {
|
|
||||||
String decoded = new String(Base64.decode(entry.encoded, Base64.DEFAULT), StandardCharsets.UTF_8);
|
|
||||||
String numeric = decoded.replaceAll("\\D+", "");
|
|
||||||
if (numeric.isEmpty()) {
|
|
||||||
continue;
|
|
||||||
}
|
}
|
||||||
long value = Long.parseLong(numeric) - keyOffset;
|
|
||||||
builder.append((char) value);
|
|
||||||
}
|
}
|
||||||
String url = builder.toString();
|
|
||||||
if (url.isEmpty()) {
|
// Si no encontramos la URL, mostrar un fragmento del HTML para debug
|
||||||
throw new IOException("No se pudo reconstruir la URL del stream");
|
String preview = html.length() > 500 ? html.substring(0, 500) : html;
|
||||||
}
|
throw new IOException("No se encontró la URL del stream en la página. Vista previa: " + preview);
|
||||||
return url;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private static String downloadPage(String pageUrl) throws IOException {
|
private static String downloadPage(String pageUrl) throws IOException {
|
||||||
HttpURLConnection connection = (HttpURLConnection) new URL(pageUrl).openConnection();
|
Request request = new Request.Builder()
|
||||||
connection.setConnectTimeout(15000);
|
.url(pageUrl)
|
||||||
connection.setReadTimeout(15000);
|
.header("User-Agent", USER_AGENT)
|
||||||
connection.setRequestProperty("User-Agent", USER_AGENT);
|
.header("Accept", "text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8")
|
||||||
connection.setRequestProperty("Accept", "text/html,application/xhtml+xml");
|
.header("Accept-Language", "es-ES,es;q=0.9,en;q=0.8")
|
||||||
|
.header("Referer", "https://streamtpcloud.com/")
|
||||||
try {
|
.build();
|
||||||
int responseCode = connection.getResponseCode();
|
|
||||||
if (responseCode != HttpURLConnection.HTTP_OK) {
|
try (Response response = CLIENT.newCall(request).execute()) {
|
||||||
throw new IOException("Error HTTP " + responseCode + " al cargar la página del stream");
|
if (!response.isSuccessful()) {
|
||||||
|
throw new IOException("Error HTTP " + response.code() + " al cargar la página del stream");
|
||||||
|
}
|
||||||
|
if (response.body() == null) {
|
||||||
|
throw new IOException("Respuesta vacía del servidor");
|
||||||
}
|
}
|
||||||
|
|
||||||
String contentType = connection.getContentType();
|
return response.body().string();
|
||||||
// Validar que sea contenido web (HTML)
|
|
||||||
if (contentType != null && !contentType.contains("html") && !contentType.contains("text")) {
|
|
||||||
// A veces puede venir sin content type o application/octet-stream,
|
|
||||||
// pero si es explícitamente una imagen o algo así, abortamos.
|
|
||||||
if (contentType.startsWith("image/") || contentType.startsWith("video/") || contentType.startsWith("audio/")) {
|
|
||||||
throw new IOException("El servidor devolvió " + contentType + " en lugar de HTML");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
try (BufferedReader reader = new BufferedReader(
|
|
||||||
new InputStreamReader(connection.getInputStream(), StandardCharsets.UTF_8))) {
|
|
||||||
StringBuilder builder = new StringBuilder();
|
|
||||||
String line;
|
|
||||||
while ((line = reader.readLine()) != null) {
|
|
||||||
builder.append(line);
|
|
||||||
}
|
|
||||||
return builder.toString();
|
|
||||||
}
|
|
||||||
} finally {
|
|
||||||
connection.disconnect();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private static long extractKeyOffset(String html) throws IOException {
|
|
||||||
Matcher matcher = KEY_FUNCTIONS_PATTERN.matcher(html);
|
|
||||||
if (!matcher.find()) {
|
|
||||||
throw new IOException("No se encontró la clave del stream");
|
|
||||||
}
|
|
||||||
String first = matcher.group(1);
|
|
||||||
String second = matcher.group(2);
|
|
||||||
long firstVal = extractReturnValue(html, first);
|
|
||||||
long secondVal = extractReturnValue(html, second);
|
|
||||||
return firstVal + secondVal;
|
|
||||||
}
|
|
||||||
|
|
||||||
private static long extractReturnValue(String html, String functionName) throws IOException {
|
|
||||||
Pattern functionPattern = Pattern.compile(
|
|
||||||
String.format(FUNCTION_TEMPLATE, Pattern.quote(functionName)));
|
|
||||||
Matcher matcher = functionPattern.matcher(html);
|
|
||||||
if (!matcher.find()) {
|
|
||||||
throw new IOException("No se encontró el valor de la función " + functionName);
|
|
||||||
}
|
|
||||||
return Long.parseLong(matcher.group(1));
|
|
||||||
}
|
|
||||||
|
|
||||||
private static List<Entry> extractEntries(String html) throws IOException {
|
|
||||||
Matcher arrayNameMatcher = ARRAY_NAME_PATTERN.matcher(html);
|
|
||||||
if (!arrayNameMatcher.find()) {
|
|
||||||
throw new IOException("No se detectó la variable del arreglo de fragmentos");
|
|
||||||
}
|
|
||||||
String arrayName = arrayNameMatcher.group(1);
|
|
||||||
Pattern arrayPattern = Pattern.compile(Pattern.quote(arrayName) + "=\\[(.*?)\\];", Pattern.DOTALL);
|
|
||||||
Matcher matcher = arrayPattern.matcher(html);
|
|
||||||
if (!matcher.find()) {
|
|
||||||
throw new IOException("No se encontró el arreglo de fragmentos");
|
|
||||||
}
|
|
||||||
String rawEntries = matcher.group(1);
|
|
||||||
Matcher entryMatcher = ENTRY_PATTERN.matcher(rawEntries);
|
|
||||||
List<Entry> entries = new ArrayList<>();
|
|
||||||
while (entryMatcher.find()) {
|
|
||||||
int index = Integer.parseInt(entryMatcher.group(1));
|
|
||||||
String encoded = entryMatcher.group(2);
|
|
||||||
entries.add(new Entry(index, encoded));
|
|
||||||
}
|
|
||||||
Collections.sort(entries, Comparator.comparingInt(e -> e.index));
|
|
||||||
return entries;
|
|
||||||
}
|
|
||||||
|
|
||||||
private static final class Entry {
|
|
||||||
final int index;
|
|
||||||
final String encoded;
|
|
||||||
|
|
||||||
Entry(int index, String encoded) {
|
|
||||||
this.index = index;
|
|
||||||
this.encoded = encoded;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -45,6 +45,7 @@ public class UpdateManager {
|
|||||||
private static final String TAG = "UpdateManager";
|
private static final String TAG = "UpdateManager";
|
||||||
private static final String LATEST_RELEASE_URL =
|
private static final String LATEST_RELEASE_URL =
|
||||||
"https://gitea.cbcren.online/api/v1/repos/renato97/app/releases/latest";
|
"https://gitea.cbcren.online/api/v1/repos/renato97/app/releases/latest";
|
||||||
|
private static final String GITEA_TOKEN = "4b94b3610136529861af0821040a801906821a0f";
|
||||||
|
|
||||||
private final Context appContext;
|
private final Context appContext;
|
||||||
private final Handler mainHandler;
|
private final Handler mainHandler;
|
||||||
@@ -74,6 +75,7 @@ public class UpdateManager {
|
|||||||
try {
|
try {
|
||||||
Request request = new Request.Builder()
|
Request request = new Request.Builder()
|
||||||
.url(LATEST_RELEASE_URL)
|
.url(LATEST_RELEASE_URL)
|
||||||
|
.header("Authorization", "token " + GITEA_TOKEN)
|
||||||
.get()
|
.get()
|
||||||
.build();
|
.build();
|
||||||
try (Response response = httpClient.newCall(request).execute()) {
|
try (Response response = httpClient.newCall(request).execute()) {
|
||||||
@@ -247,7 +249,11 @@ public class UpdateManager {
|
|||||||
if (TextUtils.isEmpty(url)) {
|
if (TextUtils.isEmpty(url)) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
Request request = new Request.Builder().url(url).get().build();
|
Request request = new Request.Builder()
|
||||||
|
.url(url)
|
||||||
|
.header("Authorization", "token " + GITEA_TOKEN)
|
||||||
|
.get()
|
||||||
|
.build();
|
||||||
try (Response response = httpClient.newCall(request).execute()) {
|
try (Response response = httpClient.newCall(request).execute()) {
|
||||||
if (!response.isSuccessful() || response.body() == null) {
|
if (!response.isSuccessful() || response.body() == null) {
|
||||||
continue;
|
continue;
|
||||||
|
|||||||
16
eventos.json
Normal file
16
eventos.json
Normal file
@@ -0,0 +1,16 @@
|
|||||||
|
[
|
||||||
|
{
|
||||||
|
"title": "Partido de Prueba",
|
||||||
|
"time": "22:00",
|
||||||
|
"category": "Fútbol",
|
||||||
|
"status": "EN VIVO",
|
||||||
|
"link": "https://streamtpmedia.com/global2.php?stream=espn"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"title": "Canal Deportivo",
|
||||||
|
"time": "15:30",
|
||||||
|
"category": "Deportes",
|
||||||
|
"status": "PRÓXIMO",
|
||||||
|
"link": "https://streamtpmedia.com/global2.php?stream=foxsports"
|
||||||
|
}
|
||||||
|
]
|
||||||
@@ -1,10 +1,10 @@
|
|||||||
{
|
{
|
||||||
"versionCode": 100100,
|
"versionCode": 100300,
|
||||||
"versionName": "10.0.1",
|
"versionName": "10.0.3",
|
||||||
"minSupportedVersionCode": 91000,
|
"minSupportedVersionCode": 91000,
|
||||||
"forceUpdate": false,
|
"forceUpdate": false,
|
||||||
"downloadUrl": "https://gitea.cbcren.online/attachments/83b72799-b731-4a48-ad04-67b75eaa78a7",
|
"downloadUrl": "https://gitea.cbcren.online/renato97/app/releases/download/v10.0.3/StreamPlayer-v10.0.3.apk",
|
||||||
"fileName": "StreamPlayer-v10.0.1.apk",
|
"fileName": "StreamPlayer-v10.0.3.apk",
|
||||||
"sizeBytes": 16674,
|
"sizeBytes": 0,
|
||||||
"notes": "StreamPlayer v10.0.1\n\nCorrecciones de errores:\n- Fix: Crash on HTML response in EventRepository\n- Fix: HTML validation in UpdateManager/DeviceRegistry\n- Fix: HTTP error handling in StreamUrlResolver\n\nVersión anterior v10.0:\n- Nueva versión mayor\n- Sistema de actualizaciones automáticas activado"
|
"notes": "StreamPlayer v10.0.3\n\nNovedades:\n- Fix: Evasión de bloqueos regionales mediante DNS de Google (DoH)\n- Corrección de error 'No se encontró la clave del stream'"
|
||||||
}
|
}
|
||||||
Reference in New Issue
Block a user