Switch to environment variables, finish Docker
This commit is contained in:
parent
1746a22162
commit
941696ad75
|
@ -0,0 +1,2 @@
|
|||
FORTELLER_EMAIL=email@example.com
|
||||
FORTELLER_PASSWORD=password
|
|
@ -0,0 +1,41 @@
|
|||
name: Create and publish a Docker image
|
||||
|
||||
on:
|
||||
push:
|
||||
branches: ['main']
|
||||
|
||||
env:
|
||||
REGISTRY: ghcr.io
|
||||
IMAGE_NAME: ${{ github.repository }}
|
||||
|
||||
jobs:
|
||||
build-and-push-image:
|
||||
runs-on: ubuntu-latest
|
||||
permissions:
|
||||
contents: read
|
||||
packages: write
|
||||
|
||||
steps:
|
||||
- name: Checkout repository
|
||||
uses: actions/checkout@v3
|
||||
|
||||
- name: Log in to the Container registry
|
||||
uses: docker/login-action@dd4fa0671be5250ee6f50aedf4cb05514abda2c7
|
||||
with:
|
||||
registry: ${{ env.REGISTRY }}
|
||||
username: ${{ github.actor }}
|
||||
password: ${{ secrets.GITHUB_TOKEN }}
|
||||
|
||||
- name: Extract metadata (tags, labels) for Docker
|
||||
id: meta
|
||||
uses: docker/metadata-action@f2a13332ac1ce8c0a71aeac48a150dbb1838ab67
|
||||
with:
|
||||
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
|
||||
|
||||
- name: Build and push Docker image
|
||||
uses: docker/build-push-action@ac9327eae2b366085ac7f6a2d02df8aa8ead720a
|
||||
with:
|
||||
context: .
|
||||
push: true
|
||||
tags: ${{ steps.meta.outputs.tags }}
|
||||
labels: ${{ steps.meta.outputs.labels }}
|
|
@ -1,3 +1,3 @@
|
|||
Gloomhaven/
|
||||
Jaws of the Lion/
|
||||
config.php
|
||||
.env
|
|
@ -1,5 +1,5 @@
|
|||
FROM php:8-slim
|
||||
FROM php:8-alpine
|
||||
|
||||
COPY *.php /
|
||||
COPY *.php /src/
|
||||
|
||||
ENTRYPOINT ["/usr/bin/php", "/src/run.php"]
|
||||
ENTRYPOINT ["/src/run.php"]
|
34
README.md
34
README.md
|
@ -1,30 +1,46 @@
|
|||
# foreteller-dl
|
||||
# forteller-dl
|
||||
|
||||
Download media from the https://www.foretellergames.com/ store without installing the application. The script behaves the same way as the application, and it can only download media that you will have access to, so please purchase the media from [fortellergames.com](https://www.fortellergames.com) before you run this script.
|
||||
Download media from the https://www.fortellergames.com/ store without installing the application. The script behaves the same way as the application, and it can only download media that you will have access to, so please purchase the media from [fortellergames.com](https://www.fortellergames.com) before you run this script.
|
||||
|
||||
Tested mainly against "Gloomhaven: Jaws of the Lion".
|
||||
|
||||
## Why?
|
||||
|
||||
I didn't like the application UX, so wrote this script instead to download the files. The app stretches the play/pause button on my iPhone SE and it looked very ugly. Plus, I can uninstall the app now and [play the files anywhere](www.defectivebydesign.org). Kudos for Foreteller for having a clean API and no DRM.
|
||||
I didn't like the application UX, so wrote this script instead to download the files. The app stretches the play/pause button on my iPhone SE and it looked very ugly. Plus, I can uninstall the app now and [play the files anywhere](www.defectivebydesign.org). Kudos for Forteller for having a clean API and no DRM.
|
||||
|
||||
## How to use
|
||||
|
||||
First configure your credentials in the `.env` file.
|
||||
|
||||
`cp .env.sample .env`
|
||||
|
||||
Edit the .env file with your correct credentials.
|
||||
|
||||
### Running using Docker
|
||||
|
||||
```sh
|
||||
# Set SKU to one of `ceph_gh`,`ceph_jaws`,`suc_mid1`,`ceph_fh`,`skg_iso`
|
||||
docker run -it --init --volume "$HOME/Downloads:/downloads" --env-file .env ghcr.io/captn3m0/forteller-dl [SKU] /downloads
|
||||
```
|
||||
|
||||
### Running using local PHP
|
||||
|
||||
You'll need php, php-curl installed, and replace {SKU} with a valid SKU (One of `ceph_gh`,`ceph_jaws`,`suc_mid1`,`ceph_fh`,`skg_iso`, but not all are available right now).
|
||||
|
||||
```
|
||||
git clone https://github.com/captn3m0/foreteller-dl.git
|
||||
cd foreteller-dl
|
||||
cp config.sample.php config.php
|
||||
// Edit the config.php file to put your credentials
|
||||
php run.php {SKU}
|
||||
git clone https://github.com/captn3m0/forteller-dl.git
|
||||
cd forteller-dl
|
||||
set -a
|
||||
source .env
|
||||
set +a
|
||||
php run.php {SKU} [/optional/path/to/output/dir]
|
||||
```
|
||||
|
||||
## TODO
|
||||
|
||||
The script is functional enough for me, so this will likely never get done. But ideas:
|
||||
|
||||
- [ ] Run with Docker
|
||||
- [x] Run with Docker
|
||||
- [ ] Cleanup code
|
||||
- [ ] API Documentation?
|
||||
- [ ] Tag the MP3 files as they are saved
|
||||
|
|
|
@ -1,4 +0,0 @@
|
|||
<?php
|
||||
|
||||
const EMAIL = 'your@email.com';
|
||||
const PASSWORD = 'yourpassword';
|
|
@ -1,11 +1,10 @@
|
|||
#!/usr/bin/env php
|
||||
<?php
|
||||
|
||||
if(!file_exists('config.php')) {
|
||||
die("Please create config.php before running this script");
|
||||
if(!isset($_ENV['FORTELLER_EMAIL']) || !isset($_ENV['FORTELLER_PASSWORD'])) {
|
||||
die("Please set FORTELLER_EMAIL and FORTELLER_PASSWORD in the environment variables");
|
||||
}
|
||||
|
||||
require('config.php');
|
||||
|
||||
const GAME_BASE_URL = 'https://us-central1-forteller-platform.cloudfunctions.net/games';
|
||||
const AUDIO_BASE_URL = 'https://us-central1-forteller-platform.cloudfunctions.net/audio/';
|
||||
const LOGIN_URL = 'https://www.googleapis.com/identitytoolkit/v3/relyingparty/verifyPassword';
|
||||
|
@ -14,7 +13,7 @@ const APP_KEY = 'AIzaSyAs2zSk1Xx-yq6pu4GNCqOUPLuCD1HPDYo';
|
|||
|
||||
function getRefreshToken() {
|
||||
$curl = curl_init();
|
||||
$body = json_encode(["email"=>EMAIL,"returnSecureToken"=>true,"password"=>PASSWORD]);
|
||||
$body = json_encode(["email"=>$_ENV['FORTELLER_EMAIL'],"returnSecureToken"=>true,"password"=>$_ENV['FORTELLER_PASSWORD']]);
|
||||
|
||||
curl_setopt_array($curl, [
|
||||
CURLOPT_URL => "https://www.googleapis.com/identitytoolkit/v3/relyingparty/verifyPassword?key=" . APP_KEY,
|
||||
|
@ -97,6 +96,13 @@ if (!in_array($argv[1], ['ceph_gh','ceph_jaws','suc_mid1','ceph_fh','skg_iso']))
|
|||
die("Invalid SKU");
|
||||
}
|
||||
|
||||
$basedir = getcwd();
|
||||
if (isset($argv[2])) {
|
||||
@mkdir($argv[2]);
|
||||
$basedir = $argv[2];
|
||||
echo("Saving files in $basedir\n");
|
||||
}
|
||||
|
||||
$jwt = login();
|
||||
$sku = $argv[1];
|
||||
$game = null;
|
||||
|
@ -109,7 +115,7 @@ foreach (json_decode(request(GAME_BASE_URL), true) as $game) {
|
|||
|
||||
$gameName = $game['name'];
|
||||
|
||||
@mkdir($gameName);
|
||||
@mkdir("$basedir/$gameName");
|
||||
$containerUrl = GAME_BASE_URL . "/" . $game['id'] . "/containers";
|
||||
$containers = request($containerUrl);
|
||||
|
||||
|
@ -123,7 +129,7 @@ foreach (json_decode($containers, true) as $c) {
|
|||
$trackName = $track['name'];
|
||||
$streamUrlParts = explode('/', $track['streamUri']);
|
||||
$trackUrl = AUDIO_BASE_URL . $streamUrlParts[2] . '/' . $streamUrlParts[3] . '/' . $streamUrlParts[4];
|
||||
$filename = "$gameName/$scenarioName - $trackName.mp3";
|
||||
$filename = "$basedir/$gameName/$scenarioName - $trackName.mp3";
|
||||
echo "$filename\n";
|
||||
if (!file_exists($filename)) {
|
||||
$track_data = request($trackUrl, 'audio/mpeg');
|
||||
|
|
Loading…
Reference in New Issue