fix: Fixed some sources

This commit is contained in:
Kevin Rodrigues Borges
2024-06-27 22:35:45 +01:00
parent a24f3d31b6
commit fc8ddef791
16 changed files with 79 additions and 69 deletions

View File

@@ -69,10 +69,8 @@ jobs:
run: export PATH="$PATH":"$HOME/.pub-cache/bin"
- name: Build deb package
run: flutter_to_debian
- name: Go to deb file path
run: cd build/linux/x64/release/debian/
- name: Rename deb file
run: cp unyo_0.0.0_amd64.deb unyo-${{github.ref_name}}-amd64.deb
run: cp build/linux/x64/release/debian/unyo_0.0.0_amd64.deb build/linux/x64/release/debian/unyo-${{github.ref_name}}-amd64.deb
- name: Linux Debain package Release
uses: softprops/action-gh-release@v1
env:

View File

@@ -5,6 +5,7 @@ import 'package:animated_snack_bar/animated_snack_bar.dart';
import 'package:bitsdojo_window/bitsdojo_window.dart';
import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
import 'package:icons_launcher/cli_commands.dart';
import 'package:smooth_list_view/smooth_list_view.dart';
import 'package:unyo/api/anilist_api_anime.dart';
import 'package:unyo/models/models.dart';
@@ -221,29 +222,6 @@ class _AnimeDetailsScreenState extends State<AnimeDetailsScreen> {
});
}
void addEmbeddedAniyomiExtensions() async {
var urlStream =
Uri.parse("https://kevin-is-awesome.mooo.com/api/unyo/sources");
var response = await http.get(urlStream);
if (response.statusCode == 200) {
List<dynamic> sources = json.decode(response.body)["sources"];
int sourcesLenght = animeSources.length;
for (var source in sources) {
String name = await getSourceNameAndLangAsync(source);
print(name);
animeSources.addAll({
sourcesLenght: EmbeddedSource(source: source as String, name: name)
});
sourcesLenght++;
}
setState(() {});
} else {
print(response.body);
}
updateSource(0);
}
//TODO temp, this is a mess
Future<String> getSourceNameAndLangAsync(String source) async {
var urlStream = Uri.parse(
@@ -403,15 +381,18 @@ class _AnimeDetailsScreenState extends State<AnimeDetailsScreen> {
List<String> keys =
streamAndCaptions[2]![source]!.split("@");
for (int i = 0; i < values.length; i++) {
headers!.addAll({keys[i]: values[i]});
headers!.addAll({keys[i][0].toUpperCase() + keys[i].substring(1): values[i]});
}
}
if (currentSource == 2){
print(streamAndCaptions[3]?[source]);
}
String? captions;
if (streamAndCaptions[1] != null &&
streamAndCaptions[1]!.isNotEmpty) {
List<String> availableCaptions =
streamAndCaptions[1]![0]!.split("@");
streamAndCaptions[1]![source]!.split("@");
for (var s in availableCaptions) {
if (s.contains("English")) {
captions = s.split(";")[0];
@@ -423,8 +404,8 @@ class _AnimeDetailsScreenState extends State<AnimeDetailsScreen> {
List<String>? availableSubtracks;
if (streamAndCaptions[5] != null &&
streamAndCaptions[5]!.isNotEmpty) {
if (streamAndCaptions[5]![0]!.contains("@")) {
availableSubtracks = streamAndCaptions[5]![0]!.split("@");
if (streamAndCaptions[5]![source]!.contains("@")) {
availableSubtracks = streamAndCaptions[5]![source]!.split("@");
for (var s in availableSubtracks) {
if (s.contains("English")) {
subtracks = s.split(";")[0];

View File

@@ -82,16 +82,16 @@ class _HomeScreenState
// print('Local server running on port ${server.port}');
}
Future<void> startEmbeddedServer() async {
String name =
'assets/embedded-api-${Platform.isLinux ? "linux" : Platform.isMacOS ? "macos" : "windows"}';
int pid;
if (Platform.isLinux || Platform.isMacOS) {
var processResults = shell.run('''
./$name
''');
}
}
// Future<void> startEmbeddedServer() async {
// String name =
// 'assets/embedded-api-${Platform.isLinux ? "linux" : Platform.isMacOS ? "macos" : "windows"}';
// int pid;
// if (Platform.isLinux || Platform.isMacOS) {
// var processResults = shell.run('''
// ./$name
// ''');
// }
// }
void setSharedPreferences() async {
prefs = await SharedPreferences.getInstance();

View File

@@ -84,7 +84,7 @@ class _VideoScreenState extends State<VideoScreen> {
videoPlayerOptions: VideoPlayerOptions(mixWithOthers: true),
);
}
if (widget.audioStream != null) {
if (widget.audioStream != null && widget.audioStream != "") {
if (widget.headers != null) {
_audioController = VideoPlayerController.networkUrl(
Uri.parse(widget.audioStream!),
@@ -111,7 +111,10 @@ class _VideoScreenState extends State<VideoScreen> {
_controller.initialize().then((_) => setState(() {}));
_controller.play();
if (widget.audioStream != null) {
if (widget.audioStream != null && widget.audioStream != "") {
_controller.addListener(() {
setState(() {});
});
_audioController.setLooping(false);
_audioController.initialize().then((_) => setState(() {}));
_audioController.play();
@@ -122,8 +125,10 @@ class _VideoScreenState extends State<VideoScreen> {
interactScreen(true);
_screenFocusNode.requestFocus();
setClientMqttConnection(false);
_mixedControllers = MixedControllers(widget.audioStream != null,
videoController: _controller, audioController: _audioController);
_mixedControllers = MixedControllers(
widget.audioStream != null && widget.audioStream != "",
videoController: _controller,
audioController: _audioController);
_mixedControllers.init();
}

View File

@@ -127,7 +127,7 @@ class GogoAnimeSource implements AnimeSource {
);
},
);
return [[await completer.future], null, null, null];
return [[await completer.future], null, [""], [""], ["Goyabu - 1080p"], [""]];
}
@override

View File

@@ -35,25 +35,27 @@ class GoyabuSource implements AnimeSource {
url = Uri.parse("https://www.goyabu.us/${episodePages[episode - 1]}");
// print(episodePages);
response =
await http.get(url, headers: {"Referer": "https://www.goaybu.us/"});
await http.get(url, headers: {"Referer": "https://www.goyabu.us/"});
if (response.statusCode != 200) {
return [];
}
htmlContent = response.body;
List<String> lines = htmlContent.split('\n');
// print("content: $htmlContent");
List<String> lines = htmlContent.split("\n");
List<String> linesWithFile =
lines.where((line) => line.contains('file: ')).toList();
lines.where((line) => line.contains('file:')).toList();
// print("raw: $linesWithFile");
List<String> cleanLines = [];
for (var line in linesWithFile) {
String newLine = line
String newLine = getStream(line)
.replaceAll("\t", "")
.replaceAll("\n", "")
.replaceAll(" ", "")
.replaceAll("file:", "")
.replaceAll("'", "")
.replaceAll(",", "");
.replaceAll(",", "").trim();
newLine = newLine.substring(0, newLine.length - 1);
cleanLines.add(newLine);
}
@@ -64,25 +66,24 @@ class GoyabuSource implements AnimeSource {
"appsd",
"appsd2",
];
bool newMp4 = false;
for(String line in cleanLines){
newMp4 = newMp4 || (line.contains("appsd2") || line.contains("apphd2"));
}
if(!newMp4) qualities.removeAt(0);
// bool newMp4 = false;
// for(String line in cleanLines){
// newMp4 = newMp4 || (line.contains("appsd2") || line.contains("apphd2"));
// }
// if(!newMp4) qualities.removeAt(0);
print("streams: $cleanLines");
List<List<String?>?> returnList = [[], null, [], [], [], []];
for (String quality in qualities) {
for (String line in cleanLines) {
if (line.contains(quality)) {
print(line);
return [
[line],
null,
["Referer"],
["https://www.goyabu.us/"]
];
}
returnList[0]?.add(line);
returnList[2]?.add("Referer");
returnList[3]?.add("https://www.goyabu.us/");
returnList[4]?.add("Qualidade - $quality");
returnList[5]?.add("");
}
}
return [];
print(returnList);
return returnList;
}
@override
@@ -116,9 +117,22 @@ class GoyabuSource implements AnimeSource {
return titlesAndIds;
}
String getStream(String htmlContent) {
int startIndex = htmlContent.indexOf("{file:'");
if (startIndex == -1) return "error";
int endIndex = htmlContent.indexOf("'", startIndex + 1);
if (endIndex == -1) return "error";
String streamingUrl = htmlContent
.substring(startIndex, endIndex + 1)
.replaceAll("\\", "")
.replaceAll('{"file":"', '')
.replaceAll('"', '')
.trim();
return streamingUrl;
}
@override
String getSourceName() {
return "Goyabu (Pt-Br)";
}
}

View File

@@ -20,8 +20,8 @@ late Map<int, AnimeSource> globalAnimesSources;
});
sourcesLenght++;
}
globalAnimesSources.addAll({sourcesLenght++ : GoyabuSource()});
globalAnimesSources.addAll({sourcesLenght++ : AnimesGamesSource()});
// globalAnimesSources.addAll({sourcesLenght++ : GoyabuSource()});
// globalAnimesSources.addAll({sourcesLenght++ : AnimesGamesSource()});
}
}

View File

@@ -55,7 +55,9 @@ class MixedControllers {
}
void dispose() {
syncTimer.cancel();
if (audio) {
syncTimer.cancel();
}
}
void syncControllers() async {

View File

@@ -0,0 +1,10 @@
import 'package:flutter/material.dart';
class MediaTags extends StatelessWidget {
const MediaTags({super.key});
@override
Widget build(BuildContext context) {
return const Placeholder();
}
}

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.2 MiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 394 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 493 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 970 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 753 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.1 MiB