-
-
Notifications
You must be signed in to change notification settings - Fork 125
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
dd54d64
commit b8c5446
Showing
23 changed files
with
962 additions
and
546 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,3 @@ | ||
export * from './steamgriddb'; | ||
export * from './consolegrid'; | ||
export * from './consolegrid'; | ||
export * from './retrogaming.cloud'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,101 @@ | ||
import { GenericImageProvider, ImageContent, ImageProviderData } from "../../models"; | ||
import { Http, Headers, URLSearchParams } from '@angular/http'; | ||
import { Observable } from "rxjs"; | ||
|
||
export class RetroGamingCloudProvider implements GenericImageProvider { | ||
constructor(private http: Http, private downloadInterrupt: Observable<any>, private timeout: number = 40000, private retryCount: number = 3) { } | ||
|
||
getProvider() { | ||
return 'retrogaming.cloud'; | ||
} | ||
|
||
retrieveUrls(title: string) { | ||
let data: ImageProviderData = { images: [], failed: [] }; | ||
|
||
return this.retrieveImageList(title).then((listData) => { | ||
if (listData.failed) { | ||
data.failed.push(listData.failed); | ||
listData.list = []; | ||
} | ||
return listData; | ||
}).then((listData) => { | ||
if (listData.list.length > 0) { | ||
let promises: Promise<{ images: ImageContent[], failed: string[] }>[] = []; | ||
for (let i = 0; i < listData.list.length; i++) { | ||
if (listData.list[i].id !== undefined) | ||
promises.push(this.retrieveMediaData(listData.list[i].id)); | ||
} | ||
return Promise.all(promises).then((results) => { | ||
for (let i = 0; i < results.length; i++) { | ||
data.images = data.images.concat(results[i].images); | ||
data.failed = data.failed.concat(results[i].failed); | ||
} | ||
}); | ||
} | ||
}).then(() => { | ||
return data; | ||
}); | ||
} | ||
|
||
private retrieveMediaData(gameId: number) { | ||
return new Promise<{ images: ImageContent[], failed: string[] }>((resolve, reject) => { | ||
let data: { images: ImageContent[], failed: string[] } = { images: [], failed: [] }; | ||
let downloadStop = this.downloadInterrupt.subscribe(() => downloadStop.unsubscribe()); | ||
let subscription = this.http.get(`http://retrogaming.cloud/api/v1/game/${gameId}/media`).timeout(this.timeout).retry(this.retryCount).subscribe( | ||
(response) => { | ||
let returndeData = response.json(); | ||
let results = returndeData.results || []; | ||
|
||
for (let i = 0; i < results.length; i++) { | ||
if (results[i].url) | ||
data.images.push({imageProvider: this.getProvider(), imageUploader: results[i].created_by ? results[i].created_by.name : undefined, imageUrl: results[i].url, loadStatus: 'none'}); | ||
} | ||
|
||
if (!downloadStop.closed) | ||
downloadStop.unsubscribe(); | ||
}, | ||
(error) => { | ||
data.failed.push(`${error} (http://retrogaming.cloud/api/v1/game/${gameId}/media)`); | ||
|
||
if (!downloadStop.closed) | ||
downloadStop.unsubscribe(); | ||
} | ||
) | ||
downloadStop.add(() => { | ||
if (!subscription.closed) | ||
subscription.unsubscribe(); | ||
resolve(data); | ||
}); | ||
}); | ||
} | ||
|
||
private retrieveImageList(title: string) { | ||
let params = new URLSearchParams(); | ||
params.append('name', title); | ||
|
||
return new Promise<{ list: any[], failed: string }>((resolve, reject) => { | ||
let data: { list: any[], failed: string } = { list: undefined, failed: undefined }; | ||
let downloadStop = this.downloadInterrupt.subscribe(() => downloadStop.unsubscribe()); | ||
let subscription = this.http.get('http://retrogaming.cloud/api/v1/game', { params: params }).timeout(this.timeout).retry(this.retryCount).subscribe( | ||
(response) => { | ||
let returndeData = response.json(); | ||
data.list = returndeData.results || []; | ||
|
||
if (!downloadStop.closed) | ||
downloadStop.unsubscribe(); | ||
}, | ||
(error) => { | ||
data.failed = `${error} (http://retrogaming.cloud/api/v1/game?${params.toString()})`; | ||
|
||
if (!downloadStop.closed) | ||
downloadStop.unsubscribe(); | ||
} | ||
) | ||
downloadStop.add(() => { | ||
if (!subscription.closed) | ||
subscription.unsubscribe(); | ||
resolve(data); | ||
}); | ||
}); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
export * from './file-parser'; | ||
export * from './vdfList'; | ||
export * from './reference'; | ||
export * from './image-provider'; | ||
export * from './fuzzy-matcher'; | ||
export * from './fuzzy-matcher'; | ||
export * from './vdf-manager'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.