-
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.
- Loading branch information
Showing
18 changed files
with
643 additions
and
280 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -5,4 +5,4 @@ Exec=unyo | |
Icon=logo | ||
Terminal=false | ||
Type=Application | ||
Categories=Multimedia; | ||
Categories=AudioVideo;Video; |
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,111 @@ | ||
import 'dart:convert'; | ||
import 'dart:math'; | ||
import 'package:unyo/models/models.dart'; | ||
import 'package:unyo/screens/home_screen.dart'; | ||
import 'package:http/http.dart' as http; | ||
import 'package:url_launcher/url_launcher.dart'; | ||
|
||
const String anilistEndpoint = "https://graphql.anilist.co"; | ||
const String anilistEndPointGetToken = | ||
"https://anilist.co/api/v2/oauth/authorize?client_id=17550&response_type=token"; | ||
|
||
Future<List<AnimeModel>> getMangaModelListTrending(int page, int n, int attempt) async { | ||
Map<String, dynamic> query = { | ||
"query": | ||
"query(\$page:Int = 1 \$id:Int \$type:MediaType \$isAdult:Boolean = false \$search:String \$format:[MediaFormat]\$status:MediaStatus \$countryOfOrigin:CountryCode \$source:MediaSource \$season:MediaSeason \$seasonYear:Int \$year:String \$onList:Boolean \$yearLesser:FuzzyDateInt \$yearGreater:FuzzyDateInt \$episodeLesser:Int \$episodeGreater:Int \$durationLesser:Int \$durationGreater:Int \$chapterLesser:Int \$chapterGreater:Int \$volumeLesser:Int \$volumeGreater:Int \$licensedBy:[Int]\$isLicensed:Boolean \$genres:[String]\$excludedGenres:[String]\$tags:[String]\$excludedTags:[String]\$minimumTagRank:Int \$sort:[MediaSort]=[POPULARITY_DESC,SCORE_DESC]){Page(page:\$page,perPage:$n){pageInfo{total perPage currentPage lastPage hasNextPage}media(id:\$id type:\$type season:\$season format_in:\$format status:\$status countryOfOrigin:\$countryOfOrigin source:\$source search:\$search onList:\$onList seasonYear:\$seasonYear startDate_like:\$year startDate_lesser:\$yearLesser startDate_greater:\$yearGreater episodes_lesser:\$episodeLesser episodes_greater:\$episodeGreater duration_lesser:\$durationLesser duration_greater:\$durationGreater chapters_lesser:\$chapterLesser chapters_greater:\$chapterGreater volumes_lesser:\$volumeLesser volumes_greater:\$volumeGreater licensedById_in:\$licensedBy isLicensed:\$isLicensed genre_in:\$genres genre_not_in:\$excludedGenres tag_in:\$tags tag_not_in:\$excludedTags minimumTagRank:\$minimumTagRank sort:\$sort isAdult:\$isAdult){id title{userPreferred}coverImage{extraLarge large color}startDate{year month day}endDate{year month day}bannerImage season seasonYear description type format status(version:2)episodes duration chapters volumes genres isAdult averageScore popularity nextAiringEpisode{airingAt timeUntilAiring episode}mediaListEntry{id status}studios(isMain:true){edges{isMain node{id name}}}}}}", | ||
"variables": { | ||
"page": page, | ||
"type": "ANIME", | ||
"sort": ["TRENDING_DESC", "POPULARITY_DESC"] | ||
} | ||
}; | ||
var url = Uri.parse(anilistEndpoint); | ||
var response = await http.post( | ||
url, | ||
headers: {"Content-Type": "application/json"}, | ||
body: json.encode(query), | ||
); | ||
if (response.statusCode == 500) { | ||
if(attempt < 5){ | ||
List<AnimeModel> returnList = await getAnimeModelListRecentlyReleased(page, n, attempt++); | ||
return returnList; | ||
} | ||
return []; | ||
} else { | ||
List<dynamic> media = jsonDecode(response.body)["data"]["Page"]["media"]; | ||
List<AnimeModel> list = []; | ||
for (int i = 0; i < n; i++) { | ||
Map<String, dynamic> json = media[i]; | ||
list.add(AnimeModel( | ||
id: json["id"], | ||
title: json["title"]["userPreferred"], | ||
coverImage: json["coverImage"]["large"], | ||
bannerImage: json["bannerImage"], | ||
startDate: | ||
"${json["startDate"]["day"]}/${json["startDate"]["month"]}/${json["startDate"]["year"]}", | ||
endDate: | ||
"${json["endDate"]["day"]}/${json["endDate"]["month"]}/${json["endDate"]["year"]}", | ||
type: json["type"], | ||
description: json["description"], | ||
status: json["status"], | ||
averageScore: json["averageScore"], | ||
episodes: json["episodes"], | ||
duration: json["duration"], | ||
format: json["format"], | ||
)); | ||
} | ||
return list; | ||
} | ||
} | ||
|
||
Future<List<AnimeModel>> getAnimeModelListRecentlyReleased( | ||
int page, int n, int attempt) async { | ||
Map<String, dynamic> query = { | ||
"query": | ||
"query{ Page(page: $page, perPage: $n) { airingSchedules (sort: TIME_DESC, notYetAired: false) {episode media { id title { userPreferred } coverImage { large } bannerImage format startDate { year month day } endDate { year month day } type description status averageScore episodes duration}}}}" | ||
}; | ||
|
||
var url = Uri.parse(anilistEndpoint); | ||
var response = await http.post( | ||
url, | ||
headers: {"Content-Type": "application/json"}, | ||
body: json.encode(query), | ||
); | ||
if (response.statusCode == 500) { | ||
if(attempt < 5){ | ||
List<AnimeModel> returnList = await getAnimeModelListRecentlyReleased(page, n, attempt++); | ||
return returnList; | ||
} | ||
return []; | ||
} else { | ||
List<dynamic> media = jsonDecode(response.body)["data"]["Page"]["airingSchedules"]; | ||
List<AnimeModel> list = []; | ||
for (int i = 0; i < media.length; i++) { | ||
var currentMedia = media[i]["media"]; | ||
list.add(AnimeModel( | ||
id: currentMedia["id"], | ||
title: currentMedia["title"]["userPreferred"], | ||
coverImage: currentMedia["coverImage"]["large"], | ||
bannerImage: currentMedia["bannerImage"], | ||
startDate: "${currentMedia["startDate"]["day"]}/${currentMedia["startDate"]["month"]}/${currentMedia["startDate"]["year"]}", | ||
endDate: "${currentMedia["endDate"]["day"]}/${currentMedia["endDate"]["month"]}/${currentMedia["endDate"]["year"]}", | ||
type: currentMedia["type"], | ||
status: currentMedia["status"], | ||
averageScore: currentMedia["averageScore"], | ||
episodes: currentMedia["episodes"], | ||
currentEpisode: media[i]["episode"], | ||
duration: currentMedia["duration"], | ||
description: currentMedia["description"], | ||
format: currentMedia["format"], | ||
)); | ||
} | ||
for(int i = 0; i < list.length; i++){ | ||
for(int j = i + 1; j < list.length - 1; j++){ | ||
if(list[i].id == list[j].id){ | ||
list.removeAt(j); | ||
} | ||
} | ||
} | ||
return list; | ||
} | ||
} |
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,38 @@ | ||
class MangaModel { | ||
MangaModel( | ||
{required this.id, | ||
required this.title, | ||
required this.coverImage, | ||
required this.bannerImage, | ||
required this.startDate, | ||
required this.endDate, | ||
required this.type, | ||
required this.status, | ||
required this.averageScore, | ||
required this.chapters, | ||
required this.duration, | ||
required this.description, | ||
required this.format, | ||
this.currentEpisode, | ||
}); | ||
|
||
int id; | ||
String? title; | ||
String? coverImage; | ||
String? bannerImage; | ||
String? startDate; | ||
String? endDate; | ||
String? type; | ||
String? status; | ||
String? description; | ||
String? format; | ||
int? averageScore; | ||
int? chapters; | ||
int? currentEpisode; | ||
int? duration; | ||
|
||
@override | ||
String toString() { | ||
return "$id $coverImage"; | ||
} | ||
} |
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
Oops, something went wrong.