Skip to content

Commit

Permalink
added flixhq movies from another api
Browse files Browse the repository at this point in the history
  • Loading branch information
BeamlakAschalew committed Dec 4, 2023
1 parent ebdb08b commit 40641d9
Show file tree
Hide file tree
Showing 9 changed files with 152 additions and 5 deletions.
10 changes: 10 additions & 0 deletions lib/api/endpoints.dart
Original file line number Diff line number Diff line change
Expand Up @@ -414,4 +414,14 @@ class Endpoints {
String baseUrl, String episodeId, String server) {
return '$baseUrl' 'anime/zoro/watch?episodeId=$episodeId&server=$server';
}

static String getMovieLinksFlixHQFQ(String baseUrl, int tmdbId) {
return '$baseUrl' 'flixhq/watch-movie?tmdbId=$tmdbId';
}

static String getTVLinksFlixHQFQ(
String baseUrl, int episode, int season, int tmdbId) {
return '$baseUrl'
'flixhq/watch-tv?tmdbId=$tmdbId&season=$season&episode=$episode';
}
}
7 changes: 4 additions & 3 deletions lib/constants/app_constants.dart
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ const kTextSmallAboutBodyStyle = TextStyle(
const kTableLeftStyle =
TextStyle(overflow: TextOverflow.ellipsis, fontWeight: FontWeight.bold);

const String currentAppVersion = '2.5.0-2';
const String currentAppVersion = '2.5.0-3';

final client = HttpClient();
const retryOptions = RetryOptions(
Expand All @@ -58,7 +58,8 @@ final List<String> appNames = [
'flixquest-v2.4.3.apk',
'flixquest-v2.4.4.apk',
'flixquest-v2.5.0.apk',
'flixquest-v2.5.0-2.apk'
'flixquest-v2.5.0-2.apk',
'flixquest-v2.5.0-3.apk'
];

CacheManager cacheProp() {
Expand All @@ -80,6 +81,6 @@ class MyHttpOverrides extends HttpOverrides {
}

const providerPreference =
'superstream-Superstream flixhq-FlixHQ viewasian-ViewAsian dramacool-Dramacool zoro-Zoro ';
'flixhqS2-FlixHQ_S2 superstream-Superstream flixhq-FlixHQ viewasian-ViewAsian dramacool-Dramacool zoro-Zoro ';

late SharedPreferences sharedPrefsSingleton;
27 changes: 27 additions & 0 deletions lib/functions/network.dart
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import 'package:flixquest/video_providers/flixhq.dart';
import '../models/external_subtitles.dart';
import '../constants/app_constants.dart';
import '../video_providers/dramacool.dart';
import '../video_providers/flixhq_flixquest.dart';
import '../video_providers/superstream.dart';
import '../video_providers/zoro.dart';
import '/models/update.dart';
Expand Down Expand Up @@ -738,3 +739,29 @@ Future<ZoroStreamSources> getMovieTVStreamLinksAndSubsZoro(String api) async {
}
return zoroVideoSources;
}

Future<FlixHQFlixQuestSources> getFlixHQFlixQuestLinks(String api) async {
FlixHQFlixQuestSources fqstreamSources;
int tries = 5;
dynamic decodeRes;
try {
dynamic res;
while (tries > 0) {
res = await retryOptions.retry(
(() => http.get(Uri.parse(api)).timeout(timeOut)),
retryIf: (e) => e is SocketException || e is TimeoutException,
);
decodeRes = jsonDecode(res.body);
if (decodeRes.containsKey('message')) {
--tries;
} else {
break;
}
}

fqstreamSources = FlixHQFlixQuestSources.fromJson(decodeRes);
} finally {
client.close();
}
return fqstreamSources;
}
2 changes: 1 addition & 1 deletion lib/models/setting_preferences.dart
Original file line number Diff line number Diff line change
Expand Up @@ -203,7 +203,7 @@ class AppColorPreferences {
}

class ProviderPrecedencePreference {
static const PROVIDER_PRECEDENCE = "providerPrecedence-v2";
static const PROVIDER_PRECEDENCE = "providerPrecedence-v3";

setProviderPrecedence(String pre) async {
sharedPrefsSingleton.setString(PROVIDER_PRECEDENCE, pre);
Expand Down
10 changes: 10 additions & 0 deletions lib/screens/common/server_status_screen.dart
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,16 @@ class _ServerStatusScreenState extends State<ServerStatusScreen> {
videoLinks = zoroStreamSources!.videoLinks;
}
});
} else if (videoProviders[i].codeName == 'flixhqS2') {
start = DateTime.now();
await getSuperstreamStreamingLinks(
"${appDependency.flixquestAPIURL}flixhq/watch-movie?tmdbId=455980")
.then((value) {
if (mounted) {
superstreamVideoSources = value;
videoLinks = superstreamVideoSources!.videoLinks;
}
});
}

end = DateTime.now();
Expand Down
40 changes: 40 additions & 0 deletions lib/screens/movie/movie_video_loader.dart
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import 'package:startapp_sdk/startapp.dart';
import '../../controllers/recently_watched_database_controller.dart';
import '../../provider/recently_watched_provider.dart';
import '../../video_providers/common.dart';
import '../../video_providers/flixhq_flixquest.dart';
import '../../video_providers/names.dart';
import '../../video_providers/zoro.dart';
import '/api/endpoints.dart';
Expand Down Expand Up @@ -53,6 +54,7 @@ class _MovieVideoLoaderState extends State<MovieVideoLoader> {

FlixHQStreamSources? fqMovieVideoSources;
SuperstreamStreamSources? superstreamVideoSources;
FlixHQFlixQuestSources? flixHQFlixQuestStreamSources;
DCVAStreamSources? dramacoolVideoSources;
DCVAStreamSources? viewasianVideoSources;
ZoroStreamSources? zoroVideoSources;
Expand Down Expand Up @@ -184,6 +186,15 @@ class _MovieVideoLoaderState extends State<MovieVideoLoader> {
if (movieVideoLinks != null && movieVideoLinks!.isNotEmpty) {
break;
}
} else if (videoProviders[i].codeName == 'flixhqS2') {
await loadFlixHQFlixQuestApi();
if (movieVideoSubs != null && movieVideoSubs!.isNotEmpty) {
await subtitleParserFetcher(movieVideoSubs!);
break;
}
if (movieVideoLinks != null && movieVideoLinks!.isNotEmpty) {
break;
}
}
}

Expand Down Expand Up @@ -831,4 +842,33 @@ class _MovieVideoLoaderState extends State<MovieVideoLoader> {
});
}
}

