File tree Expand file tree Collapse file tree 7 files changed +53
-8
lines changed
Expand file tree Collapse file tree 7 files changed +53
-8
lines changed Original file line number Diff line number Diff line change @@ -44,6 +44,7 @@ class Common {
4444 httpClient.connectionTimeout = Duration (seconds: 10 );
4545 var request = await httpClient.getUrl (uri);
4646 request.headers.set ("User-Agent" , "RSSAid" );
47+
4748 var response = await request.close ();
4849 if (response.statusCode == HttpStatus .ok) {
4950 content = await response.transform (utf8.decoder).join ();
Original file line number Diff line number Diff line change 1- class Radar {
1+ import 'package:equatable/equatable.dart' ;
2+
3+ class Radar extends Equatable {
24 String ? title;
35 String ? path;
46 bool isRssHub = true ;
@@ -18,4 +20,8 @@ class Radar {
1820 ? []
1921 : json.map ((value) => Radar .fromJson (value)).toList ();
2022 }
23+
24+ @override
25+ List <Object ?> get props => [title, path];
26+
2127}
Original file line number Diff line number Diff line change @@ -43,17 +43,17 @@ class RssHub {
4343 return radars;
4444 }
4545
46- List <dynamic > rules = rssHubRules[domain][subdomain ?? "." ];
46+ List <dynamic >? rules = rssHubRules[domain][subdomain ?? "." ];
4747
48- if (rules.isEmpty) {
49- if (subdomain == "www" ) {
48+ if (rules == null || rules .isEmpty) {
49+ if (subdomain == "www" || subdomain == 'mobile' || subdomain == 'm' ) {
5050 rules = rssHubRules[domain]["." ];
5151 } else if (subdomain! .isEmpty) {
5252 rules = rssHubRules[domain]['www' ];
5353 }
5454 }
5555
56- if (rules.isEmpty) {
56+ if (rules == null || rules .isEmpty) {
5757 return radars;
5858 }
5959
Original file line number Diff line number Diff line change 1+ import 'dart:io' ;
2+
3+ import 'package:rssaid/common/common.dart' ;
4+
5+ class UrlUtils {
6+ static getPcWebSiteUrl (String url) async {
7+ try {
8+ var httpClient = await new HttpClient ().autoProxy ();
9+ httpClient.connectionTimeout = Duration (seconds: 10 );
10+ var request = await httpClient.getUrl (Uri .parse (url));
11+ // TODO random pc user-agent
12+ request.headers.set ("User-Agent" , "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/127.0.0.0 Safari/537.36" );
13+ request.followRedirects = false ;
14+ var response = await request.close ();
15+ if (response.isRedirect) {
16+ final location = response.headers.value (HttpHeaders .locationHeader);
17+ return location;
18+ }
19+ return url;
20+ } catch (error) {
21+ print ('get content by url failed:$error ' );
22+ }
23+ return url;
24+ }
25+ }
Original file line number Diff line number Diff line change @@ -12,6 +12,7 @@ import 'package:rssaid/models/radar.dart';
1212import 'package:rssaid/radar/rss_plus.dart' ;
1313import 'package:rssaid/radar/rsshub.dart' ;
1414import 'package:rssaid/radar/rule_type/page_info.dart' ;
15+ import 'package:rssaid/radar/urlUtils.dart' ;
1516import 'package:rssaid/shared_prefs.dart' ;
1617import 'package:rssaid/views/components/not_found.dart' ;
1718import 'package:rssaid/views/config.dart' ;
@@ -149,8 +150,11 @@ class _HomePageState extends State<HomePage> {
149150 showToast (AppLocalizations .of (context)! .loadRulesFailed);
150151 return [];
151152 }
152- List <Radar > radarList = rssHub.getPageRSSHub (PageInfo (url: url, rules: rules));
153- return [...radarList, ...await RssPlus .detecting (url)];
153+ var pcUrl = await UrlUtils .getPcWebSiteUrl (url);
154+ print ("pcUrl:$pcUrl " );
155+ List <Radar > radarList = rssHub.getPageRSSHub (PageInfo (url: pcUrl, rules: rules));
156+ var radars = [...radarList, ...await RssPlus .detecting (url)];
157+ return radars.toSet ().toList ();
154158 }
155159
156160 @override
Original file line number Diff line number Diff line change @@ -145,6 +145,14 @@ packages:
145145 url: "https://pub.flutter-io.cn"
146146 source: hosted
147147 version: "2.3.6"
148+ equatable:
149+ dependency: "direct main"
150+ description:
151+ name: equatable
152+ sha256: c2b87cb7756efdf69892005af546c56c0b5037f54d2a88269b4f347a505e3ca2
153+ url: "https://pub.flutter-io.cn"
154+ source: hosted
155+ version: "2.0.5"
148156 fake_async:
149157 dependency: transitive
150158 description:
Original file line number Diff line number Diff line change @@ -15,7 +15,7 @@ publish_to: 'none' # Remove this line if you wish to publish to pub.dev
1515# In iOS, build-name is used as CFBundleShortVersionString while build-number used as CFBundleVersion.
1616# Read more about iOS versioning at
1717# https://developer.apple.com/library/archive/documentation/General/Reference/InfoPlistKeyReference/Articles/CoreFoundationKeys.html
18- version : 3.0.1+11
18+ version : 3.0.2+12
1919
2020environment :
2121 sdk : " >=2.12.0 <3.0.0"
@@ -39,6 +39,7 @@ dependencies:
3939 package_info_plus : ^8.0.0
4040 any_link_preview : ^3.0.2
4141 tldts : ^0.0.1-beta
42+ equatable : ^2.0.5
4243 # The following adds the Cupertino Icons font to your application.
4344 # Use with the CupertinoIcons class for iOS style icons.
4445
You can’t perform that action at this time.
0 commit comments