Android Question Fastest way to grab text from. URL and split it?

Dustin Tinsley

Member
Licensed User
Longtime User
I am attempting to create a small IPTV client. The client will download the IPTV channel list (a m3u file) for channel access. I need to find the fastest way to download the m3u file (right now I am using OkHttpUtils2) and then to split the data into "categories". An example of the m3u is below. I am looking for the most effective way to split this data as such:

Group Title
- Channel Name
- Video source

So, I for example, I would have:

*Sports
-Sky Sports Cricket HD
-http://video.source.com/play/2479.ts?token=***token***
-Sky Sports Action HD
-http://video.source.com/play/2480.ts?token=***token***
-Sky Sports Golf HD
-http://video.source.com/play/2481.ts?token=***token***
*United States
-FOX HD
-http://video.source.com/play/2448.ts?token=***token***
*Premium Movies
-HDNet Movies HD
-http://video.source.com/play/74791.ts?token=***token***


The below is just a snippet of the channel list. The actual list can range from a small amount of channels to 1000+ channels...

B4X:
#EXTM3U

#EXTINF:-1 catchup="default" catchup-source="http://video.source.com/play/dvr/${start}/2479.ts?token=***token***&duration=3600" catchup-days=511206 tvg-name="Sky Sports Cricket HD" tvg-id="SkySportsCricket.uk" tvg-logo="http://logo.source/logos/sky%20sports%20cricket%20hd.png" group-title="Sports",Sky Sports Cricket HD
http://video.source.com/play/2479.ts?token=***token***

#EXTINF:-1 catchup="default" catchup-source="http://video.source.com/play/dvr/${start}/2480.ts?token=***token***&duration=3600" catchup-days=511208 tvg-name="Sky Sports Action HD" tvg-id="SkySportsAction.uk" tvg-logo="http://logo.source/logos/sky%20sports%20action%20hd.png" group-title="Sports",Sky Sports Action HD
http://video.source.com/play/2480.ts?token=***token***

#EXTINF:-1 catchup="default" catchup-source="http://video.source.com/play/dvr/${start}/2481.ts?token=***token***&duration=3600" catchup-days=507609 tvg-name="Sky Sports Golf HD" tvg-id="SkySportsGolf.uk" tvg-logo="http://logo.source/logos/sky%20sports%20golf%20hd.png" group-title="Sports",Sky Sports Golf HD
http://video.source.com/play/2481.ts?token=***token***

#EXTINF:-1 catchup="default" catchup-source="http://video.source.com/play/dvr/${start}/2448.ts?token=***token***&duration=3600" catchup-days=507594 tvg-name="FOX HD" tvg-id="I398.11746.schedulesdirect.org" tvg-logo="http://logo.source/logos/usa%20fox%20hd.png" group-title="United States",FOX HD
http://video.source.com/play/2448.ts?token=***token***

#EXTINF:-1 tvg-name="HDNet Movies HD" tvg-id="I566.33668.schedulesdirect.org" tvg-logo="http://logo.source/logos/hdnet%20movies.png" group-title="Premium Movies",HDNet Movies HD
http://video.source.com/play/74791.ts?token=***token***
 

MarkusR

Well-Known Member
Licensed User
Longtime User
I need to find the fastest way to download the m3u file
maybe with a proxy server usage, it would cache the file if it stay constant.

i would try to spilt the file into "rows" (split by#EXTINF) and then process each "row" and split it into columns with some little helper functions.
something like
B4X:
Data.Catchup=Read(line,"catchup")
..=Read(line,"catchup-source")
..=Read(line,"tvg-name")
the result you put into a "Type"
this data you can put into a List.
 
Upvote 0
Top