Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Create lib #177

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion src/apkpure.rs
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ pub async fn download_apps(
parallel: usize,
sleep_duration: u64,
outpath: &Path,
xapk_bundle: bool
) {
let mp = Rc::new(MultiProgress::new());
let http_client = Rc::new(reqwest::Client::new());
Expand Down Expand Up @@ -64,7 +65,11 @@ pub async fn download_apps(
.headers(headers)
.send().await.unwrap();
if let Some(app_version) = app_version {
let regex_string = format!("[[:^digit:]]{}:(?s:.)+?{}", regex::escape(&app_version), crate::consts::APKPURE_DOWNLOAD_URL_REGEX);
let download_url_regex = match xapk_bundle {
true => format!("(XAPKJ)..{}", crate::consts::APKPURE_DOWNLOAD_URL_REGEX),
false => format!("[^X](APKJ)..{}", crate::consts::APKPURE_DOWNLOAD_URL_REGEX)
};
let regex_string = format!("[[:^digit:]]{}:(?s:.)+?{}", regex::escape(&app_version), download_url_regex);
let re = Regex::new(&regex_string).unwrap();
download_from_response(versions_response, Box::new(Box::new(re)), app_string, outpath, mp).await;
} else {
Expand Down
2 changes: 1 addition & 1 deletion src/consts.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
pub const APKPURE_VERSIONS_URL_FORMAT: &str = "https://api.pureapk.com/m/v3/cms/app_version?hl=en-US&package_name=";
pub const APKPURE_DOWNLOAD_URL_REGEX: &str = r"(X?APKJ)..(https?://(www\.)?[-a-zA-Z0-9@:%._\+~#=]{1,256}\.[a-zA-Z0-9()]{1,6}\b([-a-zA-Z0-9()@:%_\+.~#?&//=]*))";
pub const APKPURE_DOWNLOAD_URL_REGEX: &str = r"(https?://(www\.)?[-a-zA-Z0-9@:%._\+~#=]{1,256}\.[a-zA-Z0-9()]{1,6}\b([-a-zA-Z0-9()@:%_\+.~#?&//=]*))";
pub const FDROID_REPO: &str = "https://f-droid.org/repo";
pub const FDROID_INDEX_FINGERPRINT: &[u8] = &[67, 35, 141, 81, 44, 30, 94, 178, 214, 86, 159, 74, 58, 251, 245, 82, 52, 24, 184, 46, 10, 62, 209, 85, 39, 112, 171, 185, 169, 201, 204, 171];
pub const FDROID_SIGNATURE_BLOCK_FILE_REGEX: &str = r"^META-INF/.*\.(DSA|EC|RSA)$";
Expand Down
8 changes: 8 additions & 0 deletions src/lib.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
pub mod apkpure;
pub mod fdroid;
pub mod google_play;
pub mod huawei_app_gallery;

mod progress_bar;
mod consts;
mod config;
2 changes: 1 addition & 1 deletion src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -284,7 +284,7 @@ async fn main() {

match download_source {
DownloadSource::APKPure => {
apkpure::download_apps(list, parallel, sleep_duration, &outpath).await;
apkpure::download_apps(list, parallel, sleep_duration, &outpath, true).await;
}
DownloadSource::GooglePlay => {
let mut username = matches.get_one::<String>("google_username").map(|v| v.to_string());
Expand Down