-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Updated fvp version and added 2 portuguese anime sources
- Loading branch information
Showing
9 changed files
with
286 additions
and
10 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,135 @@ | ||
import 'dart:convert'; | ||
import 'package:html/parser.dart' show parse; | ||
import 'package:unyo/sources/anime/anime_source.dart'; | ||
import 'package:flutter/material.dart'; | ||
import 'package:http/http.dart' as http; | ||
|
||
class AnimesOnlineSource implements AnimeSource { | ||
@override | ||
Future<List<String?>> getAnimeStreamAndCaptions( | ||
String id, int episode, BuildContext context) async { | ||
final String animePageEndpoint = | ||
"${id.replaceFirst("/anime/", "/episodio/")}-episodio-${episode > 9 ? episode : "0$episode"}"; | ||
|
||
var url = Uri.parse(animePageEndpoint); | ||
var response = await http | ||
.get(url, headers: {"Referer": "https://animesonline.cloud/"}); | ||
|
||
final String dataId = getDataId(response, animePageEndpoint); | ||
print("Id -> $dataId"); | ||
String animeStreamEndpoint = | ||
"https://animesonline.cloud/wp-json/dooplayer/v2/$dataId/tv/1"; | ||
|
||
url = Uri.parse(animeStreamEndpoint); | ||
response = await http | ||
.get(url, headers: {"Referer": "https://animesonline.cloud/"}); | ||
|
||
Map<String, dynamic> jsonResponse = json.decode(response.body); | ||
late String mp4Endpoint; | ||
|
||
try { | ||
mp4Endpoint = jsonResponse["embed_url"]; | ||
} catch (e) { | ||
print("Json: $jsonResponse \n Id: $dataId"); | ||
mp4Endpoint = ""; | ||
} | ||
|
||
if (!mp4Endpoint.contains("mangas.cloud")) { | ||
animeStreamEndpoint = | ||
"https://animesonline.cloud/wp-json/dooplayer/v2/$dataId/tv/2"; | ||
|
||
url = Uri.parse(animeStreamEndpoint); | ||
response = await http | ||
.get(url, headers: {"Referer": "https://animesonline.cloud/"}); | ||
|
||
jsonResponse = json.decode(response.body); | ||
try { | ||
mp4Endpoint = jsonResponse["embed_url"]; | ||
} catch (e) { | ||
mp4Endpoint = ""; | ||
} | ||
if (!mp4Endpoint.contains("mangas.cloud")) { | ||
animeStreamEndpoint = | ||
"https://animesonline.cloud/wp-json/dooplayer/v2/$dataId/tv/3"; | ||
|
||
url = Uri.parse(animeStreamEndpoint); | ||
response = await http | ||
.get(url, headers: {"Referer": "https://animesonline.cloud/"}); | ||
|
||
jsonResponse = json.decode(response.body); | ||
try { | ||
mp4Endpoint = jsonResponse["embed_url"]; | ||
} catch (e) { | ||
return []; | ||
} | ||
} | ||
} | ||
|
||
mp4Endpoint = mp4Endpoint.replaceFirst( | ||
"https://animesonline.cloud/jwplayer?source=", ""); | ||
mp4Endpoint = mp4Endpoint.replaceFirst("&id=$dataId&type=mp4", ""); | ||
mp4Endpoint = Uri.decodeFull(mp4Endpoint); | ||
return [mp4Endpoint, null]; | ||
} | ||
|
||
@override | ||
Future<List<List<String>>> getAnimeTitlesAndIds(String query) async { | ||
//TODO search the html for the ids instead of assuming them | ||
final String titlesAndIdsEndPoint = | ||
"https://animesonline.cloud/wp-json/dooplay/search/?keyword=$query&nonce=2cf7e710c5"; | ||
var url = Uri.parse(titlesAndIdsEndPoint); | ||
var response = await http | ||
.get(url, headers: {"Referer": "https://animesonline.cloud/"}); | ||
if (response.statusCode != 200) { | ||
//TODO Dialog | ||
|
||
// print(response.body); | ||
return []; | ||
} | ||
|
||
List<List<String>> titlesAndIds = [[], []]; | ||
Map<String, dynamic> jsonResponse = json.decode(response.body); | ||
List<MapEntry<String, dynamic>> entries = jsonResponse.entries.toList(); | ||
try { | ||
for (int i = 0; i < entries.length; i++) { | ||
//ids | ||
titlesAndIds[1].add(entries[i].value["url"].toString()); | ||
//titles | ||
titlesAndIds[0].add(entries[i].value["title"].toString()); | ||
} | ||
} catch (e) { | ||
return [[], []]; | ||
} | ||
|
||
return titlesAndIds; | ||
} | ||
|
||
@override | ||
String getSourceName() { | ||
return "Animes Online (Pt-Br)"; | ||
} | ||
|
||
String getDataId(http.Response response, String url) { | ||
String htmlContent = response.body; | ||
|
||
var document = parse(htmlContent); | ||
var elements = document.querySelectorAll('a[data-id]'); | ||
|
||
for (var element in elements) { | ||
if (element.attributes['data-id'] == null) continue; | ||
return element.attributes['data-id']!; | ||
} | ||
//If something goes wrong | ||
int startIndex = htmlContent.indexOf('data-id="'); | ||
print("startIndex->$startIndex"); | ||
if (startIndex != -1) { | ||
startIndex += 'data-id="'.length; | ||
int endIndex = htmlContent.indexOf('"', startIndex); | ||
return "$startIndex-$endIndex"; | ||
} else { | ||
print(url); | ||
} | ||
|
||
return "error"; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,120 @@ | ||
import 'package:html/parser.dart'; | ||
import 'package:unyo/sources/sources.dart'; | ||
import 'package:http/http.dart' as http; | ||
import 'package:flutter/material.dart'; | ||
|
||
class GoyabuSource implements AnimeSource { | ||
@override | ||
Future<List<String?>> getAnimeStreamAndCaptions( | ||
String id, int episode, BuildContext context) async { | ||
var url = Uri.parse(id); | ||
var response = | ||
await http.get(url, headers: {"Referer": "https://www.goyabu.us/"}); | ||
|
||
if (response.statusCode != 200) { | ||
return []; | ||
} | ||
|
||
List<String> episodePages = []; | ||
String htmlContent = response.body; | ||
var document = parse(htmlContent); | ||
var elements = document.querySelectorAll('.ultimosEpisodiosHomeItem'); | ||
for (var element in elements) { | ||
//episodePages | ||
String? episodePage = element.querySelector('a')?.attributes['href']; | ||
if (episodePage != null) { | ||
episodePages.add(episodePage); | ||
} | ||
} | ||
|
||
if (episodePages.length < episode) { | ||
//TODO handle cases where episode is higher than 30 | ||
return []; | ||
} | ||
|
||
url = Uri.parse("https://www.goyabu.us/${episodePages[episode - 1]}"); | ||
// print(episodePages); | ||
response = | ||
await http.get(url, headers: {"Referer": "https://www.goaybu.us/"}); | ||
|
||
if (response.statusCode != 200) { | ||
return []; | ||
} | ||
|
||
htmlContent = response.body; | ||
List<String> lines = htmlContent.split('\n'); | ||
List<String> linesWithFile = | ||
lines.where((line) => line.contains('file: ')).toList(); | ||
List<String> cleanLines = []; | ||
for (var line in linesWithFile) { | ||
String newLine = line | ||
.replaceAll("\t", "") | ||
.replaceAll("\n", "") | ||
.replaceAll(" ", "") | ||
.replaceAll("file:", "") | ||
.replaceAll("'", "") | ||
.replaceAll(",", ""); | ||
newLine = newLine.substring(0, newLine.length - 1); | ||
cleanLines.add(newLine); | ||
} | ||
List<String> qualities = [ | ||
"appfullhd", | ||
"apphd", | ||
"apphd2", | ||
/* "appfullhd", */ | ||
"apphd2", | ||
"appsd2", | ||
"apphd", | ||
"appsd" | ||
]; | ||
for (String quality in qualities) { | ||
for (String line in cleanLines) { | ||
if (line.contains(quality)) { | ||
return [ | ||
line /* "https://cdn8.anicdn.net/apphd/43606.mp4" */, | ||
null, | ||
"https://www.goyabu.us/" | ||
]; | ||
} | ||
} | ||
} | ||
return []; | ||
} | ||
|
||
@override | ||
Future<List<List<String>>> getAnimeTitlesAndIds(String query) async { | ||
final String animeTitlesAndIdsEndpoint = | ||
"https://www.goyabu.us/busca?busca=$query"; | ||
var url = Uri.parse(animeTitlesAndIdsEndpoint); | ||
var response = | ||
await http.get(url, headers: {"Referer": "https://www.goyabu.us/"}); | ||
|
||
if (response.statusCode != 200) { | ||
return [[], []]; | ||
} | ||
List<List<String>> titlesAndIds = [[], []]; | ||
String htmlContent = response.body; | ||
var document = parse(htmlContent); | ||
|
||
var elements = document.querySelectorAll('.ultimosAnimesHomeItem'); | ||
for (var element in elements) { | ||
//link | ||
var id = element.querySelector('a')?.attributes['href']; | ||
//title | ||
var title = | ||
element.querySelector('.ultimosAnimesHomeItemInfosNome')?.text.trim(); | ||
|
||
if (id != null && title != null) { | ||
titlesAndIds[0].add(title); | ||
titlesAndIds[1].add(id); | ||
} | ||
} | ||
return titlesAndIds; | ||
} | ||
|
||
@override | ||
String getSourceName() { | ||
return "Goyabu (Pt -Br)"; | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,7 @@ | ||
export 'anime/anime_source.dart'; | ||
export 'anime/gogoanime_source.dart'; | ||
export 'anime/zoro_source.dart'; | ||
export 'anime/goyabu.dart'; | ||
export 'anime/animes_online_source.dart'; | ||
export 'manga/manga_source.dart'; | ||
export 'manga/mangahere_source.dart'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.