17 Commits
9 changed files with 167 additions and 30 deletions
+1
View File
@@ -0,0 +1 @@
custom: ['t.me/tribute/app?startapp=dqW2']
+58
View File
@@ -0,0 +1,58 @@
name: Extract
on:
workflow_dispatch:
schedule:
- cron: '0 4 * * 1' # Runs every Monday at 04:00 UTC
jobs:
extract:
runs-on: ubuntu-latest
permissions:
# Give the default GITHUB_TOKEN write permission to commit and push the
# added or changed files to the repository.
contents: write
steps:
- name: Checkout repository
uses: actions/checkout@v4
# JADX requires Java 11 or higher to run
- name: Set up JDK 17
uses: actions/setup-java@v4
with:
java-version: '17'
distribution: 'temurin'
# Download and install the latest version of JADX
- name: Install JADX
run: |
# Fetch the latest version tag from the JADX GitHub repository
JADX_VERSION=$(curl -s "https://api.github.com/repos/skylot/jadx/releases/latest" | grep -Po '"tag_name": "v\K[0-9.]+')
echo "Installing JADX version ${JADX_VERSION}..."
# Download the release zip file
curl -Lo jadx.zip "https://github.com/skylot/jadx/releases/download/v${JADX_VERSION}/jadx-${JADX_VERSION}.zip"
# Unzip the archive
unzip -q jadx.zip -d jadx-dist
# Add the JADX bin directory to the GitHub Actions path
# This makes the 'jadx' command available in subsequent steps
echo "$(pwd)/jadx-dist/jadx-${JADX_VERSION}/bin" >> $GITHUB_PATH
# Clean up the downloaded zip file
rm jadx.zip
shell: bash
# Verify that JADX was installed correctly
- name: Verify JADX installation
run: jadx --version
# Verify that JADX was installed correctly
- name: Extract app credentials
run: node . --target mobile --output ./credentials.mobile.json && node . --target tv --output ./credentials.tv.json
# Commit all changed files back to the repository
- uses: stefanzweifel/git-auto-commit-action@v5
+51
View File
@@ -0,0 +1,51 @@
name: Publish
on:
push:
tags:
- 'v*'
jobs:
publish:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: 22
registry-url: https://registry.npmjs.org/
- run: npm ci
# Extract version from package.json and determine release channel
- name: Parse version and determine release channel
id: version
run: |
VERSION=$(node -p "require('./package.json').version")
echo "PACKAGE_VERSION=$VERSION" >> $GITHUB_OUTPUT
if [[ $VERSION == *"-alpha."* ]]; then
echo "NPM_TAG=alpha" >> $GITHUB_OUTPUT
echo "PRERELEASE=true" >> $GITHUB_OUTPUT
elif [[ $VERSION == *"-beta."* ]]; then
echo "NPM_TAG=beta" >> $GITHUB_OUTPUT
echo "PRERELEASE=true" >> $GITHUB_OUTPUT
else
echo "NPM_TAG=latest" >> $GITHUB_OUTPUT
fi
# Publish with the appropriate tag
- name: Publish to npm
run: npm publish --tag ${{ steps.version.outputs.NPM_TAG }}
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
# Only create GitHub releases for stable versions
- name: Create GitHub Release
uses: softprops/action-gh-release@v2
with:
generate_release_notes: true
prerelease: ${{ steps.version.outputs.PRERELEASE == 'true' }}
token: ${{ secrets.GITHUB_TOKEN }}
permissions:
contents: write
+22 -13
View File
@@ -1,31 +1,34 @@
# Crextractor
Utility for extracting credentials from the Crunchyroll Android app
Utility for extracting credentials from the Crunchyroll Android app (both TV and mobile versions).
The [credentials](https://github.com/vitalygashkov/crextractor/blob/main/credentials.tv.json) are [automatically](https://github.com/vitalygashkov/crextractor/actions/workflows/extract.yml) updated once a week (if there are any changes).
## Prerequisites
- [Node.js](https://nodejs.org/en)
- [jadx](https://github.com/skylot/jadx)
## Installation
## Usage
### Library
```bash
npm i crextractor
```
## Usage
### Fetching already extracted secrets
#### Fetch ready credentials from this GitHub repository
```js
async function main() {
const url = 'https://raw.githubusercontent.com/vitalygashkov/crextractor/refs/heads/main/credentials.tv.json';
const data = await fetch(url).then((response) => response.json());
import { pull } from 'crextractor';
// You can use the extracted secrets to obtain access tokens for Crunchyroll APIs
async function main() {
const credentials = await pull('tv');
// You can use the extracted credentials to obtain access tokens for Crunchyroll APIs
const response = await fetch('https://beta-api.crunchyroll.com/auth/v1/token', {
headers: {
Authorization: data.authorization,
Authorization: credentials.authorization, // Ready HTTP header in the format `Basic <encoded>`, can be used to access some Crunchyroll APIs
'User-Agent': 'Crunchyroll/ANDROIDTV/3.42.1_22267 (Android 16; en-US; sdk_gphone64_x86_64)',
// ...
},
@@ -37,17 +40,23 @@ async function main() {
}
```
#### Library
#### Extract credentials from the latest APK using jadx
```js
import { extract } from 'crextractor';
async function main() {
const { id, secret, encoded, authorization } = await extract();
// id - Crunchyroll app ID
// secret - Crunchyroll app secret
// encoded - Base64 encoded `id:secret` string
// authorization - ready HTTP header in the format `Basic <encoded>`, can be used to access some Crunchyroll APIs
// Do something with the extracted secrets
// Do something with the extracted credentials
}
```
#### Command-line interface
### Command-line interface
```bash
npx crextractor --target mobile --output ./credentials.mobile.json
+1 -1
View File
@@ -14,7 +14,7 @@ const args = parseArgs({
},
cleanup: {
type: 'boolean',
default: false,
default: true,
},
},
});
+17 -3
View File
@@ -1,10 +1,24 @@
export function extractSecrets(): Promise<{
export type CrunchyrollAppCredentials = {
// Crunchyroll app ID
id: string;
// Crunchyroll app secret
secret: string;
// Base64 encoded `id:secret` string
encoded: string;
// HTTP header with Basic Authorization to access Crunchyroll mobile APIs
// Ready HTTP header in the format `Basic <encoded>`, can be used to access some Crunchyroll APIs
authorization: string;
}>;
};
/**
* Extract credentials from the Crunchyroll Android APK using jadx.
*/
export function extract(options?: {
target?: 'mobile' | 'tv';
output?: string;
cleanup?: boolean;
}): Promise<CrunchyrollAppCredentials>;
/**
* Fetch ready credentials from the GitHub repository.
*/
export function pull(options?: { target: 'mobile' | 'tv' }): Promise<CrunchyrollAppCredentials>;
+11 -9
View File
@@ -1,16 +1,12 @@
const { execSync } = require('node:child_process');
const { join } = require('node:path');
const { readdir, readFile, writeFile, rm } = require('node:fs/promises');
const { download } = require('molnia');
const { existsSync } = require('node:fs');
const { download } = require('molnia');
const downloadMobileApk = async () => {
const source = 'https://apkcombo.com/crunchyroll/com.crunchyroll.crunchyroid/download/apk';
const page = await fetch(source);
const html = await page.text();
const route = '/r2' + html.split('/r2')[1]?.split('"')[0];
const url = `https://apkcombo.com${route}`;
const filepath = join(process.cwd(), 'crunchyroll.xapk');
const url = 'https://api.qqaoop.com/v11/apps/com.crunchyroll.crunchyroid/download?userId=1';
const filepath = join(process.cwd(), 'crunchyroll.apk');
await download(url, {
output: filepath,
onError: (error) => console.error(error),
@@ -100,7 +96,7 @@ const parseVersion = async (decompiledDir) => {
}
};
const extract = async ({ target, output, cleanup = false } = {}) => {
const extract = async ({ target = 'mobile', output, cleanup = false } = {}) => {
console.log('Downloading APK...');
const apkPath = target === 'tv' ? await downloadTvApk() : await downloadMobileApk();
@@ -132,4 +128,10 @@ const extract = async ({ target, output, cleanup = false } = {}) => {
return { version, id, secret, encoded, authorization };
};
module.exports = { extract };
const pull = async ({ target = 'mobile' } = {}) => {
const url = `https://raw.githubusercontent.com/vitalygashkov/crextractor/refs/heads/main/credentials.${target}.json`;
const credentials = await fetch(url).then((response) => response.json());
return credentials;
};
module.exports = { extract, pull };
+2 -2
View File
@@ -1,12 +1,12 @@
{
"name": "crextractor",
"version": "1.2.0",
"version": "1.3.0",
"lockfileVersion": 3,
"requires": true,
"packages": {
"": {
"name": "crextractor",
"version": "1.2.0",
"version": "1.3.0",
"funding": [
{
"type": "individual",
+3 -1
View File
@@ -1,6 +1,6 @@
{
"name": "crextractor",
"version": "1.2.0",
"version": "1.3.0",
"description": "Utility for extracting credentials from the Crunchyroll Android app",
"main": "crextractor.js",
"bin": {
@@ -15,6 +15,8 @@
"type": "commonjs",
"scripts": {
"start": "node bin/cli.js",
"extract:mobile": "node bin/cli.js --target mobile --output ./credentials.mobile.json",
"extract:tv": "node bin/cli.js --target tv --output ./credentials.tv.json",
"test": "echo \"Error: no test specified\" && exit 1"
},
"keywords": [