Commit c4768d23 authored by nanahira's avatar nanahira

change url

parent 47f3b906
...@@ -94,34 +94,47 @@ export class App { ...@@ -94,34 +94,47 @@ export class App {
background: string; background: string;
price: { [currency: string]: string }; price: { [currency: string]: string };
key?: string; key?: string
static getQuerySuffix(platform: string, locale: string, arch: string) {
const params = new URLSearchParams();
params.set('platform', platform);
params.set('locale', locale);
params.set('platform', arch);
return params.toString();
}
static downloadUrl(app: App, platform: string, locale: string): string { static downloadUrl(app: App, platform: string, locale: string, arch: string): string {
/*
if (app.id === 'ygopro') { if (app.id === 'ygopro') {
return `https://sthief.moecube.com:444/metalinks/${app.id}-${process.platform}-${locale}/${app.version}`; return `https://sthief.moecube.com:444/metalinks/${app.id}-${process.platform}-${locale}/${app.version}`;
} else if (app.id === 'desmume') { } else if (app.id === 'desmume') {
return `https://sthief.moecube.com:444/metalinks/${app.id}-${process.platform}/${app.version}`; return `https://sthief.moecube.com:444/metalinks/${app.id}-${process.platform}/${app.version}`;
} }
return `https://sthief.moecube.com:444/metalinks/${app.id}/${app.version}`; return `https://sthief.moecube.com:444/metalinks/${app.id}/${app.version}`;
*/
return `https://sapi.moecube.com:444/release/update/metalinks/${app.id}/${app.version}?${this.getQuerySuffix(platform, locale, arch)}`;
} }
static checksumUrl(app: App, platform: string, locale: string): string { static checksumUrl(app: App, platform: string, locale: string, arch: string): string {
if (app.id === 'ygopro') { /*if (app.id === 'ygopro') {
return `https://sthief.moecube.com:444/checksums/${app.id}-${platform}-${locale}/${app.version}`; return `https://sthief.moecube.com:444/checksums/${app.id}-${platform}-${locale}/${app.version}`;
} else if (app.id === 'desmume') { } else if (app.id === 'desmume') {
return `https://sthief.moecube.com:444/checksums/${app.id}-${platform}/${app.version}`; return `https://sthief.moecube.com:444/checksums/${app.id}-${platform}/${app.version}`;
} }
return `https://sthief.moecube.com:444/checksums/${app.id}/${app.version}`; return `https://sthief.moecube.com:444/checksums/${app.id}/${app.version}`;*/
return `https://sapi.moecube.com:444/release/update/checksums/${app.id}/${app.version}?${this.getQuerySuffix(platform, locale, arch)}`;
} }
static updateUrl(app: App, platform: string, locale: string): string { static updateUrl(app: App, platform: string, locale: string, arch: string): string {
if (app.id === 'ygopro') { /*if (app.id === 'ygopro') {
return `https://sthief.moecube.com:444/update/${app.id}-${platform}-${locale}/${app.version}`; return `https://sthief.moecube.com:444/update/${app.id}-${platform}-${locale}/${app.version}`;
} else if (app.id === 'desmume') { } else if (app.id === 'desmume') {
return `https://sthief.moecube.com:444/update/${app.id}-${platform}/${app.version}`; return `https://sthief.moecube.com:444/update/${app.id}-${platform}/${app.version}`;
} }*/
return `https://sthief.moecube.com:444/update/${app.id}/${app.version}`; return `https://sapi.moecube.com:444/release/update/update/${app.id}/${app.version}?${this.getQuerySuffix(platform, locale, arch)}`;
} }
isBought(): Boolean { isBought(): Boolean {
......
...@@ -21,6 +21,7 @@ import {ComparableSet} from './shared/ComparableSet'; ...@@ -21,6 +21,7 @@ import {ComparableSet} from './shared/ComparableSet';
import {AppsJson} from './apps-json-type'; import {AppsJson} from './apps-json-type';
import Timer = NodeJS.Timer; import Timer = NodeJS.Timer;
import ReadableStream = NodeJS.ReadableStream; import ReadableStream = NodeJS.ReadableStream;
import * as os from 'os';
const Logger = { const Logger = {
info: (...message: any[]) => { info: (...message: any[]) => {
...@@ -81,7 +82,7 @@ export class AppsService { ...@@ -81,7 +82,7 @@ export class AppsService {
} }
async loadApps() { async loadApps() {
let appsURL = 'https://sapi.moecube.com:444/apps.json'; let appsURL = 'https://sapi.moecube.com:444/release/update/apps.json';
let keysURL = 'https://sapi.moecube.com:444/keys'; let keysURL = 'https://sapi.moecube.com:444/keys';
try { try {
let data = await this.http.get(appsURL) let data = await this.http.get(appsURL)
...@@ -640,7 +641,7 @@ export class AppsService { ...@@ -640,7 +641,7 @@ export class AppsService {
if (!['zh-CN', 'en-US', 'ja-JP'].includes(locale)) { if (!['zh-CN', 'en-US', 'ja-JP'].includes(locale)) {
locale = 'en-US'; locale = 'en-US';
} }
let updateUrl = App.updateUrl(app, process.platform, locale); let updateUrl = App.updateUrl(app, process.platform, locale, os.arch());
let metalink = await this.http.post(updateUrl, changedFiles).map((response) => response.text()).toPromise(); let metalink = await this.http.post(updateUrl, changedFiles).map((response) => response.text()).toPromise();
let downloadDir = path.join(path.dirname(app.local!.path), 'downloading'); let downloadDir = path.join(path.dirname(app.local!.path), 'downloading');
let downloadId = await this.downloadService.addMetalink(metalink, downloadDir); let downloadId = await this.downloadService.addMetalink(metalink, downloadDir);
...@@ -698,7 +699,7 @@ export class AppsService { ...@@ -698,7 +699,7 @@ export class AppsService {
if (!['zh-CN', 'en-US', 'ja-JP'].includes(locale)) { if (!['zh-CN', 'en-US', 'ja-JP'].includes(locale)) {
locale = 'en-US'; locale = 'en-US';
} }
let metalinkUrl = App.downloadUrl(_app, process.platform, locale); let metalinkUrl = App.downloadUrl(_app, process.platform, locale, os.arch());
_app.status.status = 'downloading'; _app.status.status = 'downloading';
let metalink = await this.http.get(metalinkUrl).map((response) => response.text()).toPromise(); let metalink = await this.http.get(metalinkUrl).map((response) => response.text()).toPromise();
let downloadId = await this.downloadService.addMetalink(metalink, dir); let downloadId = await this.downloadService.addMetalink(metalink, dir);
...@@ -1096,7 +1097,7 @@ export class AppsService { ...@@ -1096,7 +1097,7 @@ export class AppsService {
locale = 'en-US'; locale = 'en-US';
} }
let checksumUrl = App.checksumUrl(app, process.platform, locale); let checksumUrl = App.checksumUrl(app, process.platform, locale, os.arch());
return this.http.get(checksumUrl) return this.http.get(checksumUrl)
.map((response) => { .map((response) => {
let map = new Map<string, string>(); let map = new Map<string, string>();
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment