Skip to content

Commit

Permalink
Bump version
Browse files Browse the repository at this point in the history
  • Loading branch information
3003h committed Nov 1, 2023
1 parent 630df11 commit 3df4b00
Show file tree
Hide file tree
Showing 17 changed files with 631 additions and 316 deletions.
11 changes: 11 additions & 0 deletions changelog/v1.4.8+518.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
## 修正

- 同步网站关于原图链接的更新,目前旧版本应该无法下载原图
- 导入设置数据时,保持现有设置的下载路径设置,避免跨系统导入数据导致下载路径问题
- 修正一些画廊解析问题

## 新增

- 样式设置中,添加画廊评论显示开关,缩略图显示开关
- 添加水平缩略图布局,可在样式设置中启用
- 将部分数据库操作放到在单独的isolate线程中进行,避免在主线程中进行数据库操作导致的卡顿
1 change: 1 addition & 0 deletions jsons/gallery_provider.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
"filesizeText?" : "",
"visible?": "",
"parent?": "",
"parentHref?": "",
"ratingFallBack?": 4.0,
"numberOfReviews?": "",
"postTime?": "",
Expand Down
16 changes: 3 additions & 13 deletions lib/common/controller/download_controller.dart
Original file line number Diff line number Diff line change
Expand Up @@ -1233,20 +1233,10 @@ class DownloadController extends GetxController {
Future _onDownloadComplete(String fileName, int gid, int itemSer) async {
logger.t('********** $itemSer complete $fileName');

// final task = await isarHelper.findImageTaskAllByGidSer(gid, itemSer);
// logger.d('task is null: ${task == null}');

// 下载完成 更新数据库明细
// logger.t('下载完成 更新数据库明细');
await isarHelper.updateImageTaskStatusIsolate(
gid,
itemSer,
TaskStatus.complete.value,
);

// 更新ui
final List<GalleryImageTask> listComplete = await isarHelper
.finaAllImageTaskByGidAndStatusIsolate(gid, TaskStatus.complete.value);
.onDownloadCompleteIsolate(gid, itemSer, TaskStatus.complete.value);

logger.t(
'listComplete: ${listComplete.length}: ${listComplete.map((e) => e.ser).join(',')}');
Expand All @@ -1261,7 +1251,7 @@ class DownloadController extends GetxController {
}

if (_task != null) {
await isarHelper.putGalleryTaskIsolate(_task);
await isarHelper.putGalleryTask(_task);
}
_updateDownloadView(['DownloadGalleryItem_$gid']);
}
Expand All @@ -1288,7 +1278,7 @@ class DownloadController extends GetxController {
.sublist(0, min(lastCounts.length, checkMaxCount));

logger
.v('${lastCountsTopCheck.join(',')}\n${lastCounts.reversed.join(',')}');
.t('${lastCountsTopCheck.join(',')}\n${lastCounts.reversed.join(',')}');

final speedCheck =
(max(totCurCount - lastCountsTopCheck.reversed.first, 0) /
Expand Down
77 changes: 40 additions & 37 deletions lib/common/parser/gallery_detail_parser.dart
Original file line number Diff line number Diff line change
Expand Up @@ -200,8 +200,6 @@ Future<GalleryProvider> parseGalleryDetail(String response) async {
// 解析响应信息dom
final Document document = parse(response);

// GalleryItem galleryProvider = const GalleryItem();

// 封面图片
final Element? imageElem = document.querySelector('#gd1 > div');
final String _imageElemStyle = imageElem?.attributes['style'] ?? '';
Expand All @@ -217,24 +215,24 @@ Future<GalleryProvider> parseGalleryDetail(String response) async {
}

// 收藏夹序号
String _favcat = '';
final Element? _favcatElm = document.querySelector('#fav');
if (_favcatElm?.nodes.isNotEmpty ?? false) {
final Element? _div = _favcatElm?.querySelector('div');
String _favCat = '';
final Element? _favCatElm = document.querySelector('#fav');
if (_favCatElm?.nodes.isNotEmpty ?? false) {
final Element? _div = _favCatElm?.querySelector('div');
final String _catStyle = _div?.attributes['style'] ?? '';
final String _catPosition = RegExp(r'background-position:0px -(\d+)px;')
.firstMatch(_catStyle)?[1] ??
'';
_favcat = '${(int.parse(_catPosition) - 2) ~/ 19}';
_favCat = '${(int.parse(_catPosition) - 2) ~/ 19}';
}

// apiuid
final String _apiuid =
// apiUid
final String _apiUid =
RegExp(r'var\s*?apiuid\s*?=\s*?(\d+);').firstMatch(response)?.group(1) ??
'';

// apikey
final String _apikey = RegExp(r'var\s*?apikey\s*?=\s*?"([0-9a-f]+)";')
final String _apiKey = RegExp(r'var\s*?apikey\s*?=\s*?"([0-9a-f]+)";')
.firstMatch(response)
?.group(1) ??
'';
Expand All @@ -248,15 +246,6 @@ Future<GalleryProvider> parseGalleryDetail(String response) async {
final _colorRating = _ratingImageClass;
final _isRatinged = _ratingImageClass.contains(RegExp(r'ir([rgby])'));

// 收藏次数
final String _favCount =
document.querySelector('#favcount')?.text.replaceFirstMapped(
RegExp(r'(\d+).+'),
(Match m) => m.group(1) ?? '',
) ??
'';
final _favoritedCount = _favCount;

// 评分人次
final String _ratingCount =
document.querySelector('#rating_count')?.text ?? '';
Expand Down Expand Up @@ -285,21 +274,32 @@ Future<GalleryProvider> parseGalleryDetail(String response) async {
final Element? _elmTorrent =
document.querySelector('#gd5')?.children[2].children[1];
// 种子数量
final _torrentcount =
final _torrentCount =
RegExp(r'\d+').firstMatch(_elmTorrent?.text ?? '')?.group(0) ?? '0';

final String _language = document
.querySelector('#gdd > table > tbody > tr:nth-child(3) > td.gdt2')
?.text
.replaceFirstMapped(
RegExp(r'(\w+).*'),
(Match m) => m.group(1) ?? '',
) ??
'';
final _tBody = document.querySelector('#gdd > table > tbody');
final _listTr = _tBody?.children;
final _mapGdt = <String, Element>{};
// key gdt1, value gdt2
for (final Element? _tr in _listTr ?? []) {
final _listTd = _tr?.children;
if (_listTd?.length == 2) {
_mapGdt[_listTd![0].text.trim()] = _listTd[1];
}
}

final String _fileSize = document
.querySelector('#gdd > table > tbody > tr:nth-child(4) > td.gdt2')
?.text ??
// print('^^^ $_mapGdt');

final String _parent = _mapGdt['Parent:']?.text.trim() ?? '';
final String _parentHref =
_mapGdt['Parent:']?.querySelector('a')?.attributes['href'] ?? '';
final String _visible = _mapGdt['Visible:']?.text.trim() ?? '';
final String _language = _mapGdt['Language:']?.text.trim() ?? '';
final String _fileSize = _mapGdt['File Size:']?.text.trim() ?? '';
final String _postTime = _mapGdt['Posted:']?.text.trim() ?? '';
final String _favCount = RegExp(r'\d+')
.firstMatch(_mapGdt['Favorited:']?.text.trim() ?? '')
?.group(0) ??
'';

final Element? elmCategory = document.querySelector('#gdc > div');
Expand All @@ -310,7 +310,6 @@ Future<GalleryProvider> parseGalleryDetail(String response) async {
final _uploader = document.querySelector('#gdn > a')?.text.trim() ?? '';

final _galleryComments = parseGalleryComment(document);

final _chapter = _parseChapter(_galleryComments);

final galleryProvider = GalleryProvider(
Expand All @@ -320,23 +319,27 @@ Future<GalleryProvider> parseGalleryDetail(String response) async {
galleryImages: parseGalleryImage(document),
chapter: _chapter,
favTitle: _favTitle,
favcat: _favcat,
apiuid: _apiuid,
apikey: _apikey,
favcat: _favCat,
apiuid: _apiUid,
apikey: _apiKey,
archiverLink: _archiverLink,
colorRating: _colorRating,
isRatinged: _isRatinged,
favoritedCount: _favoritedCount,
favoritedCount: _favCount,
ratingCount: _ratingCount,
ratingFallBack: _ratingFB,
rating: _ratingNum,
englishTitle: _englishTitle,
japaneseTitle: _japaneseTitle,
torrentcount: _torrentcount,
torrentcount: _torrentCount,
language: _language,
filesizeText: _fileSize,
category: _category,
uploader: _uploader,
postTime: _postTime,
parent: _parent,
parentHref: _parentHref,
visible: _visible,
);

return galleryProvider;
Expand Down
Loading

0 comments on commit 3df4b00

Please sign in to comment.