Skip to content

Commit

Permalink
fix: Fixed some sources
Browse files Browse the repository at this point in the history
  • Loading branch information
K3vinb5 committed Jun 27, 2024
1 parent a24f3d3 commit fc8ddef
Show file tree
Hide file tree
Showing 16 changed files with 79 additions and 69 deletions.
4 changes: 1 addition & 3 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
35 changes: 8 additions & 27 deletions lib/screens/anime_details_screen.dart
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down Expand Up @@ -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(
Expand Down Expand Up @@ -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];
Expand All @@ -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];
Expand Down
20 changes: 10 additions & 10 deletions lib/screens/home_screen.dart
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down
13 changes: 9 additions & 4 deletions lib/screens/video_screen.dart
Original file line number Diff line number Diff line change
Expand Up @@ -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!),
Expand All @@ -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();
Expand All @@ -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();
}

Expand Down
2 changes: 1 addition & 1 deletion lib/sources/anime/gogoanime_source.dart
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@ class GogoAnimeSource implements AnimeSource {
);
},
);
return [[await completer.future], null, null, null];
return [[await completer.future], null, [""], [""], ["Goyabu - 1080p"], [""]];
}

@override
Expand Down
56 changes: 35 additions & 21 deletions lib/sources/anime/goyabu.dart
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
Expand All @@ -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
Expand Down Expand Up @@ -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)";
}

}
4 changes: 2 additions & 2 deletions lib/sources/anime/util/embedded_extensions.dart
Original file line number Diff line number Diff line change
Expand Up @@ -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()});
}
}

Expand Down
4 changes: 3 additions & 1 deletion lib/util/mixed_controllers.dart
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,9 @@ class MixedControllers {
}

void dispose() {
syncTimer.cancel();
if (audio) {
syncTimer.cancel();
}
}

void syncControllers() async {
Expand Down
10 changes: 10 additions & 0 deletions lib/widgets/media_tags.dart
Original file line number Diff line number Diff line change
@@ -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 removed readme-assets/Peek 2024-04-02 22-05.mp4
Binary file not shown.
Binary file removed readme-assets/image-1.png
Binary file not shown.
Binary file removed readme-assets/image-2.png
Binary file not shown.
Binary file removed readme-assets/image-3.png
Binary file not shown.
Binary file removed readme-assets/image-4.png
Binary file not shown.
Binary file removed readme-assets/image-5.png
Binary file not shown.
Binary file added readme-assets/screenshots.gif
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit fc8ddef

Please sign in to comment.