Initial Commit

This commit is contained in:
Nemo 2021-04-06 20:21:07 +05:30
commit 615effc563
3 changed files with 86 additions and 0 deletions

7
LICENSE Normal file
View File

@ -0,0 +1,7 @@
Copyright 2021 Abhay Rana
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

11
README.md Normal file
View File

@ -0,0 +1,11 @@
# foreteller-dl
Download media from the https://www.foretellergames.com/ store without installing the application.
I didn't like the application UX, so wrote this hacky script instead.
Currently somewhat broken. Not 100% tested. Downloads Gloomhaven: Jaws of the Lion by default.
## License
Licensed under the [MIT License](https://nemo.mit-license.org/). See LICENSE file for details.

68
run.php Normal file
View File

@ -0,0 +1,68 @@
<?php
const BASE_URL = 'https://us-central1-forteller-platform.cloudfunctions.net/games/FF2K2f7IRo6VvzacwW3v/containers/';
const AUDIO_BASE_URL = 'https://us-central1-forteller-platform.cloudfunctions.net/audio/zOoRCBJBRD47XjQAmAkS/';
const LOGIN_URL = 'https://www.googleapis.com/identitytoolkit/v3/relyingparty/verifyPassword';
const APP_KEY = 'AIzaSyAs2zSk1Xx-yq6pu4GNCqOUPLuCD1HPDYo';
const EMAIL = 'YOUR_EMAIL_GOES_HERE';
const PASSWORD = 'YOUR_FORETELLER_PASSWORD_GOES_HERE';
function login() {
$body = json_encode(["email"=>EMAIL,"returnSecureToken"=>false,"password"=>PASSWORD]);
echo $body;exit;
$ch = curl_init('https://www.googleapis.com/identitytoolkit/v3/relyingparty/verifyPassword?key=' . APP_KEY);
curl_setopt_array($ch, array(
CURLOPT_POST => TRUE,
CURLOPT_RETURNTRANSFER => TRUE,
CURLOPT_POSTFIELDS => $body
));
$response = curl_exec($ch);
if($response === false){
die(curl_error($ch));
}
$responseData = json_decode($response, true);
return $responseData['idToken'];
}
function request($url, $accept = 'application/json') {
global $jwt;
$opts = [
"http" => [
"method" => "GET",
"header" => "Accept: $accept\r\n" .
"Authorization: Bearer $jwt\r\n"
]
];
$context = stream_context_create($opts);
return file_get_contents($url, false, $context);
}
$jwt = login();
$scenarios = json_decode(file_get_contents('scenarios.json'), true);
foreach ($scenarios as $s) {
$sid = $s['id'];
$scenarioName = $s['name'];
@mkdir($scenarioName, 0777);
$itemsUrl = BASE_URL . $sid . '/items';
$data = json_decode(request($itemsUrl), true);
foreach ($data as $track) {
$trackName = $track['name'];
$streamUrlParts = explode('/', $track['streamUri']);
$trackUrl = AUDIO_BASE_URL . $streamUrlParts[3] . '/' . $streamUrlParts[4];
$filename = "$scenarioName/$trackName.mp3";
echo "$filename\n";
if (!file_exists($filename)) {
$track_data = request($trackUrl, 'audio/mpeg');
file_put_contents($filename, $track_data);
}
}
}