Skip to content

Commit

Permalink
[Modify/Add] Update Channel Source And Some Refactoring
Browse files Browse the repository at this point in the history
  • Loading branch information
kananinirav committed Aug 15, 2024
1 parent d419156 commit 2ba7518
Show file tree
Hide file tree
Showing 5 changed files with 40 additions and 22 deletions.
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ Watch 500+ live india TV channels with **IPTV Android Application**

## [Download Latest APK From Release](https://github.com/kananinirav/iptv-indian-app/releases/)

- [Mobile APK Download Link](https://github.com/kananinirav/Indian-IPTV-App/releases/download/v2.0.0/iptv-mobile.apk)
- [Android TV APK Download Link](https://github.com/kananinirav/Indian-IPTV-App/releases/download/v2.0.0/iptv-android-tv.apk)
- [Mobile APK Download Link](https://github.com/kananinirav/Indian-IPTV-App/releases/download/v2.1.0/iptv-mobile.apk)
- [Android TV APK Download Link](https://github.com/kananinirav/Indian-IPTV-App/releases/download/v2.1.0/iptv-android-tv.apk)

[**Watch Sports TV Channels Online With SPORTS PULSE TV**](https://sports-tv-channels.click/)

Expand Down Expand Up @@ -44,7 +44,7 @@ Watch 500+ live india TV channels with **IPTV Android Application**

## Credits

[Channel Source](https://github.com/aniketda/iptv2050)
[Channel Source](https://github.com/FunctionError/PiratesTv)

## Star History

Expand Down
Binary file added assets/images/tv-icon.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
46 changes: 32 additions & 14 deletions lib/provider/channels_provider.dart
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ class ChannelsProvider with ChangeNotifier {
List<Channel> channels = [];
List<Channel> filteredChannels = [];
String sourceUrl =
'https://raw.githubusercontent.com/aniketda/iptv2050/main/iptv';
'https://raw.githubusercontent.com/FunctionError/PiratesTv/main/combined_playlist.m3u';

Future<List<Channel>> fetchM3UFile() async {
final response = await http.get(Uri.parse(sourceUrl));
Expand All @@ -16,30 +16,25 @@ class ChannelsProvider with ChangeNotifier {
List<String> lines = fileText.split('\n');

String? name;
String? logoUrl;
String logoUrl = getDefaultLogoUrl();
String? streamUrl;

for (int i = 0; i < lines.length; i++) {
String line = lines[i];
for (String line in lines) {
if (line.startsWith('#EXTINF:')) {
List<String> parts = line.split(',');
name = parts[1];
List<String> logoParts = parts[0].split('"');
logoUrl = logoParts.length > 3
? logoParts[3]
: 'https://fastly.picsum.photos/id/125/536/354.jpg?hmac=EYT3s6VXrAoggrr4fXsOIIcQ3Grc13fCmXkqcE2FusY';
name = extractChannelName(line);
logoUrl = extractLogoUrl(line) ?? getDefaultLogoUrl();
} else if (line.isNotEmpty) {
streamUrl = line;
if (name != null && name.isNotEmpty) {
if (name != null) {
channels.add(Channel(
name: name,
logoUrl: logoUrl ??
'https://fastly.picsum.photos/id/928/200/200.jpg?hmac=5MQxbf-ANcu87ZaOn5sOEObpZ9PpJfrOImdC7yOkBlg',
logoUrl: logoUrl,
streamUrl: streamUrl,
));
}
// Reset for next channel
name = null;
logoUrl = null;
logoUrl = getDefaultLogoUrl();
streamUrl = null;
}
}
Expand All @@ -49,6 +44,29 @@ class ChannelsProvider with ChangeNotifier {
}
}

String getDefaultLogoUrl() {
return 'assets/images/tv-icon.png';
}

String? extractChannelName(String line) {
List<String> parts = line.split(',');
return parts.last;
}

String? extractLogoUrl(String line) {
List<String> parts = line.split('"');
if (parts.length > 1 && isValidUrl(parts[1])) {
return parts[1];
} else if (parts.length > 5 && isValidUrl(parts[5])) {
return parts[5];
}
return null;
}

bool isValidUrl(String url) {
return url.startsWith('https') || url.startsWith('http');
}

List<Channel> filterChannels(String query) {
filteredChannels = channels
.where((channel) =>
Expand Down
4 changes: 2 additions & 2 deletions lib/screens/home.dart
Original file line number Diff line number Diff line change
Expand Up @@ -91,8 +91,8 @@ class _HomeState extends State<Home> {
height: 50,
fit: BoxFit.contain,
errorBuilder: (context, error, stackTrace) {
return Image.network(
'https://fastly.picsum.photos/id/125/536/354.jpg?hmac=EYT3s6VXrAoggrr4fXsOIIcQ3Grc13fCmXkqcE2FusY',
return Image.asset(
'assets/images/tv-icon.png',
width: 50,
height: 50,
fit: BoxFit.contain,
Expand Down
6 changes: 3 additions & 3 deletions pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ publish_to: 'none' # Remove this line if you wish to publish to pub.dev
# https://developer.apple.com/library/archive/documentation/General/Reference/InfoPlistKeyReference/Articles/CoreFoundationKeys.html
# In Windows, build-name is used as the major, minor, and patch parts
# of the product and file versions while build-number is used as the build suffix.
version: 1.1.0+2
version: 2.1.0+3

environment:
sdk: '>=3.2.1 <4.0.0'
Expand Down Expand Up @@ -65,8 +65,8 @@ flutter:
uses-material-design: true

# To add assets to your application, add an assets section, like this:
# assets:
# - assets/images/no-image.png
assets:
- assets/images/tv-icon.png

# An image asset can refer to one or more resolution-specific "variants", see
# https://flutter.dev/assets-and-images/#resolution-aware
Expand Down

0 comments on commit 2ba7518

Please sign in to comment.