Skip to content

Commit

Permalink
Fixed download failing due to change in Anna's archive website
Browse files Browse the repository at this point in the history
  • Loading branch information
dstark5 committed Sep 11, 2023
1 parent 546805b commit ccd260d
Show file tree
Hide file tree
Showing 5 changed files with 27 additions and 7 deletions.
16 changes: 15 additions & 1 deletion fastlane/metadata/android/en-US/full_description.txt
@@ -1 +1,15 @@
<p><i>Openlib</i> is an open source app to download and read books from shadow library (<a href='https://annas-archive.org/' target='_blank' rel='nofollow noopener'>Anna’s Archive</a>). The App Has Built In Reader to Read Books.</p><p>As <i>Anna’s Archive</i> doesn't have an API, the app works by sending requests to <i>Anna’s Archive</i> and parses the response to objects. The app extracts the mirrors from the responses, downloads the book and stores it in the application's document directory.</p><p>Features include a.o.:</p><ul><li>Trending Books</li><li>Download And Read Books With In-Built Viewer</li><li>Supports Epub And Pdf Formats</li><li>Filter Books</li><li>Sort Books</li></ul>
<p>
<i>Openlib</i> is an open source app to download and read books from shadow library (<a href='https://annas-archive.org/' target='_blank' rel='nofollow noopener'>Anna’s Archive</a>). The App Has Built In Reader to Read Books.
</p>
<p>
As <i>Anna’s Archive</i> doesn't have an API, the app works by sending requests to <i>Anna’s Archive</i> and parses the response to objects. The app extracts the mirrors from the responses, downloads the book and stores it in the application's document directory.
</p>
<p>Main Features:</p>
<ul>
<li>Trending Books</li>
<li>Download And Read Books With In-Built Viewer</li>
<li>Supports Epub And Pdf Formats</li>
<li>Open Books With Your Favourite Ebooks Reader</li>
<li>Filter Books</li>
<li>Sort Books</li>
</ul>
11 changes: 8 additions & 3 deletions lib/services/annas_archieve.dart
Expand Up @@ -135,14 +135,19 @@ class AnnasArchieve {
Future<BookInfoData?> _bookInfoParser(resData, url) async {
var document = parse(resData.toString());
var main = document.querySelector('main[class="main"]');
var ul = main?.querySelector('ul[class="mb-4"]');
var ul = main?.querySelectorAll('ul[class="mb-4"]');

List<String> mirrors = [];

if (ul != null) {
var a = ul.querySelectorAll('a');
var anchorTags = [];
if (ul.length == 2) {
anchorTags = ul[1].querySelectorAll('a');
} else {
anchorTags = ul[0].querySelectorAll('a');
}

for (var element in a) {
for (var element in anchorTags) {
if (element.attributes['href']!.startsWith('https://')) {
if (element.attributes['href'] != null) {
mirrors.add(element.attributes['href']!);
Expand Down
3 changes: 2 additions & 1 deletion lib/services/download_file.dart
Expand Up @@ -14,7 +14,8 @@ List<String> _reorderMirrors(List<String> mirrors) {
if (element.contains('ipfs') == true) {
ipfsMirrors.add(element);
} else {
if (element.startsWith('https://annas-archive.gs') != true) {
if (element.startsWith('https://annas-archive.gs') != true &&
element.startsWith('https://1lib.sk') != true) {
httpsMirrors.add(element);
}
}
Expand Down
2 changes: 1 addition & 1 deletion lib/ui/about_page.dart
Expand Up @@ -43,7 +43,7 @@ class AboutPage extends StatelessWidget {
Padding(
padding: EdgeInsets.only(left: 7, right: 7, top: 5),
child: Text(
"1.0.1",
"1.0.2",
style: TextStyle(
fontSize: 15,
fontWeight: FontWeight.bold,
Expand Down
2 changes: 1 addition & 1 deletion pubspec.yaml
Expand Up @@ -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.1+1
version: 1.0.2+1

environment:
sdk: '>=3.0.5 <4.0.0'
Expand Down

0 comments on commit ccd260d

Please sign in to comment.