commit 615effc563a944e569ee6bf43155d35f9e07065a Author: Nemo Date: Tue Apr 6 20:21:07 2021 +0530 Initial Commit diff --git a/LICENSE b/LICENSE new file mode 100644 index 0000000..b248ac6 --- /dev/null +++ b/LICENSE @@ -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. \ No newline at end of file diff --git a/README.md b/README.md new file mode 100644 index 0000000..799f7f9 --- /dev/null +++ b/README.md @@ -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. \ No newline at end of file diff --git a/run.php b/run.php new file mode 100644 index 0000000..8dd5489 --- /dev/null +++ b/run.php @@ -0,0 +1,68 @@ +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); + } + } +} \ No newline at end of file