Skip to content

Commit

Permalink
gogo source change, add stats page, version bump
Browse files Browse the repository at this point in the history
  • Loading branch information
frostnova721 committed Apr 27, 2024
1 parent f0f3a81 commit 8c1a67c
Show file tree
Hide file tree
Showing 6 changed files with 461 additions and 31 deletions.
2 changes: 1 addition & 1 deletion lib/core/anime/providers/gogoanime.dart
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ class Search {
}

class GogoAnime {
final String _baseUrl = "https://gogoanime3.net";
final String _baseUrl = "https://ww5.gogoanimes.fi";
final String _ajaxUrl = "https://ajax.gogocdn.net/ajax";

Future<List<Map<String, String?>>> search(String query) async {
Expand Down
48 changes: 48 additions & 0 deletions lib/core/database/anilist/queries.dart
Original file line number Diff line number Diff line change
Expand Up @@ -324,4 +324,52 @@ class AnilistQueries {
}
return recommendationList;
}

Future<AnilistUserStats> getUserStats(String userName) async {
final query = '''{
User(name: "$userName") {
statistics {
anime {
count
minutesWatched
episodesWatched
genres {
genre
count
minutesWatched
}
}
}
}
}''';

final Map<String, dynamic> res = await Anilist().fetchQuery(query, null);
final Map<String, dynamic> stats = res['User']['statistics']['anime'];
List<GenreWatchStats> genres = [];
for(final genre in stats['genres']) {
genres.add(GenreWatchStats(count: genre['count'], genre: genre['genre'], minutesWatched: genre['minutesWatched']));
}
return AnilistUserStats(
episodesWatched: stats['episodesWatched'],
genres: genres,
minutesWatched: stats['minutesWatched'],
notInPlanned: stats['count'],
);
}

Future<List<String>> getGenreThumbnail(String genre) async {
final query = """{ Page(perPage: 10){media(genre:"$genre", sort: TRENDING_DESC, type: ANIME, countryOfOrigin:"JP") {bannerImage} } }""";
final res =await Anilist().fetchQuery(query, RequestType.media);
List<String> banners = [];
for(final item in res) {
if(item['bannerImage'] != null) {
banners.add(item['bannerImage']);
}
}

if(banners.isEmpty) {
throw new Exception("ERR COULDNT GET GENRE THUMBNAIL");
}
return banners;
}
}
19 changes: 19 additions & 0 deletions lib/core/database/anilist/types.dart
Original file line number Diff line number Diff line change
Expand Up @@ -153,3 +153,22 @@ class CurrentlyAiringResult {
CurrentlyAiringResult({required this.cover, required this.id, required this.status, required this.title});
}

class GenreWatchStats {
final int count;
final int minutesWatched;
final String genre;

GenreWatchStats({required this.count, required this.genre, required this.minutesWatched});
}


class AnilistUserStats {
/**the items not in planned but from every other list */
final int notInPlanned;
final int minutesWatched;
final int episodesWatched;
final List<GenreWatchStats> genres;

AnilistUserStats({required this.episodesWatched, required this.genres, required this.minutesWatched, required this.notInPlanned});
}

64 changes: 35 additions & 29 deletions lib/ui/pages/settingPages/account.dart
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import 'package:animestream/core/database/anilist/login.dart';
import 'package:animestream/core/database/anilist/types.dart';
import 'package:animestream/ui/models/snackBar.dart';
import 'package:animestream/ui/pages/settingPages/common.dart';
import 'package:animestream/ui/pages/settingPages/stats.dart';
import 'package:animestream/ui/theme/mainTheme.dart';
import 'package:flutter/material.dart';

Expand Down Expand Up @@ -118,36 +119,41 @@ class _AccountSettingState extends State<AccountSetting> {
mainAxisAlignment:
MainAxisAlignment.spaceBetween,
children: [
Row(
children: [
Padding(
padding: const EdgeInsets.only(
right: 15),
child: CircleAvatar(
radius: 25,
backgroundColor: textSubColor,
backgroundImage:
user?.avatar != null
? NetworkImage(
user!.avatar!)
: AssetImage(
"lib/assets/images/ghost.png",
) as ImageProvider,
InkWell(
onTap: () {
Navigator.of(context).push(MaterialPageRoute(builder: (context) => UserStats(userModal: user!,)));
},
child: Row(
children: [
Padding(
padding: const EdgeInsets.only(
right: 15),
child: CircleAvatar(
radius: 25,
backgroundColor: textSubColor,
backgroundImage:
user?.avatar != null
? NetworkImage(
user!.avatar!)
: AssetImage(
"lib/assets/images/ghost.png",
) as ImageProvider,
),
),
),
Text(
user?.name ??
"NO_NAME_ERR", //lol
style: TextStyle(
color: textMainColor,
fontFamily: "NotoSans",
fontWeight: FontWeight.bold,
fontSize: 20,
overflow:
TextOverflow.ellipsis),
maxLines: 2,
),
],
Text(
user?.name ??
"NO_NAME_ERR", //lol
style: TextStyle(
color: textMainColor,
fontFamily: "NotoSans",
fontWeight: FontWeight.bold,
fontSize: 20,
overflow:
TextOverflow.ellipsis),
maxLines: 2,
),
],
),
),
ElevatedButton(
onPressed: () {
Expand Down
Loading

0 comments on commit 8c1a67c

Please sign in to comment.