mirror of
https://github.com/dstark5/Openlib.git
synced 2025-09-19 13:33:35 +08:00
Compare commits
5 Commits
v1.0.7-bet
...
v1.0.9-bet
Author | SHA1 | Date | |
---|---|---|---|
1e84848d39 | |||
78a50e28ff | |||
fda962a46f | |||
a7ca206b10 | |||
6be9927b26 |
@ -219,8 +219,7 @@ class AnnasArchieve {
|
||||
'info':
|
||||
main?.querySelector('div[class="text-sm text-gray-500"]')?.text ?? '',
|
||||
'description': main
|
||||
?.querySelector(
|
||||
'div[class="mt-4 line-clamp-[8] js-md5-top-box-description"]')
|
||||
?.querySelector('div[class="mb-1"]')
|
||||
?.text
|
||||
.replaceFirst("description", '') ??
|
||||
" "
|
||||
|
@ -8,9 +8,31 @@ class TrendingBookData {
|
||||
TrendingBookData({this.title, this.thumbnail});
|
||||
}
|
||||
|
||||
class OpenLibrary {
|
||||
String url = "https://openlibrary.org/trending/daily";
|
||||
abstract class TrendingBooksImpl {
|
||||
String url = '';
|
||||
int timeOutDuration = 20;
|
||||
List<TrendingBookData> _parser(dynamic data);
|
||||
|
||||
Future<List<TrendingBookData>> trendingBooks() async {
|
||||
try {
|
||||
final dio = Dio();
|
||||
final response = await dio.get(url,
|
||||
options: Options(
|
||||
sendTimeout: Duration(seconds: timeOutDuration),
|
||||
receiveTimeout: Duration(seconds: timeOutDuration)));
|
||||
return _parser(response.data.toString());
|
||||
} on DioException catch (e) {
|
||||
return [];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
class OpenLibrary extends TrendingBooksImpl {
|
||||
OpenLibrary() {
|
||||
super.url = "https://openlibrary.org/trending/daily";
|
||||
}
|
||||
|
||||
@override
|
||||
List<TrendingBookData> _parser(data) {
|
||||
var document = parse(data.toString());
|
||||
var bookList = document.querySelectorAll('li[class="searchResultItem"]');
|
||||
@ -32,31 +54,33 @@ class OpenLibrary {
|
||||
return trendingBooks;
|
||||
}
|
||||
|
||||
@override
|
||||
Future<List<TrendingBookData>> trendingBooks() async {
|
||||
try {
|
||||
final dio = Dio();
|
||||
const timeOutDuration = 5;
|
||||
final response = await dio.get(url,
|
||||
options: Options(
|
||||
sendTimeout: const Duration(seconds: 20),
|
||||
receiveTimeout: const Duration(seconds: 20)));
|
||||
sendTimeout: const Duration(seconds: timeOutDuration),
|
||||
receiveTimeout: const Duration(seconds: timeOutDuration)));
|
||||
final response2 = await dio.get(
|
||||
"https://openlibrary.org/trending/daily?page=2",
|
||||
options: Options(
|
||||
sendTimeout: const Duration(seconds: 20),
|
||||
receiveTimeout: const Duration(seconds: 20)));
|
||||
sendTimeout: const Duration(seconds: timeOutDuration),
|
||||
receiveTimeout: const Duration(seconds: timeOutDuration)));
|
||||
return _parser('${response.data.toString()}${response2.data.toString()}');
|
||||
} on DioException catch (e) {
|
||||
if (e.type == DioExceptionType.unknown) {
|
||||
throw "socketException";
|
||||
}
|
||||
rethrow;
|
||||
return [];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
class GoodReads {
|
||||
String url = "https://www.goodreads.com/shelf/show/trending";
|
||||
class GoodReads extends TrendingBooksImpl {
|
||||
GoodReads() {
|
||||
super.url = "https://www.goodreads.com/shelf/show/trending";
|
||||
}
|
||||
|
||||
@override
|
||||
List<TrendingBookData> _parser(data) {
|
||||
var document = parse(data.toString());
|
||||
var bookList = document.querySelectorAll('div[class="elementList"]');
|
||||
@ -84,28 +108,15 @@ class GoodReads {
|
||||
}
|
||||
return trendingBooks;
|
||||
}
|
||||
|
||||
Future<List<TrendingBookData>> trendingBooks() async {
|
||||
try {
|
||||
final dio = Dio();
|
||||
final response = await dio.get(url,
|
||||
options: Options(
|
||||
sendTimeout: const Duration(seconds: 20),
|
||||
receiveTimeout: const Duration(seconds: 20)));
|
||||
return _parser(response.data.toString());
|
||||
} on DioException catch (e) {
|
||||
if (e.type == DioExceptionType.unknown) {
|
||||
throw "socketException";
|
||||
}
|
||||
rethrow;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
class PenguinRandomHouse {
|
||||
String url =
|
||||
class PenguinRandomHouse extends TrendingBooksImpl {
|
||||
PenguinRandomHouse() {
|
||||
super.url =
|
||||
"https://www.penguinrandomhouse.com/ajaxc/categories/books/?from=0&to=50&contentId=&elClass=book&dataType=html&catFilter=best-sellers";
|
||||
}
|
||||
|
||||
@override
|
||||
List<TrendingBookData> _parser(data) {
|
||||
var document = parse(data.toString());
|
||||
var bookList = document.querySelectorAll('div[class="book"]');
|
||||
@ -132,20 +143,34 @@ class PenguinRandomHouse {
|
||||
}
|
||||
return trendingBooks;
|
||||
}
|
||||
}
|
||||
|
||||
Future<List<TrendingBookData>> trendingBooks() async {
|
||||
try {
|
||||
final dio = Dio();
|
||||
final response = await dio.get(url,
|
||||
options: Options(
|
||||
sendTimeout: const Duration(seconds: 20),
|
||||
receiveTimeout: const Duration(seconds: 20)));
|
||||
return _parser(response.data.toString());
|
||||
} on DioException catch (e) {
|
||||
if (e.type == DioExceptionType.unknown) {
|
||||
throw "socketException";
|
||||
class BookDigits extends TrendingBooksImpl {
|
||||
BookDigits() {
|
||||
super.url = "https://bookdigits.com/fresh";
|
||||
}
|
||||
rethrow;
|
||||
|
||||
@override
|
||||
List<TrendingBookData> _parser(data) {
|
||||
var document = parse(data.toString());
|
||||
var bookList = document.querySelectorAll('div[class="list-row"]');
|
||||
List<TrendingBookData> trendingBooks = [];
|
||||
for (var element in bookList) {
|
||||
if (element.querySelector('div[class="list-title link-reg"]')?.text !=
|
||||
null &&
|
||||
element.querySelector('img')?.attributes['src'] != null) {
|
||||
String? thumbnail = element.querySelector('img')?.attributes['src'];
|
||||
trendingBooks.add(
|
||||
TrendingBookData(
|
||||
title: element
|
||||
.querySelector('div[class="list-title link-reg"]')
|
||||
?.text
|
||||
.toString()
|
||||
.trim(),
|
||||
thumbnail: thumbnail.toString()),
|
||||
);
|
||||
}
|
||||
}
|
||||
return trendingBooks;
|
||||
}
|
||||
}
|
||||
|
@ -72,17 +72,22 @@ final searchQueryProvider = StateProvider<String>((ref) => "");
|
||||
//Provider for Trending Books
|
||||
|
||||
final getTrendingBooks = FutureProvider<List<TrendingBookData>>((ref) async {
|
||||
OpenLibrary openLibrary = OpenLibrary();
|
||||
// OpenLibrary openLibrary = OpenLibrary();
|
||||
GoodReads goodReads = GoodReads();
|
||||
PenguinRandomHouse penguinTrending = PenguinRandomHouse();
|
||||
BookDigits bookDigits = BookDigits();
|
||||
List<TrendingBookData> trendingBooks =
|
||||
await Future.wait<List<TrendingBookData>>([
|
||||
openLibrary.trendingBooks(),
|
||||
goodReads.trendingBooks(),
|
||||
penguinTrending.trendingBooks()
|
||||
penguinTrending.trendingBooks(),
|
||||
// openLibrary.trendingBooks(),
|
||||
bookDigits.trendingBooks(),
|
||||
]).then((List<List<TrendingBookData>> listOfData) =>
|
||||
listOfData.expand((element) => element).toList());
|
||||
|
||||
if (trendingBooks.isEmpty) {
|
||||
throw 'Nothing Trending Today :(';
|
||||
}
|
||||
trendingBooks.shuffle();
|
||||
return trendingBooks;
|
||||
});
|
||||
|
@ -13,6 +13,8 @@ class AboutPage extends StatelessWidget {
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
const version = "1.0.9";
|
||||
|
||||
return Scaffold(
|
||||
appBar: AppBar(
|
||||
backgroundColor: Theme.of(context).colorScheme.background,
|
||||
@ -47,7 +49,7 @@ class AboutPage extends StatelessWidget {
|
||||
Padding(
|
||||
padding: EdgeInsets.only(left: 7, right: 7, top: 5),
|
||||
child: Text(
|
||||
"1.0.7",
|
||||
version,
|
||||
style: TextStyle(
|
||||
fontSize: 15,
|
||||
fontWeight: FontWeight.bold,
|
||||
|
@ -52,7 +52,7 @@ class _WebviewState extends ConsumerState<Webview> {
|
||||
onLoadStart: (controller, url) {},
|
||||
onLoadStop: (controller, url) async {
|
||||
String query =
|
||||
"""document.querySelector('a[class="font-bold"]').href""";
|
||||
"""var paragraphTag=document.querySelector('p[class="mb-4 text-xl font-bold"]');var anchorTagHref=paragraphTag.querySelector('a').href;var url=()=>{return anchorTagHref};url();""";
|
||||
String? mirrorLink = await webViewController
|
||||
?.evaluateJavascript(source: query);
|
||||
// final ipfsUrl = widget.url
|
||||
@ -62,7 +62,6 @@ class _WebviewState extends ConsumerState<Webview> {
|
||||
// await webViewController?.loadUrl(
|
||||
// urlRequest: URLRequest(
|
||||
// url: WebUri('https://example.com/new-page')));
|
||||
|
||||
if (mirrorLink != null) {
|
||||
Future.delayed(const Duration(milliseconds: 70), () {
|
||||
// ignore: use_build_context_synchronously
|
||||
|
@ -16,7 +16,7 @@ publish_to: "none" # Remove this line if you wish to publish to pub.dev
|
||||
# https://developer.apple.com/library/archive/documentation/General/Reference/InfoPlistKeyReference/Articles/CoreFoundationKeys.html
|
||||
# In Windows, build-name is used as the major, minor, and patch parts
|
||||
# of the product and file versions while build-number is used as the build suffix.
|
||||
version: 1.0.7+1
|
||||
version: 1.0.9+12
|
||||
|
||||
environment:
|
||||
sdk: ">=3.3.0 <4.0.0"
|
||||
@ -36,6 +36,7 @@ dependencies:
|
||||
|
||||
flutter_pdfview: ^1.2.7
|
||||
epub_view: ^3.2.0
|
||||
# vocsy_epub_viewer: ^3.0.0
|
||||
# syncfusion_flutter_pdfviewer: ^22.2.5
|
||||
# pdfx: ^2.4.0
|
||||
|
||||
|
Reference in New Issue
Block a user