Skip to content

Commit

Permalink
script: request galleries with default headers
Browse files Browse the repository at this point in the history
  • Loading branch information
violet-dev committed Jan 3, 2022
1 parent 977ae36 commit 90826a0
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 1 deletion.
6 changes: 5 additions & 1 deletion lib/script/script_manager.dart
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import 'package:flutter_js/flutter_js.dart';
import 'package:tuple/tuple.dart';
import 'package:violet/log/log.dart';
import 'package:violet/network/wrapper.dart' as http;
import 'package:violet/network/wrapper.dart';
import 'package:violet/widgets/article_item/image_provider_manager.dart';

class ScriptManager {
Expand Down Expand Up @@ -52,7 +53,10 @@ class ScriptManager {
try {
var downloadUrl =
_runtime.evaluate("create_download_url('$id')").stringResult;
var galleryInfo = await http.get(downloadUrl);
var galleryInfo = await http.get(downloadUrl, headers: {
'accept': HttpWrapper.accept,
'user-agent': HttpWrapper.mobileUserAgent,
});
_runtime.evaluate(galleryInfo.body);
final jResult = _runtime.evaluate("hitomi_get_image_list()").stringResult;
final jResultObject = jsonDecode(jResult);
Expand Down
23 changes: 23 additions & 0 deletions test/test_get.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
// This source code is a part of Project Violet.
// Copyright (C) 2020-2022. violet-team. Licensed under the Apache-2.0 License.

import 'package:http/http.dart' as http;
import 'package:flutter/material.dart';
import 'package:flutter_test/flutter_test.dart';
import 'package:violet/network/wrapper.dart';

void main() {
setUp(() async {
WidgetsFlutterBinding.ensureInitialized();
});

test("Test Bookmark", () async {
var res = await http
.get(Uri.parse('https://ltn.hitomi.la/galleries/2102839.js'), headers: {
'accept': HttpWrapper.accept,
'user-agent': HttpWrapper.mobileUserAgent,
});

print(res.body);
});
}

0 comments on commit 90826a0

Please sign in to comment.