Skip to content

Commit

Permalink
[server] update new bbs routes
Browse files Browse the repository at this point in the history
  • Loading branch information
BrightDV committed Jul 19, 2024
1 parent 5532a29 commit 5d981f6
Show file tree
Hide file tree
Showing 9 changed files with 94 additions and 46 deletions.
6 changes: 4 additions & 2 deletions lib/Screens/racehub.dart
Original file line number Diff line number Diff line change
Expand Up @@ -689,7 +689,8 @@ class SessionItem extends StatelessWidget {
children: [
Text(
sessionsAbbreviations[
session.sessionsAbbreviation],
session.sessionsAbbreviation] ??
session.sessionsAbbreviation,
style: TextStyle(
fontSize: 20,
),
Expand Down Expand Up @@ -770,7 +771,8 @@ class SessionItem extends StatelessWidget {
context,
MaterialPageRoute(
builder: (context) => SessionScreen(
sessionsAbbreviations[session.sessionsAbbreviation],
sessionsAbbreviations[session.sessionsAbbreviation] ??
session.sessionsAbbreviation,
session,
meetingCountryName,
meetingOfficialName,
Expand Down
10 changes: 7 additions & 3 deletions lib/api/event_tracker.dart
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,9 @@ class EventTracker {

if (championship == 'Formula 1') {
Uri uri = Uri.parse(
'$endpoint/v1/event-tracker',
endpoint != defaultEndpoint
? '$endpoint/f1/v1/event-tracker'
: '$endpoint/v1/event-tracker',
);
Response res = await get(
uri,
Expand Down Expand Up @@ -136,7 +138,7 @@ class EventTracker {
Response res = await get(
Uri.parse(
endpoint != defaultEndpoint
? '$endpoint/formula-e/v1/races/$raceId'
? '$endpoint/fe/formula-e/v1/races/$raceId'
: '$feEndpoint/formula-e/v1/races/$raceId',
),
headers: {
Expand Down Expand Up @@ -313,7 +315,9 @@ class EventTracker {
.get('useOfficialDataSoure', defaultValue: false) as bool;

Uri uri = Uri.parse(
'$endpoint/v1/event-tracker/meeting/$formulaOneCircuitId',
endpoint != defaultEndpoint
? '$endpoint/f1/v1/event-tracker/meeting/$formulaOneCircuitId'
: '$endpoint/v1/event-tracker/meeting/$formulaOneCircuitId',
);

Response res = await get(
Expand Down
56 changes: 40 additions & 16 deletions lib/api/formula1.dart
Original file line number Diff line number Diff line change
Expand Up @@ -85,13 +85,22 @@ class Formula1 {
.get('server', defaultValue: defaultEndpoint) as String;
if (tagId != null) {
url = Uri.parse(
'$endpoint/v1/editorial/articles?limit=16&offset=$offset&tags=$tagId');
endpoint != defaultEndpoint
? '$endpoint/f1/v1/editorial/articles?limit=16&offset=$offset&tags=$tagId'
: '$endpoint/v1/editorial/articles?limit=16&offset=$offset&tags=$tagId',
);
} else if (articleType != null) {
url = Uri.parse(
'$endpoint/v1/editorial/articles?limit=16&offset=$offset&articleTypes=$articleType');
endpoint != defaultEndpoint
? '$endpoint/f1/v1/editorial/articles?limit=16&offset=$offset&articleTypes=$articleType'
: '$endpoint/v1/editorial/articles?limit=16&offset=$offset&articleTypes=$articleType',
);
} else {
url =
Uri.parse('$endpoint/v1/editorial/articles?limit=16&offset=$offset');
url = Uri.parse(
endpoint != defaultEndpoint
? '$endpoint/f1/v1/editorial/articles?limit=16&offset=$offset'
: '$endpoint/v1/editorial/articles?limit=16&offset=$offset',
);
}
var response = await http.get(
url,
Expand Down Expand Up @@ -124,11 +133,16 @@ class Formula1 {
.get('server', defaultValue: defaultEndpoint) as String;
if (articleType != null) {
url = Uri.parse(
'$endpoint/v1/editorial/articles?limit=16&tags=${tags.join(',')}&articleTypes=$articleType',
endpoint != defaultEndpoint
? '$endpoint/f1/v1/editorial/articles?limit=16&tags=${tags.join(',')}&articleTypes=$articleType'
: '$endpoint/v1/editorial/articles?limit=16&tags=${tags.join(',')}&articleTypes=$articleType',
);
} else {
url = Uri.parse(
'$endpoint/v1/editorial/articles?limit=16&tags=${tags.join(',')}');
endpoint != defaultEndpoint
? '$endpoint/f1/v1/editorial/articles?limit=16&tags=${tags.join(',')}'
: '$endpoint/v1/editorial/articles?limit=16&tags=${tags.join(',')}',
);
}
var response = await http.get(
url,
Expand All @@ -151,7 +165,11 @@ class Formula1 {
Future<Article> getArticleData(String articleId) async {
String endpoint = Hive.box('settings')
.get('server', defaultValue: defaultEndpoint) as String;
Uri url = Uri.parse('$endpoint/v1/editorial/articles/$articleId');
Uri url = Uri.parse(
endpoint != defaultEndpoint
? '$endpoint/f1/v1/editorial/articles/$articleId'
: '$endpoint/v1/editorial/articles/$articleId',
);
var response = await http.get(
url,
headers: endpoint != defaultEndpoint
Expand Down Expand Up @@ -329,7 +347,7 @@ class Formula1 {
.get('server', defaultValue: defaultEndpoint) as String;
Uri url = Uri.parse(
endpoint != defaultEndpoint
? '$endpoint/v1/fom-results/race/meeting=$meetingId'
? '$endpoint/f1/v1/fom-results/race/meeting=$meetingId'
: '$endpoint/v1/fom-results/race?meeting=$meetingId',
);
var response = await http.get(
Expand Down Expand Up @@ -364,7 +382,7 @@ class Formula1 {
.get('server', defaultValue: defaultEndpoint) as String;
Uri url = Uri.parse(
endpoint != defaultEndpoint
? '$endpoint/v1/fom-results/qualifying/meeting=$meetingId'
? '$endpoint/f1/v1/fom-results/qualifying/meeting=$meetingId'
: '$endpoint/v1/fom-results/qualifying?meeting=$meetingId',
);
var response = await http.get(
Expand Down Expand Up @@ -422,7 +440,7 @@ class Formula1 {
.get('server', defaultValue: defaultEndpoint) as String;
Uri url = Uri.parse(
endpoint != defaultEndpoint
? '$endpoint/v1/fom-results/practice/meeting=$meetingId&session=$session'
? '$endpoint/f1/v1/fom-results/practice/meeting=$meetingId&session=$session'
: '$endpoint/v1/fom-results/practice?meeting=$meetingId&session=$session',
);
var response = await http.get(
Expand Down Expand Up @@ -484,7 +502,7 @@ class Formula1 {
.get('server', defaultValue: defaultEndpoint) as String;
Uri url = Uri.parse(
endpoint != defaultEndpoint
? '$endpoint/v1/fom-results/sprint-shootout/meeting=$meetingId'
? '$endpoint/f1/v1/fom-results/sprint-shootout/meeting=$meetingId'
: '$endpoint/v1/fom-results/sprint-shootout?meeting=$meetingId',
);
var response = await http.get(
Expand Down Expand Up @@ -543,7 +561,7 @@ class Formula1 {
.get('server', defaultValue: defaultEndpoint) as String;
Uri url = Uri.parse(
endpoint != defaultEndpoint
? '$endpoint/v1/fom-results/sprint/meeting=$meetingId'
? '$endpoint/f1/v1/fom-results/sprint/meeting=$meetingId'
: '$endpoint/v1/fom-results/sprint?meeting=$meetingId',
);
var response = await http.get(
Expand Down Expand Up @@ -667,7 +685,9 @@ class Formula1 {
String endpoint = Hive.box('settings')
.get('server', defaultValue: defaultEndpoint) as String;
var url = Uri.parse(
'$endpoint/v1/editorial-driverlisting/listing',
endpoint != defaultEndpoint
? '$endpoint/f1/v1/editorial-driverlisting/listing'
: '$endpoint/v1/editorial-driverlisting/listing',
);
var response = await http.get(
url,
Expand Down Expand Up @@ -740,7 +760,9 @@ class Formula1 {
String endpoint = Hive.box('settings')
.get('server', defaultValue: defaultEndpoint) as String;
Uri url = Uri.parse(
'$endpoint/v1/editorial-constructorlisting/listing',
endpoint != defaultEndpoint
? '$endpoint/f1/v1/editorial-constructorlisting/listing'
: '$endpoint/v1/editorial-constructorlisting/listing',
);
var response = await http.get(
url,
Expand Down Expand Up @@ -879,7 +901,9 @@ class Formula1 {
String endpoint = Hive.box('settings')
.get('server', defaultValue: defaultEndpoint) as String;
Uri url = Uri.parse(
'$endpoint/v1/editorial-eventlisting/events',
endpoint != defaultEndpoint
? '$endpoint/f1/v1/editorial-eventlisting/events'
: '$endpoint/v1/editorial-eventlisting/events',
);
var response = await http.get(
url,
Expand Down Expand Up @@ -909,7 +933,7 @@ class Formula1 {
.get('server', defaultValue: defaultEndpoint) as String;
Uri url = Uri.parse(
endpoint != defaultEndpoint
? '$endpoint/v1/fom-results/starting-grid/meeting=$meetingId'
? '$endpoint/f1/v1/fom-results/starting-grid/meeting=$meetingId'
: '$endpoint/v1/fom-results/starting-grid?meeting=$meetingId',
);
var response = await http.get(
Expand Down
24 changes: 12 additions & 12 deletions lib/api/formulae.dart
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ class FormulaE {
.get('server', defaultValue: defaultF1Endpoint) as String;
Uri url = Uri.parse(
endpoint != defaultF1Endpoint
? '$endpoint/content/formula-e/text/EN/$articleId'
? '$endpoint/fe/content/formula-e/text/EN/$articleId'
: '$defaultEndpoint/content/formula-e/text/EN/$articleId',
);

Expand Down Expand Up @@ -118,8 +118,8 @@ class FormulaE {
.get('server', defaultValue: defaultF1Endpoint) as String;
Uri url = Uri.parse(
endpoint != defaultF1Endpoint
? '$endpoint/content/formula-e/text/EN/page=$page&pageSize=16&tagNames=content-type%3Anews&tagExpression=&playlistTypeRestriction=&playlistId=&detail=&size=16&championshipId=&sort='
: '$defaultEndpoint/content/formula-e/text/EN/?page=$page&pageSize=16&tagNames=content-type%3Anews&tagExpression=&playlistTypeRestriction=&playlistId=&detail=&size=16&championshipId=&sort=',
? '$endpoint/fe/content/formula-e/text/EN/page=$page&pageSize=16&tagNames=content-type:news&tagExpression=&playlistTypeRestriction=&playlistId=&detail=&size=16&championshipId=&sort='
: '$defaultEndpoint/content/formula-e/text/EN/?page=$page&pageSize=16&tagNames=content-type:news&tagExpression=&playlistTypeRestriction=&playlistId=&detail=&size=16&championshipId=&sort=',
);

var response = await http.get(
Expand Down Expand Up @@ -180,7 +180,7 @@ class FormulaE {
.get('server', defaultValue: defaultF1Endpoint) as String;
Uri url = Uri.parse(
endpoint != defaultF1Endpoint
? '$endpoint/content/formula-e/playlist/EN/15/page=$page&pageSize=$limit&detail=DETAILED&size=$limit'
? '$endpoint/fe/content/formula-e/playlist/EN/15/page=$page&pageSize=$limit&detail=DETAILED&size=$limit'
: '$defaultEndpoint/content/formula-e/playlist/EN/15?page=$page&pageSize=$limit&detail=DETAILED&size=$limit',
);

Expand Down Expand Up @@ -239,7 +239,7 @@ class FormulaE {
.get('server', defaultValue: defaultF1Endpoint) as String;
Uri url = Uri.parse(
endpoint != defaultF1Endpoint
? '$endpoint/formula-e/v1/standings/drivers/championshipId=$championshipId'
? '$endpoint/fe/formula-e/v1/standings/drivers/championshipId=$championshipId'
: '$defaultEndpoint/formula-e/v1/standings/drivers?championshipId=$championshipId',
);
var response = await http.get(
Expand Down Expand Up @@ -297,7 +297,7 @@ class FormulaE {
.get('server', defaultValue: defaultF1Endpoint) as String;
Uri url = Uri.parse(
endpoint != defaultF1Endpoint
? '$endpoint/formula-e/v1/standings/teams/championshipId=$championshipId'
? '$endpoint/fe/formula-e/v1/standings/teams/championshipId=$championshipId'
: '$defaultEndpoint/formula-e/v1/standings/teams?championshipId=$championshipId',
);
var response = await http.get(
Expand Down Expand Up @@ -398,7 +398,7 @@ class FormulaE {
.get('server', defaultValue: defaultF1Endpoint) as String;
Uri url = Uri.parse(
endpoint != defaultF1Endpoint
? '$endpoint/formula-e/v1/races/championshipId=$championshipId'
? '$endpoint/fe/formula-e/v1/races/championshipId=$championshipId'
: '$defaultEndpoint/formula-e/v1/races?championshipId=$championshipId',
);
var response = await http.get(
Expand All @@ -425,7 +425,7 @@ class FormulaE {
.get('server', defaultValue: defaultF1Endpoint) as String;
Uri url = Uri.parse(
endpoint != defaultF1Endpoint
? '$endpoint/formula-e/v1/races/$raceId/sessions'
? '$endpoint/fe/formula-e/v1/races/$raceId/sessions'
: '$defaultEndpoint/formula-e/v1/races/$raceId/sessions',
);
var response = await http.get(
Expand Down Expand Up @@ -563,7 +563,7 @@ class FormulaE {
.get('server', defaultValue: defaultF1Endpoint) as String;
Uri url = Uri.parse(
endpoint != defaultF1Endpoint
? '$endpoint/content/formula-e/EN/contentTypes=video&contentTypes=news&page=0&pageSize=10&references=FORMULA_E_RACE:${race.meetingId}&onlyRestrictedContent=false&detail=DETAILED'
? '$endpoint/fe/content/formula-e/EN/contentTypes=video&contentTypes=news&page=0&pageSize=10&references=FORMULA_E_RACE:${race.meetingId}&onlyRestrictedContent=false&detail=DETAILED'
: '$defaultEndpoint/content/formula-e/EN?contentTypes=video&contentTypes=news&page=0&pageSize=10&references=FORMULA_E_RACE:${race.meetingId}&onlyRestrictedContent=false&detail=DETAILED',
);
http.Response response = await http.get(
Expand Down Expand Up @@ -648,7 +648,7 @@ class FormulaE {
.get('server', defaultValue: defaultF1Endpoint) as String;
Uri url = Uri.parse(
endpoint != defaultF1Endpoint
? '$endpoint/formula-e/v1/races/$raceId/sessions/$sessionId/results'
? '$endpoint/fe/formula-e/v1/races/$raceId/sessions/$sessionId/results'
: '$defaultEndpoint/formula-e/v1/races/$raceId/sessions/$sessionId/results',
);
var response = await http.get(
Expand Down Expand Up @@ -861,7 +861,7 @@ class FormulaE {
.get('server', defaultValue: defaultF1Endpoint) as String;
Uri url = Uri.parse(
endpoint != defaultF1Endpoint
? '$endpoint/content/formula-e/photo/en/references=FORMULA_E_RACE:$raceId&tagNames=race:bg-image'
? '$endpoint/fe/content/formula-e/photo/en/references=FORMULA_E_RACE:$raceId&tagNames=race:bg-image'
: '$defaultEndpoint/content/formula-e/photo/en/?references=FORMULA_E_RACE:$raceId&tagNames=race:bg-image',
);
var response = await http.get(
Expand All @@ -882,7 +882,7 @@ class FormulaE {
.get('server', defaultValue: defaultF1Endpoint) as String;
Uri url = Uri.parse(
endpoint != defaultF1Endpoint
? '$endpoint/formula-e/v1/championships/latest'
? '$endpoint/fe/formula-e/v1/championships/latest'
: '$defaultEndpoint/formula-e/v1/championships/latest',
);
var response = await http.get(
Expand Down
14 changes: 11 additions & 3 deletions lib/api/videos.dart
Original file line number Diff line number Diff line change
Expand Up @@ -68,10 +68,16 @@ class F1VideosFetcher {
Uri url;
if (tag != '') {
url = Uri.parse(
'$endpoint/v1/video-assets/videos?limit=$limit&tag=$tag&offset=$offset');
endpoint != defaultEndpoint
? '$endpoint/f1/v1/video-assets/videos?limit=$limit&tag=$tag&offset=$offset'
: '$endpoint/v1/video-assets/videos?limit=$limit&tag=$tag&offset=$offset',
);
} else {
url = Uri.parse(
'$endpoint/v1/video-assets/videos?limit=$limit&offset=$offset');
endpoint != defaultEndpoint
? '$endpoint/f1/v1/video-assets/videos?limit=$limit&offset=$offset'
: '$endpoint/v1/video-assets/videos?limit=$limit&offset=$offset',
);
}
var response = await http.get(
url,
Expand All @@ -96,7 +102,9 @@ class F1VideosFetcher {
String endpoint = Hive.box('settings')
.get('server', defaultValue: defaultEndpoint) as String;
Uri url = Uri.parse(
"$endpoint/v1/video-assets/videos/$videoId",
endpoint != defaultEndpoint
? "$endpoint/f1/v1/video-assets/videos/$videoId"
: "$endpoint/v1/video-assets/videos/$videoId",
);
var response = await http.get(
url,
Expand Down
4 changes: 3 additions & 1 deletion lib/helpers/download.dart
Original file line number Diff line number Diff line change
Expand Up @@ -201,7 +201,9 @@ class DownloadUtils {

final task = DownloadTask(
taskId: taskId,
url: '$endpoint/v1/editorial/articles/$articleId',
url: endpoint != f1Endpoint
? '$endpoint/f1/v1/editorial/articles/$articleId'
: '$endpoint/v1/editorial/articles/$articleId',
filename: '$taskId.json',
displayName: articleTitle,
headers: endpoint != f1Endpoint
Expand Down
2 changes: 1 addition & 1 deletion lib/scraping/fia.dart
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ class FIAScraper {
.get('server', defaultValue: defaultEndpoint) as String;
if (endpoint != defaultEndpoint) {
latestDocumentsUrl = Uri.parse(
'$endpoint/documents',
'$endpoint/f1/documents',
);
} else {
latestDocumentsUrl = Uri.parse(
Expand Down
Loading

0 comments on commit 5d981f6

Please sign in to comment.