Future<void> loadFlixHQFlixQuestApi() async {
if (mounted) {
await getFlixHQFlixQuestLinks(Endpoints.getMovieLinksFlixHQFQ(
appDep.flixquestAPIURL, widget.metadata.movieId!))
.then((value) {
if (mounted) {
if (value.messageExists == null &&
value.videoLinks != null &&
value.videoLinks!.isNotEmpty) {
setState(() {
flixHQFlixQuestStreamSources = value;
});
} else if (value.messageExists != null ||
value.videoLinks == null ||
value.videoLinks!.isEmpty) {
return;
}
}
if (mounted) {
movieVideoLinks = flixHQFlixQuestStreamSources!.videoLinks;
movieVideoSubs = flixHQFlixQuestStreamSources!.videoSubtitles;
if (movieVideoLinks != null && movieVideoLinks!.isNotEmpty) {
convertVideoLinks(movieVideoLinks!);
}
}
});
}
}
}
43 changes: 43 additions & 0 deletions lib/screens/tv/tv_video_loader.dart
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import '../../controllers/recently_watched_database_controller.dart';
import '../../provider/recently_watched_provider.dart';
import '../../video_providers/common.dart';
import '../../video_providers/flixhq.dart';
import '../../video_providers/flixhq_flixquest.dart';
import '../../video_providers/names.dart';
import '../../video_providers/zoro.dart';
import '/api/endpoints.dart';
Expand Down Expand Up @@ -53,6 +54,7 @@ class _TVVideoLoaderState extends State<TVVideoLoader> {

FlixHQStreamSources? fqTVVideoSources;
SuperstreamStreamSources? superstreamVideoSources;
FlixHQFlixQuestSources? flixHQFlixQuestStreamSources;
DCVAStreamSources? dramacoolVideoSources;
DCVAStreamSources? viewasianVideoSources;
ZoroStreamSources? zoroVideoSources;
Expand Down Expand Up @@ -189,6 +191,15 @@ class _TVVideoLoaderState extends State<TVVideoLoader> {
if (tvVideoLinks != null && tvVideoLinks!.isNotEmpty) {
break;
}
} else if (videoProviders[i].codeName == 'flixhqS2') {
await loadFlixHQFlixQuestApi();
if (tvVideoSubs != null && tvVideoSubs!.isNotEmpty) {
await subtitleParserFetcher(tvVideoSubs!);
break;
}
if (tvVideoLinks != null && tvVideoLinks!.isNotEmpty) {
break;
}
}
}

Expand Down Expand Up @@ -642,6 +653,38 @@ class _TVVideoLoaderState extends State<TVVideoLoader> {
}
}

Future<void> loadFlixHQFlixQuestApi() async {
if (mounted) {
await getFlixHQFlixQuestLinks(Endpoints.getTVLinksFlixHQFQ(
appDep.flixquestAPIURL,
widget.metadata.episodeNumber!,
widget.metadata.seasonNumber!,
widget.metadata.tvId!))
.then((value) {
if (mounted) {
if (value.messageExists == null &&
value.videoLinks != null &&
value.videoLinks!.isNotEmpty) {
setState(() {
flixHQFlixQuestStreamSources = value;
});
} else if (value.messageExists != null ||
value.videoLinks == null ||
value.videoLinks!.isEmpty) {
return;
}
}
if (mounted) {
tvVideoLinks = flixHQFlixQuestStreamSources!.videoLinks;
tvVideoSubs = flixHQFlixQuestStreamSources!.videoSubtitles;
if (tvVideoLinks != null && tvVideoLinks!.isNotEmpty) {
convertVideoLinks(tvVideoLinks!);
}
}
});
}
}

void getAppLanguage() {
for (int i = 0; i < supportedLanguages.length; i++) {
if (supportedLanguages[i].languageCode ==
Expand Down
16 changes: 16 additions & 0 deletions lib/video_providers/flixhq_flixquest.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
import 'package:flixquest/video_providers/superstream.dart';

class FlixHQFlixQuestSources extends SuperstreamStreamSources {
FlixHQFlixQuestSources.fromJson(Map<String, dynamic> json)
: super.fromJson(json);
}

class FlixHQFlixQUestVideoLinks extends SuperstreamVideoLinks {
FlixHQFlixQUestVideoLinks.fromJson(Map<String, dynamic> json)
: super.fromJson(json);
}

class FlixHQFlixQUestSubLinks extends SuperstreamSubLinks {
FlixHQFlixQUestSubLinks.fromJson(Map<String, dynamic> json)
: super.fromJson(json);
}
2 changes: 1 addition & 1 deletion pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ description: A Flutter movie app.

publish_to: "none"

version: 2.5.0+2
version: 2.5.0+3

environment:
sdk: ">=2.12.0 <3.0.0"
Expand Down

0 comments on commit 40641d9

Please sign in to comment.