### Install apkeep from Latest Git Commit Source: https://github.com/efforg/apkeep/blob/master/README.md Install the apkeep tool directly from the latest commit in the GitHub repository. This provides the most up-to-date version. ```shell cargo install --git https://github.com/EFForg/apkeep.git ``` -------------------------------- ### Install apkeep using Cargo Source: https://github.com/efforg/apkeep/blob/master/README.md Install the apkeep tool from crates.io using the cargo package manager. Ensure you have Rust installed. ```shell cargo install apkeep ``` -------------------------------- ### INI Configuration Example Source: https://github.com/efforg/apkeep/blob/master/_autodocs/README.md Example of an INI configuration file for apkeep. This file can be used to set source-specific options like authentication tokens. ```ini [google] email=user@gmail.com aas_token=ya29.TOKEN_VALUE ``` -------------------------------- ### DownloadInformation Example (F-Droid) Source: https://github.com/efforg/apkeep/blob/master/_autodocs/types.md Provides an example of the `DownloadInformation` tuple structure, detailing app package ID, version, filename, SHA256 hash, and the repository base URL. ```rust ( vec![ ("org.mozilla.firefox".to_string(), Some("117.0".to_string()), "org.mozilla.firefox_117.0.apk".to_string(), vec![0xab, 0xcd, 0xef, ...]), ], "https://f-droid.org/repo" ) ``` -------------------------------- ### Google Play INI Configuration Example Source: https://github.com/efforg/apkeep/blob/master/_autodocs/configuration.md A specific example of the [google] section in an INI file, showing how to set the email and AAS token. ```ini [google] email=myemail@gmail.com aas_token=ya29.A0AfH6SMBbb7j-XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX ``` -------------------------------- ### Google Play INI Configuration Example Source: https://github.com/efforg/apkeep/blob/master/_autodocs/configuration.md Example of the [google] section in an INI file, specifying email and authentication tokens for Google Play services. ```ini [google] email=user@gmail.com aas_token=ya29.A0AfH6SMXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX auth_token=ya29.DIFFERENT_TOKEN_FORMAT ``` -------------------------------- ### INI File Format Example Source: https://github.com/efforg/apkeep/blob/master/_autodocs/cli-arguments.md An example of the INI file format for storing Google Play authentication credentials and settings. ```ini [google] email=user@gmail.com aas_token=AAS_TOKEN_VALUE auth_token=ya29.AUTH_TOKEN_VALUE ``` -------------------------------- ### apkeep.ini Configuration File Example Source: https://github.com/efforg/apkeep/blob/master/USAGE-google-play.md Example `apkeep.ini` file structure for specifying Google Play email and AAS token or AUTH token. ```ini [google] email = someone@gmail.com aas_token = some_aas_token # OR use auth_token instead of aas_token: # auth_token = ya29.a0... ``` -------------------------------- ### DownloadSource Usage Examples Source: https://github.com/efforg/apkeep/blob/master/_autodocs/types.md Demonstrates direct usage of DownloadSource enum variants, parsing from strings for CLI input, and displaying enum variants as strings. ```rust // Direct variant usage let source = DownloadSource::GooglePlay; // CLI parsing let source: DownloadSource = "google-play".parse()?; // Display println!("{}", DownloadSource::FDroid); // Outputs: "f-droid" ``` -------------------------------- ### Example Download Progress Output Source: https://github.com/efforg/apkeep/blob/master/_autodocs/huawei-app-gallery-api.md Illustrates the expected output format for tracking download progress using concurrent status bars. This output is generated by the `indicatif::MultiProgress` utility. ```text Downloading com.tencent.qq... [00:00:15] ████████████████░░░░░░░░░░░░░░ 65MB/98MB | com.tencent.qq.apk [00:00:08] ██████████████████████████████░░ 120MB/150MB | com.elysiumlabs.newsbytes.apk com.tencent.qq downloaded successfully! ``` -------------------------------- ### Example CSV Data Source: https://github.com/efforg/apkeep/blob/master/_autodocs/configuration.md Illustrates the format of a CSV file used for parsing, where the first field is the application ID and the second field is the version. This example demonstrates cases with and without version information. ```csv com.instagram.android,1.0.0 com.twitter.android,2.5.3 org.mozilla.firefox com.example.app,1.2 ``` -------------------------------- ### CSVList Example Usage Source: https://github.com/efforg/apkeep/blob/master/_autodocs/types.md Illustrates the structure of `CSVList` entries, showing how application data is represented with and without version information. ```rust // From CSV: "com.instagram.android,1.0.0" ("com.instagram.android".to_string(), Some("1.0.0".to_string())) // From command-line: "com.twitter.android" ("com.twitter.android".to_string(), None) // From CSV field selection ("org.fdroid.fdroid".to_string(), None) ``` -------------------------------- ### Download Retry Output Example Source: https://github.com/efforg/apkeep/blob/master/_autodocs/progress-and-output.md Shows how download progress and retry messages are displayed. Each retry generates a new progress bar, and old ones are removed. ```text An error has occurred attempting to download com.app. Retry #1... [00:00:08] ░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░ 0B/100MB | app.apk (new bar appears for retry) [00:00:10] ████████████░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░ 30MB/100MB | app.apk An error has occurred attempting to download com.app. Retry #2... [00:00:12] ████████████████████░░░░░░░░░░░░░░░░░░░░░░ 50MB/100MB | app.apk com.app downloaded successfully! ``` -------------------------------- ### Download Multiple Architectures from APKPure Source: https://github.com/efforg/apkeep/blob/master/USAGE-apkpure.md Specify multiple architectures for download by separating `arch=` specifications with a semicolon. This example shows the default `arch` option. ```shell apkeep -a com.instagram.android -o 'arch=arm64-v8a;armeabi-v7a;armeabi;x86;x86_64' . ``` -------------------------------- ### HashMap for Configuration Options Source: https://github.com/efforg/apkeep/blob/master/_autodocs/types.md Use this HashMap to store source-specific configuration options passed via CLI. The `get` method returns an `Option`. ```rust HashMap<&str, &str> ``` ```rust let mut options = HashMap::new(); options.insert("arch", "arm64-v8a"); options.insert("device", "px_9a"); options.get("arch") // Returns Option<&&str> ``` -------------------------------- ### OutputFormat Usage Example Source: https://github.com/efforg/apkeep/blob/master/_autodocs/types.md Shows how to use the OutputFormat enum to conditionally print version information in JSON or plaintext format. ```rust let format = OutputFormat::Json; if format.is_json() { println!("{{\"version\": \"1.0.0\"}}"); } else { println!("Version: 1.0.0"); } ``` -------------------------------- ### CSV Example with Whitespace Source: https://github.com/efforg/apkeep/blob/master/_autodocs/csv-processing.md Demonstrates how a CSV line with leading/trailing whitespace is processed after trimming. ```text com.example.app , 1.0.0 ``` -------------------------------- ### Custom F-Droid Repository Format Source: https://github.com/efforg/apkeep/blob/master/_autodocs/configuration.md This example shows the format for specifying a custom F-Droid repository URL with a fingerprint. ```text repo=https://example.com/fdroid/repo?fingerprint=1234567890ABCDEF...GHIJKLMNOP ``` -------------------------------- ### APKPure JSON Output Structure Source: https://github.com/efforg/apkeep/blob/master/_autodocs/progress-and-output.md Example of JSON output structure for APKPure sources, detailing available app versions or errors. ```json { "source": "APKPure", "apps": { "com.instagram.android": { "available_versions": [ {"version": "1.0.0"}, {"version": "1.0.1"}, {"version": "2.0.0"} ] }, "com.twitter.android": { "error": "Invalid app response." } } } ``` -------------------------------- ### Plaintext Progress Output Example Source: https://github.com/efforg/apkeep/blob/master/_autodocs/progress-and-output.md This shows the default plaintext output for download operations, including progress bars and status messages. It is used for download operations, progress bar messages, and error messages. ```plaintext Downloading com.instagram.android... [00:00:15] ████████████████░░░░░░░░░░░░░░ 52MB/100MB | instagram.apk Downloading com.twitter.android... [00:00:08] ██████████████████████░░░░░░░░ 78MB/98MB | twitter.apk com.instagram.android downloaded successfully! File already exists for com.twitter.android. Skipping... ``` -------------------------------- ### Get apkeep Configuration Directory Source: https://github.com/efforg/apkeep/blob/master/_autodocs/configuration.md Retrieves the apkeep configuration directory path, creating it if it doesn't exist. Handles potential errors like the directory not being found or creation failure. ```rust pub fn config_dir() -> Result ``` -------------------------------- ### Build and Run apkeep (Release) Source: https://github.com/efforg/apkeep/blob/master/HACKING.md Builds and immediately runs the apkeep binary in release mode, passing any arguments to the tool. Replace ARGS with your desired arguments. ```shell cargo run --release -- ARGS ``` -------------------------------- ### Build and Run apkeep (Debug) Source: https://github.com/efforg/apkeep/blob/master/HACKING.md Builds and immediately runs the apkeep binary in debug mode, passing any arguments to the tool. Replace ARGS with your desired arguments. ```shell cargo run -- ARGS ``` -------------------------------- ### APKPure Error Message Example Source: https://github.com/efforg/apkeep/blob/master/_autodocs/errors.md This is an example of an error message outputted when there is an issue with APKPure. ```text Could not get download URL for com.example.app. Skipping... ``` -------------------------------- ### F-Droid Error Message Example Source: https://github.com/efforg/apkeep/blob/master/_autodocs/errors.md This is an example of an error message outputted when a specific version of an app cannot be found on F-Droid. ```text Could not find version 1.0.0 arm64-v8a of org.example.app. Skipping... ``` -------------------------------- ### CSV Example with Un-trimmed Field Values Source: https://github.com/efforg/apkeep/blob/master/_autodocs/csv-processing.md Field values are not automatically trimmed. This example shows a version field with leading spaces. ```csv com.example.app, 1.0.0 ``` -------------------------------- ### Huawei AppGallery Error Message Example Source: https://github.com/efforg/apkeep/blob/master/_autodocs/errors.md This is an example of an error message outputted when an invalid app response is received from Huawei AppGallery. ```text Invalid app response for com.example.app. Skipping... ``` -------------------------------- ### List Available App Versions Source: https://github.com/efforg/apkeep/blob/master/_autodocs/cli-arguments.md Lists all available versions for a given application ID from a specified download source. ```bash apkeep -l -a org.mozilla.fennec_fdroid -d f-droid ``` -------------------------------- ### Google Play Error Message Example Source: https://github.com/efforg/apkeep/blob/master/_autodocs/errors.md This is an example of an error message outputted when there is an issue with Google Play, including a placeholder for the specific error. ```text Could not log in to Google Play. Please check your credentials and try again later. {err} ``` -------------------------------- ### Build apkeep (Release) Source: https://github.com/efforg/apkeep/blob/master/HACKING.md Compiles the apkeep binary in release mode for optimized performance. The output is placed in the target/ directory. ```shell cargo build --release ``` -------------------------------- ### Specify apkeep Configuration File Source: https://github.com/efforg/apkeep/blob/master/USAGE-google-play.md Download an app using credentials and settings specified in an `apkeep.ini` configuration file. The '.' indicates the current directory for saving the app. ```shell apkeep -a com.instagram.android -d google-play -i ~/path/to/some.ini . ``` -------------------------------- ### Download App with AUTH Token Source: https://github.com/efforg/apkeep/blob/master/USAGE-google-play.md Download an app using an AUTH token, typically obtained from a token dispenser. The `--accept-tos` flag is recommended for initial use. ```shell apkeep -a com.instagram.android -d google-play -e 'dispenser_email@gmail.com' --auth-token 'ya29.a0...' --accept-tos . ``` -------------------------------- ### List Available App Versions with apkeep Source: https://github.com/efforg/apkeep/blob/master/_autodocs/README.md This command lists all available versions for a given app from a specified source, such as F-Droid. Use the -l flag for listing and -d to specify the download source. ```bash apkeep -l -a com.instagram.android -d f-droid ``` -------------------------------- ### List Available App Versions in JSON Format Source: https://github.com/efforg/apkeep/blob/master/USAGE-fdroid.md Output the list of available app versions in JSON format by using the `output_format=json` option. This is useful for programmatic processing. ```shell apkeep -l -a org.mozilla.fennec_fdroid -d f-droid -o output_format=json ``` -------------------------------- ### F-Droid JSON Output Structure Source: https://github.com/efforg/apkeep/blob/master/_autodocs/progress-and-output.md Example of JSON output structure for F-Droid sources, detailing available app versions or errors. ```json { "source": "F-Droid", "apps": { "org.mozilla.firefox": { "available_versions": [ {"version": "117.0"}, {"version": "118.0.1"}, {"version": "119.0"} ] }, "org.fdroid.fdroid": { "error": "Not found in package list." } } } ``` -------------------------------- ### Configuration Directory Management Source: https://github.com/efforg/apkeep/blob/master/_autodocs/module-dependencies.md Handles locating and creating the platform-specific configuration directory. Returns `ConfigDirError` if the directory cannot be found or created. ```rust use std::path::PathBuf; #[derive(Debug, PartialEq, Eq)] pub enum ConfigDirError { NotFound, CouldNotCreate(String), } pub fn config_dir() -> Result { let config_path = dirs::config_dir() .ok_or(ConfigDirError::NotFound)? .join("apkeep"); if !config_path.exists() { std::fs::create_dir_all(&config_path) .map_err(|e| ConfigDirError::CouldNotCreate(e.to_string()))?; } Ok(config_path) } ``` -------------------------------- ### Build apkeep (Debug) Source: https://github.com/efforg/apkeep/blob/master/HACKING.md Compiles the apkeep binary in debug mode. The output is placed in the target/ directory. ```shell cargo build ``` -------------------------------- ### Get PathBuf from Option Source: https://github.com/efforg/apkeep/blob/master/_autodocs/types.md Extract a reference to a PathBuf from an Option. This is useful when dealing with optional file paths and needing to access the path directly. ```rust let outpath: Option = ...; let path = outpath.as_deref().unwrap(); ``` -------------------------------- ### Select Both App ID and Version Fields Source: https://github.com/efforg/apkeep/blob/master/_autodocs/csv-processing.md Uses both the -f and -v flags to specify distinct columns for application IDs and versions from the CSV file. ```bash apkeep -c data.csv -f 5 -v 8 /output ``` -------------------------------- ### Example Huawei AppGallery API Response Source: https://github.com/efforg/apkeep/blob/master/_autodocs/huawei-app-gallery-api.md This JSON structure represents a typical successful response from the Huawei AppGallery API, detailing app information and a success code. ```json { "list": [ { "downurl": "https://store-dre.hispace.dbankcloud.com/hwmarket-appapi-hk/download?appId=12345&versionCode=123&hwgateway=1", "packageName": "com.example.app", "versionCode": 123, "versionName": "1.2.3", "appId": "12345", "...additional metadata..." } ], "ret": 0 // 0 = success } ``` -------------------------------- ### progress_wrapper() Source: https://github.com/efforg/apkeep/blob/master/_autodocs/progress-and-output.md Creates a progress callback factory for streaming downloads. It takes a shared multi-bar progress tracker and returns a nested closure. The outer closure accepts filename and total length to set up a new progress bar, and the inner closure updates the progress bar's state based on downloaded bytes. ```APIDOC ## progress_wrapper() ### Description Creates a progress callback factory for streaming downloads. ### Function Signature ```rust pub fn progress_wrapper( mp: Rc ) -> Box Box ()>> ``` ### Parameters #### Path Parameters - **mp** (`Rc`) - Required - Shared multi-bar progress tracker ### Return Type Nested closure factory: `Fn(String, u64) -> Fn(u64) -> ()` ### Behavior 1. **Outer closure (factory):** - Takes `filename` and total `length`. - Creates a new `ProgressBar` with the specified total length. - Adds the new progress bar to the `MultiProgress` manager. - Returns the inner callback function. 2. **Inner closure (callback):** - Called repeatedly with the number of bytes downloaded. - Updates the position of the associated progress bar. - Removes the progress bar from the `MultiProgress` manager when it is finished. - Includes a check (`is_finished()`) to ensure it's safe to call repeatedly. ### Example Usage ```rust let mp = Rc::new(MultiProgress::new()); let progress_fn = progress_wrapper(mp.clone()); // Create callback for file "app.apk" (100MB = 104857600 bytes) let callback = progress_fn("app.apk".to_string(), 104857600); // Update progress (called by download stream) callback(0); // Starting callback(52428800); // 50% complete callback(104857600); // 100% complete (bar finishes and removes) ``` ``` -------------------------------- ### Download with Device Configuration Source: https://github.com/efforg/apkeep/blob/master/_autodocs/cli-arguments.md Downloads an app from Google Play with specific device configuration, including device model, locale, and timezone. ```bash apkeep -a com.example.app -d google-play -e user@gmail.com -t AAS_TOKEN -o "device=px_9a,locale=en_US,timezone=America/New_York" /path/to/output ``` -------------------------------- ### Example Huawei AppGallery API Request Body Source: https://github.com/efforg/apkeep/blob/master/_autodocs/huawei-app-gallery-api.md Illustrates the format of a URL-encoded request body for the client.updateCheck method, including parameters like packageName, agVersion, and device specifications. ```plaintext agVersion=12.0.1&brand=Android&buildNumber=...&packageName=com.example.app&... ``` -------------------------------- ### Parsed CSV Result Source: https://github.com/efforg/apkeep/blob/master/_autodocs/configuration.md Shows the expected output after parsing the example CSV data. Each entry is a tuple containing the application ID and its corresponding version, with `None` for entries lacking a version. ```json [ ("com.instagram.android", Some("1.0.0")), ("com.twitter.android", Some("2.5.3")), ("org.mozilla.firefox", None), ("com.example.app", Some("1.2")), ] ``` -------------------------------- ### Load Google Play Credentials from Config Source: https://github.com/efforg/apkeep/blob/master/_autodocs/configuration.md Demonstrates how to retrieve Google Play email and authentication tokens from a configuration object. It prioritizes CLI arguments and falls back to INI file values. ```rust if email.is_none() { email = conf.get("google", "email"); } if aas_token.is_none() && auth_token.is_none() { aas_token = conf.get("google", "aas_token"); if aas_token.is_none() { auth_token = conf.get("google", "auth_token"); } } ``` -------------------------------- ### Download Specific App Version with apkeep Source: https://github.com/efforg/apkeep/blob/master/_autodocs/README.md To download a particular version of an app, append the version number to the app's package name using '@'. For example, to download version 1.0.0 of com.instagram.android. ```bash apkeep -a com.instagram.android@1.0.0 /output ``` -------------------------------- ### Download from APKPure Source: https://github.com/efforg/apkeep/blob/master/USAGE-apkpure.md Use this command to download an application from APKPure when it is the default source. Specify the application package name and the output directory. ```shell apkeep -a com.instagram.android . ``` -------------------------------- ### Configure APKPure Source Options Source: https://github.com/efforg/apkeep/blob/master/_autodocs/configuration.md When using the APKPure source, you can specify architectures and the output format using the `-o` flag. Architectures are semicolon-separated, and the output format can be set to 'json'. ```bash apkeep -a app.id -o "arch=arm64-v8a;armeabi-v7a,output_format=json" /output ``` -------------------------------- ### Batch Download Apps from CSV with apkeep Source: https://github.com/efforg/apkeep/blob/master/_autodocs/README.md For downloading multiple apps listed in a CSV file, use the -c flag followed by the CSV filename. Flags -f and -v can specify the column indices for app package names and versions, respectively. ```bash apkeep -c apps.csv -f 1 -v 2 /output ``` -------------------------------- ### Direct Printing with Rust Source: https://github.com/efforg/apkeep/blob/master/_autodocs/progress-and-output.md Demonstrates direct printing using `println!` and `eprintln!` for non-critical output like announcements and simple errors. ```rust println!("Downloading {{}}", app_id); eprintln!("Error: {{}}", message); ``` -------------------------------- ### APKPure Download and List Functions Source: https://github.com/efforg/apkeep/blob/master/_autodocs/module-dependencies.md Handles downloading APKs and listing versions from APKPure. Uses `reqwest` for HTTP requests and `regex` for URL parsing. Includes helper functions for constructing HTTP headers and processing responses. ```rust use reqwest::header::{HeaderMap, USER_AGENT}; use regex::Regex; use tokio_dl_stream_to_disk::Downloader; use indicatif::ProgressBar; use crate::util::{OutputFormat, progress_bar::progress_wrapper}; use std::path::Path; pub async fn download_apps(apps: &[String], output_dir: &Path, output_format: OutputFormat) -> Result<(), Box> { // ... implementation details ... Ok(()) } pub async fn list_versions(query: Option<&str>, output_format: OutputFormat) -> Result<(), Box> { // ... implementation details ... Ok(()) } pub fn http_headers() -> HeaderMap { let mut headers = HeaderMap::new(); headers.insert(USER_AGENT, "Mozilla/5.0".parse().unwrap()); headers } pub async fn download_from_response(response: reqwest::Response, output_path: &Path, pb: ProgressBar) -> Result<(), Box> { let downloader = Downloader::new(response); downloader.download_to_path(output_path, Some(pb)).await?; Ok(()) } ``` -------------------------------- ### Download Source Selection Source: https://github.com/efforg/apkeep/blob/master/_autodocs/cli-arguments.md Choose the repository from which to download applications. ```APIDOC ## Download Source Selection ### `-d, --download-source ` #### Description Specifies which repository to download from. #### Properties - **Type**: `DownloadSource` enum - **Required**: No - **Default**: `apk-pure` - **Valid Values**: `apk-pure`, `google-play`, `f-droid`, `huawei-app-gallery` ``` -------------------------------- ### Core Function Source: https://github.com/efforg/apkeep/blob/master/_autodocs/cli-arguments.md The `app()` function returns a configured `clap::Command` for parsing APK download requests. This is the primary entry point for the CLI. ```APIDOC ## Core Function ### Description Returns a fully configured `clap::Command` for parsing APK download requests. The command name is "apkeep" version 1.0.0. ### Signature ```rust pub fn app() -> Command ``` ``` -------------------------------- ### Download App from F-Droid Repo with Old Index Source: https://github.com/efforg/apkeep/blob/master/USAGE-fdroid.md If a repository only supports the older v1 package index, disable the newer entry point specification using `use_entry=false`. ```shell apkeep -a org.torproject.android -d f-droid -o repo=https://guardianproject.info/fdroid/repo?fingerprint=B7C2EEFD8DAC7806AF67DFCD92EB18126BC08312A7F2D6F3862E46013C7A6135,use_entry=false . ``` -------------------------------- ### Configure Google Play Source Options Source: https://github.com/efforg/apkeep/blob/master/_autodocs/configuration.md For Google Play, configure options like device ID, locale, timezone, and split APK settings using the `-o` flag. Values for boolean options like `split_apk` can be '0'/'1' or 'true'/'false'. ```bash apkeep -a app.id -d google-play -e user@gmail.com -t TOKEN \ -o "device=px_9a,locale=en_US,timezone=America/New_York,split_apk=1" /output ``` -------------------------------- ### Source-Specific Options Source: https://github.com/efforg/apkeep/blob/master/_autodocs/cli-arguments.md Pass through configuration options specific to the chosen download source. ```APIDOC ## Source-Specific Options ### `-o, --options ` #### Description Comma-separated source-specific configuration. #### Properties - **Type**: `String` - **Required**: No - **Format**: `key1=value1,key2=value2` #### Common options by source: - `APKPure`: `arch=arm64-v8a;armeabi-v7a` - Device architectures - `GooglePlay`: `device=px_9a`, `locale=en_US`, `timezone=UTC`, `device_properties_file=/path`, `split_apk=true`, `include_additional_files=true`, `include_dex_metadata=true` - `F-Droid`: `repo=https://custom.repo?fingerprint=HEXVALUE`, `use_entry=true/false`, `verify-index=true/false`, `output_format=json`, `arch=arm64-v8a` - `HuaweiAppGallery`: None ``` -------------------------------- ### Configure F-Droid Source Options Source: https://github.com/efforg/apkeep/blob/master/_autodocs/configuration.md Configure F-Droid source options including repository URL (with optional fingerprint), verification settings, and output format. Use 'true'/'false' or '0'/'1' for boolean flags like `use_entry` and `verify-index`. ```bash apkeep -a app.id -d f-droid \ -o "repo=https://guardianproject.info/fdroid/repo?fingerprint=ABC123...,verify-index=true,output_format=json" /output ``` -------------------------------- ### Google Play Configuration Source: https://github.com/efforg/apkeep/blob/master/_autodocs/configuration.md Demonstrates how to configure apkeep for downloading from Google Play using an INI file. The INI file stores the user's email and an AAS token, and the command specifies the application and the 'google-play' profile. ```ini [google] email=user@gmail.com aas_token=ya29.A0AfH6SM... ``` ```bash apkeep -a com.instagram.android -d google-play /output ``` -------------------------------- ### Config Directory Access Usage Source: https://github.com/efforg/apkeep/blob/master/_autodocs/types.md Demonstrates how to handle potential errors when accessing the configuration directory using `config::config_dir()`. ```rust match config::config_dir() { Ok(path) => println!("Config: {}", path.display()), Err(ConfigDirError::NotFound) => eprintln!("No config directory"), Err(ConfigDirError::CouldNotCreate) => eprintln!("Permission denied"), } ``` -------------------------------- ### Google Play Download and List Functions Source: https://github.com/efforg/apkeep/blob/master/_autodocs/module-dependencies.md Provides functionality to download apps from Google Play using the `gpapi` crate. Includes methods for requesting AAS tokens and listing version information. ```rust use gpapi::client::Client; use tokio::task; use indicatif::ProgressBar; use crate::util::progress_bar::progress_wrapper; use std::path::Path; pub async fn download_apps(apps: &[String], output_dir: &Path) -> Result<(), Box> { // ... implementation details ... Ok(()) } pub async fn request_aas_token(client: &Client) -> Result> { // ... implementation details ... Ok("dummy_token".to_string()) } pub async fn list_versions(app_id: &str) -> Result<(), Box> { // ... implementation details ... Ok(()) } ``` -------------------------------- ### Download App with Specific Version Source: https://github.com/efforg/apkeep/blob/master/_autodocs/cli-arguments.md Command to download a specific version of an application by appending the version number to the app ID. ```bash apkeep -a com.instagram.android@1.2.3 /path/to/output ``` -------------------------------- ### List App Versions Function Source: https://github.com/efforg/apkeep/blob/master/_autodocs/README.md This function retrieves available versions for specified applications. It requires app identifiers and source-specific options. ```rust pub async fn list_versions( apps: Vec<(String, Option)>, options: HashMap<&str, &str>, ) ``` -------------------------------- ### List Available App Versions from APKPure Source: https://github.com/efforg/apkeep/blob/master/USAGE-apkpure.md List all available versions of an application from APKPure without specifying an architecture. ```shell apkeep -l -a com.instagram.android ``` -------------------------------- ### List Available App Versions from APKPure (Specific Architecture) Source: https://github.com/efforg/apkeep/blob/master/USAGE-apkpure.md List the available versions of an application from APKPure for a specific architecture using the `-l` flag and the `-o 'arch='` option. ```shell apkeep -l -a com.instagram.android -o 'arch=x86' ``` -------------------------------- ### Download APK using Docker Source: https://github.com/efforg/apkeep/blob/master/README.md Run apkeep within a Docker container to download an APK. Mount a local directory to the container's '/output' path to save the downloaded file. ```shell docker run --rm -v output_path:/output ghcr.io/efforg/apkeep:stable -a com.instagram.android /output ``` -------------------------------- ### list_versions() Source: https://github.com/efforg/apkeep/blob/master/_autodocs/apkpure-api.md Enumerates available versions for specified applications on APKPure. Supports different output formats including plaintext and JSON. ```APIDOC ## list_versions() ### Description Enumerate available versions for apps on APKPure. The output can be formatted as plaintext or JSON. ### Method `pub async fn list_versions(apps: Vec<(String, Option)>, options: HashMap<&str, &str>)` ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body None ### Parameters - **apps** (`Vec<(String, Option)>`) - Required - Vector of (app_id, ignored) tuples. - **options** (`HashMap<&str, &str>`) - Required - Output format and HTTP options. Supported keys include `output_format` (`json` or plaintext). ### Response #### Success Response Prints available versions to stdout or a file descriptor. The format is determined by the `output_format` option. #### Response Example **Plaintext (default):** ``` Versions available for com.example.app on APKPure: | 1.0.0, 1.0.1, 1.1.0, 2.0.0 ``` **JSON:** ```json { "source": "APKPure", "apps": { "com.example.app": { "available_versions": [ {"version": "1.0.0"}, {"version": "1.0.1"} ] } } } ``` ### Request Example ```rust use std::collections::HashMap; let apps = vec![ ("com.instagram.android".to_string(), None), ("org.mozilla.firefox".to_string(), None), ]; let mut options = HashMap::new(); options.insert("output_format", "json"); apkpure::list_versions(apps, options).await; ``` ``` -------------------------------- ### Select Version Field using -v flag Source: https://github.com/efforg/apkeep/blob/master/_autodocs/csv-processing.md Specifies which column in the CSV file should be used for application versions. Requires the -f flag to also be set. ```bash apkeep -c data.csv -f 1 -v 2 /output ``` -------------------------------- ### List Versions from CSV Source: https://github.com/efforg/apkeep/blob/master/_autodocs/csv-processing.md Uses the -l flag to list application versions from a specified CSV file, potentially downloading from a non-default source like F-Droid. ```bash apkeep -l -c fdroid_apps.csv -f 1 -d f-droid ``` -------------------------------- ### Download App with Custom Device Profile Source: https://github.com/efforg/apkeep/blob/master/USAGE-google-play.md Specify a custom device profile using the `-o` option to emulate a different device. The '.' indicates the current directory for saving the app. ```shell apkeep -a com.instagram.android -d google-play -o device=ad_g3_pro -e 'someone@gmail.com' -t some_aas_token . ``` -------------------------------- ### MultiProgress Initialization (indicatif) Source: https://github.com/efforg/apkeep/blob/master/_autodocs/types.md Initializes a thread-safe multi-bar progress tracker using indicatif. This is useful for managing multiple concurrent download progress bars. ```rust let mp = Rc::new(MultiProgress::new()); let pb = ProgressBar::new(total_bytes); let pb = mp.add(pb); ``` -------------------------------- ### Manage Multiple Progress Bars Source: https://github.com/efforg/apkeep/blob/master/_autodocs/progress-and-output.md Demonstrates the usage of `indicatif::MultiProgress` to manage multiple concurrent progress bars. It shows how to create a manager, add bars, update their progress, print messages without disruption, suspend bars for printing, and remove finished bars. ```rust let mp = Rc::new(MultiProgress::new()); let mp_log = Rc::clone(&mp); let pb = ProgressBar::new(file_length); let pb = mp.add(pb); // Update progress pb.set_position(bytes_downloaded); // Print without disrupting bar mp_log.println("Download complete!").unwrap(); // Print with bar suspended mp_log.suspend(|| println!("Progress suspended for printing")); // Finish and remove when done if length == downloaded { pb.finish(); mp.remove(&pb); } ``` -------------------------------- ### List Available App Versions from F-Droid Source: https://github.com/efforg/apkeep/blob/master/USAGE-fdroid.md Use the `-l` flag to list all available versions of an application from the F-Droid repository. ```shell apkeep -l -a org.mozilla.fennec_fdroid -d f-droid ``` -------------------------------- ### Testing Error Paths with apkeep CLI Source: https://github.com/efforg/apkeep/blob/master/_autodocs/errors.md These commands demonstrate how to test different error handling scenarios using the apkeep command-line interface. They cover invalid CSV files, non-existent directories, F-Droid verification failures, and permission errors. ```bash # Test CSV validation apkeep -c nonexistent.csv /output # Exits with error message ``` ```bash # Test invalid directory apkeep -a com.example.app /nonexistent # Exits with error message ``` ```bash # Test F-Droid verification failure apkeep -a fake.app -d f-droid /output # App skipped, process continues ``` ```bash # Test permission error apkeep -a com.example.app /root/protected # File skipped, process continues ``` -------------------------------- ### Define apkeep CLI Command Source: https://github.com/efforg/apkeep/blob/master/_autodocs/cli-arguments.md Returns a fully configured clap::Command for parsing APK download requests. The command name is "apkeep" version 1.0.0. ```rust pub fn app() -> Command ``` -------------------------------- ### list_versions() Source: https://github.com/efforg/apkeep/blob/master/_autodocs/fdroid-api.md Enumerates available versions for specified applications on the F-Droid repository. Supports custom repositories and different output formats. ```APIDOC ## list_versions() ### Description Enumerate available versions for apps on F-Droid. ### Method `async fn list_versions( apps: Vec<(String, Option)>, options: HashMap<&str, &str> ) -> () ### Parameters #### Path Parameters - `apps` (Vec<(String, Option)>) - Required - App identifiers (versions ignored) - `options` (HashMap<&str, &str>) - Required - Repo and output format #### Options Supported: - `repo` (URL) - Optional - Custom repository URL. - `use_entry` (String) - Optional - Index format selection. - `verify-index` (String) - Optional - Enable/disable verification. - `output_format` (String) - Optional - `json` or plaintext. Defaults to plaintext. ### Response #### Success Response (200) - `()` - Prints available versions to stdout. #### Output Formats: Plaintext (default): ``` Versions available for org.mozilla.fennec_fdroid on F-Droid: | 117.0, 118.0.1, 119.0 ``` JSON: ```json { "source": "F-Droid", "apps": { "org.mozilla.fennec_fdroid": { "available_versions": [ {"version": "117.0"}, {"version": "118.0.1"} ] } } } ``` ### Request Example ```rust use std::collections::HashMap; let apps = vec![ ("org.fdroid.fdroid".to_string(), None), ]; let mut options = HashMap::new(); options.insert("output_format", "json"); fdroid::list_versions(apps, options).await; ``` ``` -------------------------------- ### F-Droid Custom Repository Configuration Source: https://github.com/efforg/apkeep/blob/master/_autodocs/configuration.md Shows how to configure apkeep to download from a custom F-Droid repository. This involves specifying the application ID, the 'f-droid' profile, and providing the repository URL and fingerprint as options. ```bash apkeep -a com.example.app -d f-droid \ -o "repo=https://guardian.fdroid/repo?fingerprint=b7c2ebb2c223..." \ /output ``` -------------------------------- ### Download Apps Function Source: https://github.com/efforg/apkeep/blob/master/_autodocs/README.md Use this function to download applications. It supports parallel downloads, rate limiting, and source-specific options. Ensure the output path is correctly specified. ```rust pub async fn download_apps( apps: Vec<(String, Option)>, // (app_id, optional_version) parallel: usize, // concurrent downloads sleep_duration: u64, // rate limiting (ms) outpath: &Path, // output directory options: HashMap<&str, &str>, // source-specific options ) ``` -------------------------------- ### Extract App IDs and Versions from CSV Source: https://github.com/efforg/apkeep/blob/master/_autodocs/csv-processing.md Use this when your CSV file contains both application IDs and versions. Specify the fields for both using -f and -v flags. An empty version field will result in None. ```csv com.instagram.android,1.0.0 com.twitter.android,5.20.0 org.mozilla.firefox,117.0 com.example.app, ``` ```bash apkeep -c apps.csv -f 1 -v 2 /output ``` ```text [ ("com.instagram.android", Some("1.0.0")), ("com.twitter.android", Some("5.20.0")), ("org.mozilla.firefox", Some("117.0")), ("com.example.app", None), // Empty version → None ] ``` -------------------------------- ### Select App ID Field using -f flag Source: https://github.com/efforg/apkeep/blob/master/_autodocs/csv-processing.md Specifies which column in the CSV file should be used for application IDs. Defaults to column 1 if not provided. ```bash apkeep -c data.csv -f 3 /output ```