Initial commit
This commit is contained in:
commit
1fda53e947
1
.gitignore
vendored
Normal file
1
.gitignore
vendored
Normal file
|
@ -0,0 +1 @@
|
|||
.direnv
|
61
flake.lock
Normal file
61
flake.lock
Normal file
|
@ -0,0 +1,61 @@
|
|||
{
|
||||
"nodes": {
|
||||
"flake-utils": {
|
||||
"inputs": {
|
||||
"systems": "systems"
|
||||
},
|
||||
"locked": {
|
||||
"lastModified": 1726560853,
|
||||
"narHash": "sha256-X6rJYSESBVr3hBoH0WbKE5KvhPU5bloyZ2L4K60/fPQ=",
|
||||
"owner": "numtide",
|
||||
"repo": "flake-utils",
|
||||
"rev": "c1dfcf08411b08f6b8615f7d8971a2bfa81d5e8a",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
"owner": "numtide",
|
||||
"repo": "flake-utils",
|
||||
"type": "github"
|
||||
}
|
||||
},
|
||||
"nixpkgs": {
|
||||
"locked": {
|
||||
"lastModified": 1728538411,
|
||||
"narHash": "sha256-f0SBJz1eZ2yOuKUr5CA9BHULGXVSn6miBuUWdTyhUhU=",
|
||||
"owner": "NixOS",
|
||||
"repo": "nixpkgs",
|
||||
"rev": "b69de56fac8c2b6f8fd27f2eca01dcda8e0a4221",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
"owner": "NixOS",
|
||||
"ref": "nixpkgs-unstable",
|
||||
"repo": "nixpkgs",
|
||||
"type": "github"
|
||||
}
|
||||
},
|
||||
"root": {
|
||||
"inputs": {
|
||||
"flake-utils": "flake-utils",
|
||||
"nixpkgs": "nixpkgs"
|
||||
}
|
||||
},
|
||||
"systems": {
|
||||
"locked": {
|
||||
"lastModified": 1681028828,
|
||||
"narHash": "sha256-Vy1rq5AaRuLzOxct8nz4T6wlgyUR7zLU309k9mBC768=",
|
||||
"owner": "nix-systems",
|
||||
"repo": "default",
|
||||
"rev": "da67096a3b9bf56a91d16901293e51ba5b49a27e",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
"owner": "nix-systems",
|
||||
"repo": "default",
|
||||
"type": "github"
|
||||
}
|
||||
}
|
||||
},
|
||||
"root": "root",
|
||||
"version": 7
|
||||
}
|
26
flake.nix
Normal file
26
flake.nix
Normal file
|
@ -0,0 +1,26 @@
|
|||
{
|
||||
description = "IPAScrape";
|
||||
|
||||
inputs = {
|
||||
nixpkgs.url = "github:NixOS/nixpkgs/nixpkgs-unstable";
|
||||
flake-utils.url = "github:numtide/flake-utils";
|
||||
};
|
||||
outputs = { flake-utils, nixpkgs, ...}:
|
||||
flake-utils.lib.eachDefaultSystem (system:
|
||||
let pkgs = nixpkgs.legacyPackages.${system};
|
||||
ipatool = pkgs.ipatool.overrideAttrs {
|
||||
# grab latest unreleased version, which allows downloading by app store ID
|
||||
src = pkgs.fetchFromGitHub {
|
||||
owner = "majd";
|
||||
repo = "ipatool";
|
||||
rev = "63ee6fc6a42a89d51c9caac632cefd65218825ab";
|
||||
hash = "sha256-dbsQC/CRcT1/XBVKX/k2AUcLAOeN3IuSLl4GpAGBWPI=";
|
||||
};
|
||||
vendorHash = "sha256-v1hithTdsyNAQj0E9g1nRC90WdM9z4kAQuOh6OScJss=";
|
||||
};
|
||||
in {
|
||||
devShells.default = pkgs.mkShell {
|
||||
buildInputs = [ ipatool pkgs.python3 ];
|
||||
};
|
||||
});
|
||||
}
|
46
ipascrape.py
Executable file
46
ipascrape.py
Executable file
|
@ -0,0 +1,46 @@
|
|||
#!/usr/bin/env python3
|
||||
import argparse
|
||||
import csv
|
||||
import os
|
||||
import subprocess
|
||||
|
||||
def get_apps(filename):
|
||||
with open(filename) as f:
|
||||
c = csv.DictReader(f)
|
||||
return [
|
||||
{**row, "id": row["Item Reference Number"]}
|
||||
for row in c
|
||||
if row['Content Type'] == 'iOS and tvOS Apps'
|
||||
]
|
||||
|
||||
def apps_from_folder(dirname):
|
||||
return (get_apps(os.path.join(dirname, "Store Transaction History.csv")) +
|
||||
get_apps(os.path.join(dirname, "Store Transaction History - Free Apps.csv")))
|
||||
|
||||
def fetch_app(app, outdir):
|
||||
print(f"Downloading {app["Item Description"]}")
|
||||
subprocess.run(["ipatool", "download", "--app-id", app["id"], "-o", outdir])
|
||||
|
||||
def main():
|
||||
parser = argparse.ArgumentParser(
|
||||
prog="ipascrape",
|
||||
description="Scrape Apple data export CSVs for valid iOS IPAs connected to your account"
|
||||
)
|
||||
parser.add_argument("-o", "--outputdir", required=True)
|
||||
parser.add_argument("csvfile", nargs="+")
|
||||
args = parser.parse_args()
|
||||
|
||||
apps = []
|
||||
for filename in args.csvfile:
|
||||
if os.path.isfile(filename):
|
||||
apps.extend(get_apps(filename))
|
||||
elif os.path.isdir(filename):
|
||||
apps.extend(apps_from_folder(filename))
|
||||
else:
|
||||
print(f'{filename} does not exist, ignoring')
|
||||
|
||||
for app in apps:
|
||||
fetch_app(app, args.outputdir)
|
||||
|
||||
if __name__ == "__main__":
|
||||
main()
|
Loading…
Reference in a new issue