Skip to content

Tsa/enhance tv#741

Open
apollotsantos wants to merge 18 commits into
AndreyPavlenko:masterfrom
apollotsantos:tsa/enhance-tv
Open

Tsa/enhance tv#741
apollotsantos wants to merge 18 commits into
AndreyPavlenko:masterfrom
apollotsantos:tsa/enhance-tv

Conversation

@apollotsantos
Copy link
Copy Markdown
Contributor

Better handling of large IPTV playlists + search across categories
I've been using a provider whose M3U has ~500k entries, and the TV addon is pretty rough at that scale: the UI freezes for a minute on load with no feedback, memory usage is silly, and once it's loaded there's no realistic way to find a channel by scrolling through hundreds of categories. This PR is a handful of small changes to fix that.

@apollotsantos
Copy link
Copy Markdown
Contributor Author

This will prevent issues like #702 (comment), where list size is a problem

int totalLines = 0;
// Pool to deduplicate repeating short strings (group names, catchup-source, tvg-id, etc.).
// Drastically cuts heap usage on large Xtream playlists where these fields repeat heavily.
Map<String, String> stringPool = new HashMap<>(4096);
Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why not just using String.intern()?

Comment thread fermata/src/main/java/me/aap/fermata/media/lib/M3uItem.java Outdated
Comment thread modules/tv/src/main/java/me/aap/fermata/addon/tv/TvFragment.java Outdated
Comment thread modules/tv/src/main/java/me/aap/fermata/addon/tv/TvFragment.java Outdated
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR targets usability and reliability issues when loading very large IPTV M3U playlists in the TV addon, and adds a way to search for channels without scrolling through many categories.

Changes:

  • Adds a TV navbar “Search” action that uses SearchFolder to search channels across categories.
  • Adjusts the IPTV response-timeout preference UI and applies a more forgiving timeout default.
  • Adds additional logging and user feedback during M3U loading/parsing to help diagnose slow loads and invalid playlist content.

Reviewed changes

Copilot reviewed 6 out of 6 changed files in this pull request and generated 10 comments.

Show a summary per file
File Description
modules/tv/src/main/res/values/strings.xml Adds strings for timeout hint and TV search messaging.
modules/tv/src/main/java/me/aap/fermata/addon/tv/m3u/TvM3uFileSystemProvider.java Tightens timeout preference bounds and clamps low values to a higher default.
modules/tv/src/main/java/me/aap/fermata/addon/tv/TvFragment.java Adds a navbar search entry and executes a cross-category search via SearchFolder.
fermata/src/main/res/values/ids.xml Adds a new nav_search id for the navbar menu.
fermata/src/main/java/me/aap/fermata/vfs/m3u/M3uFileSystem.java Adds logging around M3U loading/download and cache file usage.
fermata/src/main/java/me/aap/fermata/media/lib/M3uItem.java Adds parsing diagnostics, progress logs, string pooling, and user toasts for large playlists.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread modules/tv/src/main/res/values/strings.xml
Comment thread modules/tv/src/main/java/me/aap/fermata/addon/tv/m3u/TvM3uFileSystemProvider.java Outdated
Comment thread modules/tv/src/main/java/me/aap/fermata/addon/tv/TvFragment.java Outdated
Comment thread fermata/src/main/java/me/aap/fermata/media/lib/M3uItem.java Outdated
Comment thread fermata/src/main/java/me/aap/fermata/media/lib/M3uItem.java Outdated
Comment thread fermata/src/main/java/me/aap/fermata/vfs/m3u/M3uFileSystem.java Outdated
Comment thread fermata/src/main/java/me/aap/fermata/media/lib/M3uItem.java Outdated
Comment thread fermata/src/main/java/me/aap/fermata/media/lib/M3uItem.java Outdated
Comment thread fermata/src/main/java/me/aap/fermata/media/lib/M3uItem.java
apollotsantos and others added 5 commits May 4, 2026 21:16
Co-authored-by: Andrey Pavlenko <andrey.a.pavlenko@gmail.com>
Co-authored-by: Andrey Pavlenko <andrey.a.pavlenko@gmail.com>
Co-authored-by: Andrey Pavlenko <andrey.a.pavlenko@gmail.com>
…back; update TV fragment for better search functionality and adjust response timeout settings.
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 8 out of 8 changed files in this pull request and generated 7 comments.

}

return new InputStreamReader(in, (cs == null) ? "UTF-8" : cs);
return new InputStreamReader(in, (cs == null) ? UTF_8 : java.nio.charset.Charset.forName(cs));
Comment on lines +83 to +84
peekM3uHead(m3uFile);

Comment on lines 269 to 275
} else if ((name == null) || l.startsWith("#")) {
if (name == null && !l.startsWith("#") && !l.isEmpty()) {
skippedNoName++;
if (skippedNoName <= 3) Log.d("Skipped playlist entry with no name");
}
continue;
}
Comment on lines +277 to +285
totalLines++;
VirtualResource file = vfs.resolve(l, dir).get(null);

if (totalLines <= 3) {
Log.d("Resolved playlist URL #", totalLines, ": ", (file != null ? "OK" : "NULL"));
} else if ((totalLines % 25000) == 0) {
Log.i("M3U parse progress: ", totalLines, " entries (",
groups.size(), " groups, ", tracks.size(), " ungrouped tracks)");
}
BrowsableItem parent = parentSupplier.apply(emptyList());
if (parent == null) return completedNull();
String id = SCHEME + q + '@' + parent.getId();
String id = SCHEME + ((name == null) ? "" : name + ':') + q + '@' + parent.getId();
return ((cur == null) || !items.contains(cur)) ? searchParent : cur.getParent();
};

SearchFolder.search(q, getString(R.string.tv_search_title), ps).main(a.getHandler()).onSuccess(f -> {
Comment on lines +221 to +223
int timeout = ps.getIntPref(RESP_TIMEOUT);
if (timeout < 0) timeout = 30;
f.setResponseTimeout(timeout);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants