Compare commits
2 commits
c0d54b2916
...
1fe6d01978
Author | SHA1 | Date | |
---|---|---|---|
1fe6d01978 | |||
c35adbcc0a |
4 changed files with 173 additions and 21 deletions
68
.forgejo/workflows/docker-build-push.yaml
Normal file
68
.forgejo/workflows/docker-build-push.yaml
Normal file
|
@ -0,0 +1,68 @@
|
||||||
|
name: Build and Push Docker Image
|
||||||
|
|
||||||
|
# Define when this workflow will run
|
||||||
|
on:
|
||||||
|
push:
|
||||||
|
branches:
|
||||||
|
- master # Trigger on pushes to master branch
|
||||||
|
tags:
|
||||||
|
- '[0-9]+.[0-9]+.[0-9]+' # Trigger on semantic version tags
|
||||||
|
paths-ignore:
|
||||||
|
- 'Cargo.lock'
|
||||||
|
- 'LICENSE'
|
||||||
|
- 'README.md'
|
||||||
|
- 'docker-compose.yml'
|
||||||
|
workflow_dispatch: # Allow manual triggering of the workflow
|
||||||
|
|
||||||
|
# Define environment variables used throughout the workflow
|
||||||
|
env:
|
||||||
|
REGISTRY: git.nadeko.net
|
||||||
|
IMAGE_NAME: fijxu/inv_sig_helper
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
build-and-push:
|
||||||
|
runs-on: runner
|
||||||
|
|
||||||
|
steps:
|
||||||
|
# Step 1: Check out the repository code
|
||||||
|
- name: Checkout code
|
||||||
|
uses: https://github.com/actions/checkout@v3
|
||||||
|
|
||||||
|
# Step 3: Set up Docker Buildx for enhanced build capabilities
|
||||||
|
- name: Set up Docker Buildx
|
||||||
|
uses: https://github.com/docker/setup-buildx-action@v3
|
||||||
|
|
||||||
|
# Step 4: Authenticate with Quay.io registry
|
||||||
|
- name: Login to Docker Container Registry
|
||||||
|
uses: https://github.com/docker/login-action@v3.1.0
|
||||||
|
with:
|
||||||
|
registry: git.nadeko.net
|
||||||
|
username: ${{ secrets.USERNAME }}
|
||||||
|
password: ${{ secrets.TOKEN }}
|
||||||
|
|
||||||
|
# Step 5: Extract metadata for Docker image tagging and labeling
|
||||||
|
- name: Extract metadata for Docker
|
||||||
|
id: meta
|
||||||
|
uses: https://github.com/docker/metadata-action@v4
|
||||||
|
with:
|
||||||
|
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
|
||||||
|
# Define tagging strategy
|
||||||
|
tags: |
|
||||||
|
type=semver,pattern={{version}}
|
||||||
|
type=semver,pattern={{major}}.{{minor}}
|
||||||
|
type=semver,pattern={{major}}
|
||||||
|
type=raw,value=latest,enable=${{ github.ref == format('refs/heads/{0}', 'master') }}
|
||||||
|
type=sha,prefix={{branch}}-
|
||||||
|
# Define labels
|
||||||
|
labels: |
|
||||||
|
quay.expires-after=12w
|
||||||
|
|
||||||
|
# Step 6: Build and push the Docker image
|
||||||
|
- name: Build and push Docker image
|
||||||
|
uses: https://github.com/docker/build-push-action@v5
|
||||||
|
with:
|
||||||
|
context: .
|
||||||
|
push: true
|
||||||
|
platforms: linux/amd64
|
||||||
|
tags: ${{ steps.meta.outputs.tags }}
|
||||||
|
labels: ${{ steps.meta.outputs.labels }}
|
75
X7dZ.patch
Normal file
75
X7dZ.patch
Normal file
|
@ -0,0 +1,75 @@
|
||||||
|
diff --git a/src/player.rs b/src/player.rs
|
||||||
|
index 23333b3..a3d79af 100644
|
||||||
|
--- a/src/player.rs
|
||||||
|
+++ b/src/player.rs
|
||||||
|
@@ -18,8 +18,10 @@ pub enum FetchUpdateStatus {
|
||||||
|
CannotFetchPlayerJS,
|
||||||
|
NsigRegexCompileFailed,
|
||||||
|
PlayerAlreadyUpdated,
|
||||||
|
+ SignatureExtractionFailed,
|
||||||
|
}
|
||||||
|
|
||||||
|
+
|
||||||
|
pub async fn fetch_update(state: Arc<GlobalState>) -> Result<(), FetchUpdateStatus> {
|
||||||
|
let global_state = state.clone();
|
||||||
|
let response = match reqwest::get(TEST_YOUTUBE_VIDEO).await {
|
||||||
|
@@ -145,33 +147,39 @@ pub async fn fetch_update(state: Arc<GlobalState>) -> Result<(), FetchUpdateStat
|
||||||
|
}
|
||||||
|
|
||||||
|
// Extract signature function name
|
||||||
|
- let sig_function_name = REGEX_SIGNATURE_FUNCTION
|
||||||
|
- .captures(&player_javascript)
|
||||||
|
- .unwrap()
|
||||||
|
- .get(1)
|
||||||
|
- .unwrap()
|
||||||
|
- .as_str();
|
||||||
|
+ let sig_function_name = match REGEX_SIGNATURE_FUNCTION.captures(&player_javascript) {
|
||||||
|
+ Some(captures) => match captures.get(1) {
|
||||||
|
+ Some(m) => m.as_str(),
|
||||||
|
+ None => return Err(FetchUpdateStatus::NsigRegexCompileFailed),
|
||||||
|
+ },
|
||||||
|
+ None => return Err(FetchUpdateStatus::NsigRegexCompileFailed),
|
||||||
|
+ };
|
||||||
|
|
||||||
|
let mut sig_function_body_regex_str: String = String::new();
|
||||||
|
sig_function_body_regex_str += &sig_function_name.replace("$", "\\$");
|
||||||
|
sig_function_body_regex_str += "=function\\([a-zA-Z0-9_]+\\)\\{.+?\\}";
|
||||||
|
|
||||||
|
- let sig_function_body_regex = Regex::new(&sig_function_body_regex_str).unwrap();
|
||||||
|
+ let sig_function_body_regex = match Regex::new(&sig_function_body_regex_str) {
|
||||||
|
+ Ok(r) => r,
|
||||||
|
+ Err(_) => return Err(FetchUpdateStatus::NsigRegexCompileFailed),
|
||||||
|
+ };
|
||||||
|
|
||||||
|
- let sig_function_body = sig_function_body_regex
|
||||||
|
- .captures(&player_javascript)
|
||||||
|
- .unwrap()
|
||||||
|
- .get(0)
|
||||||
|
- .unwrap()
|
||||||
|
- .as_str();
|
||||||
|
+ let sig_function_body = match sig_function_body_regex.captures(&player_javascript) {
|
||||||
|
+ Some(captures) => match captures.get(0) {
|
||||||
|
+ Some(m) => m.as_str(),
|
||||||
|
+ None => return Err(FetchUpdateStatus::NsigRegexCompileFailed),
|
||||||
|
+ },
|
||||||
|
+ None => return Err(FetchUpdateStatus::NsigRegexCompileFailed),
|
||||||
|
+ };
|
||||||
|
|
||||||
|
- // Get the helper object
|
||||||
|
- let helper_object_name = REGEX_HELPER_OBJ_NAME
|
||||||
|
- .captures(sig_function_body)
|
||||||
|
- .unwrap()
|
||||||
|
- .get(1)
|
||||||
|
- .unwrap()
|
||||||
|
- .as_str();
|
||||||
|
+ // Get the helper object
|
||||||
|
+ let helper_object_name = match REGEX_HELPER_OBJ_NAME.captures(sig_function_body) {
|
||||||
|
+ Some(captures) => match captures.get(1) {
|
||||||
|
+ Some(m) => m.as_str(),
|
||||||
|
+ None => return Err(FetchUpdateStatus::NsigRegexCompileFailed),
|
||||||
|
+ },
|
||||||
|
+ None => return Err(FetchUpdateStatus::NsigRegexCompileFailed),
|
||||||
|
+ };
|
||||||
|
|
||||||
|
let mut helper_object_body_regex_str = String::new();
|
||||||
|
helper_object_body_regex_str += "(var ";
|
|
@ -21,7 +21,8 @@ pub static NSIG_FUNCTION_ENDINGS: &[&str] = &[
|
||||||
pub static REGEX_SIGNATURE_TIMESTAMP: &Lazy<Regex> = regex!("signatureTimestamp[=:](\\d+)");
|
pub static REGEX_SIGNATURE_TIMESTAMP: &Lazy<Regex> = regex!("signatureTimestamp[=:](\\d+)");
|
||||||
|
|
||||||
pub static REGEX_SIGNATURE_FUNCTION: &Lazy<Regex> =
|
pub static REGEX_SIGNATURE_FUNCTION: &Lazy<Regex> =
|
||||||
regex!("\\bc&&\\(c=([a-zA-Z0-9$]{2,})\\(decodeURIComponent\\(c\\)\\)");
|
regex!("\\b[a-zA-Z]+&&\\([a-zA-Z]+=([a-zA-Z0-9$]{2,})\\(decodeURIComponent\\([a-zA-Z]+\\)\\)");
|
||||||
|
|
||||||
pub static REGEX_HELPER_OBJ_NAME: &Lazy<Regex> = regex!(";([A-Za-z0-9_\\$]{2,})\\...\\(");
|
pub static REGEX_HELPER_OBJ_NAME: &Lazy<Regex> = regex!(";([A-Za-z0-9_\\$]{2,})\\...\\(");
|
||||||
|
|
||||||
pub static NSIG_FUNCTION_NAME: &str = "decrypt_nsig";
|
pub static NSIG_FUNCTION_NAME: &str = "decrypt_nsig";
|
||||||
|
|
|
@ -18,8 +18,10 @@ pub enum FetchUpdateStatus {
|
||||||
CannotFetchPlayerJS,
|
CannotFetchPlayerJS,
|
||||||
NsigRegexCompileFailed,
|
NsigRegexCompileFailed,
|
||||||
PlayerAlreadyUpdated,
|
PlayerAlreadyUpdated,
|
||||||
|
SignatureExtractionFailed,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
pub async fn fetch_update(state: Arc<GlobalState>) -> Result<(), FetchUpdateStatus> {
|
pub async fn fetch_update(state: Arc<GlobalState>) -> Result<(), FetchUpdateStatus> {
|
||||||
let global_state = state.clone();
|
let global_state = state.clone();
|
||||||
let response = match reqwest::get(TEST_YOUTUBE_VIDEO).await {
|
let response = match reqwest::get(TEST_YOUTUBE_VIDEO).await {
|
||||||
|
@ -145,33 +147,39 @@ pub async fn fetch_update(state: Arc<GlobalState>) -> Result<(), FetchUpdateStat
|
||||||
}
|
}
|
||||||
|
|
||||||
// Extract signature function name
|
// Extract signature function name
|
||||||
let sig_function_name = REGEX_SIGNATURE_FUNCTION
|
let sig_function_name = match REGEX_SIGNATURE_FUNCTION.captures(&player_javascript) {
|
||||||
.captures(&player_javascript)
|
Some(captures) => match captures.get(1) {
|
||||||
.unwrap()
|
Some(m) => m.as_str(),
|
||||||
.get(1)
|
None => return Err(FetchUpdateStatus::NsigRegexCompileFailed),
|
||||||
.unwrap()
|
},
|
||||||
.as_str();
|
None => return Err(FetchUpdateStatus::NsigRegexCompileFailed),
|
||||||
|
};
|
||||||
|
|
||||||
let mut sig_function_body_regex_str: String = String::new();
|
let mut sig_function_body_regex_str: String = String::new();
|
||||||
sig_function_body_regex_str += &sig_function_name.replace("$", "\\$");
|
sig_function_body_regex_str += &sig_function_name.replace("$", "\\$");
|
||||||
sig_function_body_regex_str += "=function\\([a-zA-Z0-9_]+\\)\\{.+?\\}";
|
sig_function_body_regex_str += "=function\\([a-zA-Z0-9_]+\\)\\{.+?\\}";
|
||||||
|
|
||||||
let sig_function_body_regex = Regex::new(&sig_function_body_regex_str).unwrap();
|
let sig_function_body_regex = match Regex::new(&sig_function_body_regex_str) {
|
||||||
|
Ok(r) => r,
|
||||||
|
Err(_) => return Err(FetchUpdateStatus::NsigRegexCompileFailed),
|
||||||
|
};
|
||||||
|
|
||||||
let sig_function_body = sig_function_body_regex
|
let sig_function_body = match sig_function_body_regex.captures(&player_javascript) {
|
||||||
.captures(&player_javascript)
|
Some(captures) => match captures.get(0) {
|
||||||
.unwrap()
|
Some(m) => m.as_str(),
|
||||||
.get(0)
|
None => return Err(FetchUpdateStatus::NsigRegexCompileFailed),
|
||||||
.unwrap()
|
},
|
||||||
.as_str();
|
None => return Err(FetchUpdateStatus::NsigRegexCompileFailed),
|
||||||
|
};
|
||||||
|
|
||||||
// Get the helper object
|
// Get the helper object
|
||||||
let helper_object_name = REGEX_HELPER_OBJ_NAME
|
let helper_object_name = match REGEX_HELPER_OBJ_NAME.captures(sig_function_body) {
|
||||||
.captures(sig_function_body)
|
Some(captures) => match captures.get(1) {
|
||||||
.unwrap()
|
Some(m) => m.as_str(),
|
||||||
.get(1)
|
None => return Err(FetchUpdateStatus::NsigRegexCompileFailed),
|
||||||
.unwrap()
|
},
|
||||||
.as_str();
|
None => return Err(FetchUpdateStatus::NsigRegexCompileFailed),
|
||||||
|
};
|
||||||
|
|
||||||
let mut helper_object_body_regex_str = String::new();
|
let mut helper_object_body_regex_str = String::new();
|
||||||
helper_object_body_regex_str += "(var ";
|
helper_object_body_regex_str += "(var ";
|
||||||
|
|
Loading…
Add table
Reference in a new issue