Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bump flutter webview #580

Open
wants to merge 7 commits into
base: dev
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 0 additions & 9 deletions violet/lib/component/hentai.dart
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,6 @@ import 'package:shared_preferences/shared_preferences.dart';
import 'package:violet/component/eh/eh_headers.dart';
import 'package:violet/component/eh/eh_parser.dart';
import 'package:violet/component/eh/eh_provider.dart';
import 'package:violet/component/hisoki/hisoki_getter.dart';
import 'package:violet/component/hisoki/hisoki_provider.dart';
import 'package:violet/component/hitomi/hitomi.dart';
import 'package:violet/component/hitomi/hitomi_parser.dart';
import 'package:violet/component/hitomi/hitomi_provider.dart';
Expand Down Expand Up @@ -568,13 +566,6 @@ class HentaiManager {
}
return HitomiImageProvider(imgList, qr.id().toString());
}

case 'Hisoki':
{
var urls = await HisokiGetter.getImages(qr.id());
if (urls == null || urls.isEmpty) break;
return HisokiImageProvider(infos: urls, id: qr.id());
}
}
} catch (e, st) {
Logger.error('[hentai-getImageProvider] E: $e\n'
Expand Down
32 changes: 0 additions & 32 deletions violet/lib/component/hisoki/hisoki_getter.dart

This file was deleted.

31 changes: 0 additions & 31 deletions violet/lib/component/hisoki/hisoki_hash.dart

This file was deleted.

68 changes: 0 additions & 68 deletions violet/lib/component/hisoki/hisoki_provider.dart

This file was deleted.

15 changes: 7 additions & 8 deletions violet/lib/component/hitomi/series_finder.dart
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,9 @@ class SeriesFinder {

if (kv.key.toLowerCase() == 'n/a') continue;

final qm = QueryManager.queryPagination(HitomiManager.translate2query(
'artist:${kv.key.replaceAll(' ', '_')}'));
qm.itemsPerPage = 99999;
final query = HitomiManager.translate2query(
'artist:${kv.key.replaceAll(' ', '_')}');
final qm = QueryManager.queryPagination(query, 99999);
final qr = await qm.next();

if (qr.length == 1) continue;
Expand All @@ -52,9 +52,9 @@ class SeriesFinder {

if (kv.key.toLowerCase() == 'n/a') continue;

final qm = QueryManager.queryPagination(HitomiManager.translate2query(
'artist:${kv.key.replaceAll(' ', '_')}'));
qm.itemsPerPage = 99999;
final query = HitomiManager.translate2query(
'artist:${kv.key.replaceAll(' ', '_')}');
final qm = QueryManager.queryPagination(query, 99999);
final qr = await qm.next();

if (qr.length == 1) continue;
Expand All @@ -77,8 +77,7 @@ class SeriesFinder {

static Future<void> doFind2() async {
final qm = QueryManager.queryPagination(
'SELECT Title, Artists, Groups FROM HitomiColumnModel');
qm.itemsPerPage = 999999;
'SELECT Title, Artists, Groups FROM HitomiColumnModel', 999999);
final qr = await qm.next();

final artists = <String, List<int>>{};
Expand Down
3 changes: 2 additions & 1 deletion violet/lib/database/query.dart
Original file line number Diff line number Diff line change
Expand Up @@ -64,11 +64,12 @@ class QueryManager {
return qm;
}

static QueryManager queryPagination(String rawQuery) {
static QueryManager queryPagination(String rawQuery, int itemsPerPage) {
QueryManager qm = QueryManager();
qm.isPagination = true;
qm.curPage = 0;
qm.queryString = rawQuery;
qm.itemsPerPage = itemsPerPage;
return qm;
}

Expand Down
1 change: 1 addition & 0 deletions violet/lib/pages/after_loading/afterloading_page.dart
Original file line number Diff line number Diff line change
Expand Up @@ -345,6 +345,7 @@ class AfterLoadingPageState extends State<AfterLoadingPage>
child: Stack(
children: [
if (kReleaseMode) const ScriptWebView(),
const ScriptWebView(),
PageView(
controller: _pageController,
physics:
Expand Down
56 changes: 6 additions & 50 deletions violet/lib/pages/artist_info/artist_info_page.dart
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,7 @@ class _ArtistInfoPageState extends State<ArtistInfoPage> {
similarsAll = similars;
similars = similars.take(6).toList();

await querySimilars(similars, widget.type.name, qrs);
await querySimilars(similars, widget.type, qrs);

if (widget.type.isCharacter || widget.type.isSeries) {
if (widget.type.isCharacter) {
Expand All @@ -177,13 +177,13 @@ class _ArtistInfoPageState extends State<ArtistInfoPage> {

await querySimilars(
relatedCharacterOrSeries,
widget.type.name,
widget.type,
qrsCharacterOrSeries,
);

await querySimilars(
relatedCOSSingle,
widget.type.name,
widget.type,
qrsCOSSingle,
);
}
Expand Down Expand Up @@ -219,54 +219,10 @@ class _ArtistInfoPageState extends State<ArtistInfoPage> {
if (comments!.isNotEmpty) setState(() {});
}

Future<void> querySimilars(List<(String, double)> similars, String prefix,
Future<void> querySimilars(List<(String, double)> similars, ArtistType type,
List<List<QueryResult>> qrs) async {
var unescape = HtmlUnescape();
for (int i = 0; i < similars.length; i++) {
var postfix = similars[i].$1.toLowerCase().replaceAll(' ', '_');
var queryString = HitomiManager.translate2query(
'$prefix:$postfix ${Settings.includeTags} ${Settings.serializedExcludeTags}');
final qm = QueryManager.queryPagination(queryString);
qm.itemsPerPage = 10;

var x = await qm.next();
if (x.isEmpty) {
qrs.add(<QueryResult>[]);
continue;
}
var y = [x[0]];

var titles = [unescape.convert((x[0].title() as String).trim())];
if (titles[0].contains('Ch.')) {
titles[0] = titles[0].split('Ch.')[0];
} else if (titles[0].contains('ch.')) {
titles[0] = titles[0].split('ch.')[0];
}

for (int i = 1; i < x.length; i++) {
var skip = false;
var ff = unescape.convert((x[i].title() as String).trim());
if (ff.contains('Ch.')) {
ff = ff.split('Ch.')[0];
} else if (ff.contains('ch.')) {
ff = ff.split('ch.')[0];
}
for (int j = 0; j < titles.length; j++) {
var tt = titles[j];
if (Distance.levenshteinDistanceComparable(
tt.runes.map((e) => e.toString()).toList(),
ff.runes.map((e) => e.toString()).toList()) <
3) {
skip = true;
break;
}
}
if (skip) continue;
y.add(x[i]);
titles.add(ff.trim());
}

qrs.add(y);
for (final (name, _) in similars) {
qrs.add(await queryDedupedArtistArticles(type, name));
}
}

Expand Down
84 changes: 38 additions & 46 deletions violet/lib/pages/artist_info/similar_list_page.dart
Original file line number Diff line number Diff line change
Expand Up @@ -24,51 +24,6 @@ class SimilarListPage extends StatelessWidget {
required this.type,
});

Future<List<QueryResult>> _future(String e) async {
var unescape = HtmlUnescape();
var postfix = e.toLowerCase().replaceAll(' ', '_');
if (type.isUploader) postfix = e;
var queryString = HitomiManager.translate2query(
'${type.name}:$postfix ${Settings.includeTags} ${Settings.serializedExcludeTags}');
final qm = QueryManager.queryPagination(queryString);
qm.itemsPerPage = 10;

var x = await qm.next();
var y = [x[0]];

var titles = [unescape.convert((x[0].title() as String).trim())];
if (titles[0].contains('Ch.')) {
titles[0] = titles[0].split('Ch.')[0];
} else if (titles[0].contains('ch.')) {
titles[0] = titles[0].split('ch.')[0];
}

for (int i = 1; i < x.length; i++) {
var skip = false;
var ff = unescape.convert((x[i].title() as String).trim());
if (ff.contains('Ch.')) {
ff = ff.split('Ch.')[0];
} else if (ff.contains('ch.')) {
ff = ff.split('ch.')[0];
}
for (int j = 0; j < titles.length; j++) {
var tt = titles[j];
if (Distance.levenshteinDistanceComparable(
tt.runes.map((e) => e.toString()).toList(),
ff.runes.map((e) => e.toString()).toList()) <
3) {
skip = true;
break;
}
}
if (skip) continue;
y.add(x[i]);
titles.add(ff.trim());
}

return y;
}

@override
Widget build(BuildContext context) {
return CardPanel.build(
Expand All @@ -81,7 +36,7 @@ class SimilarListPage extends StatelessWidget {
itemBuilder: (BuildContext ctxt, int index) {
var e = similarsAll[index];
return FutureBuilder<List<QueryResult>>(
future: _future(e.$1),
future: queryDedupedArtistArticles(type, e.$1),
builder: (BuildContext context,
AsyncSnapshot<List<QueryResult>> snapshot) {
if (!snapshot.hasData) {
Expand All @@ -108,3 +63,40 @@ class SimilarListPage extends StatelessWidget {
);
}
}

Future<List<QueryResult>> queryDedupedArtistArticles(
ArtistType type, String e) async {
final postfix = e.toLowerCase().replaceAll(' ', '_');
final queryString = HitomiManager.translate2query(
'${type.name}:$postfix ${Settings.includeTags} ${Settings.serializedExcludeTags}');
final qm = QueryManager.queryPagination(queryString, 10);
final quries = await qm.next();

final titles = [removeChapter(quries[0].title() as String)];
final results = [quries[0]];

// 제목이 비슷한(중복) 작품을 보여주지 않기 위해 필터링
for (final query in quries) {
final target = removeChapter(query.title() as String);
final hasSimilar = titles.any((source) {
return Distance.levenshteinDistanceComparable(
source.runes.map((e) => e.toString()).toList(),
target.runes.map((e) => e.toString()).toList()) <
3;
});

if (!hasSimilar) {
titles.add(target);
results.add(query);
}
}

return results;
}

String removeChapter(String title) {
final unescapedTitle = HtmlUnescape().convert(title.trim());
final pos = unescapedTitle.indexOf(RegExp(r'Ch\.|ch\.'));

return (pos == -1 ? unescapedTitle : unescapedTitle.substring(0, pos)).trim();
}
Loading
Loading