first commit
This commit is contained in:
0
src/app/app.component.css
Normal file
0
src/app/app.component.css
Normal file
100
src/app/app.component.html
Normal file
100
src/app/app.component.html
Normal file
@@ -0,0 +1,100 @@
|
||||
<div class="row mx-2">
|
||||
<div class="col-12 col-lg-8 mt-4">
|
||||
<div class="card shadow">
|
||||
<div class="card-content p-3 text-center">
|
||||
<h1 class="mb-6">CrawlFlix</h1>
|
||||
<small>Paramount+ / Max HBO / Netflix / Disney+ / Amazon Prime / Canal+</small>
|
||||
</div>
|
||||
</div>
|
||||
<div class="card shadow mt-3">
|
||||
<div class="card-content p-3">
|
||||
<form [formGroup]="processingForm" (ngSubmit)="onSubmit()">
|
||||
<div class="row">
|
||||
<div class="col-6">
|
||||
<label>MP4 Filename</label>
|
||||
<input type="text" formControlName="mp4Filename" class="form-control" placeholder="ex: S01E01">
|
||||
</div>
|
||||
<div class="col-6">
|
||||
<label>Wanted Resolution</label>
|
||||
<select formControlName="wantedResolution" class="form-select">
|
||||
<option value="4k">4K</option>
|
||||
<option value="1080p" selected>1080p</option>
|
||||
<option value="720p">720p</option>
|
||||
<option value="480p">480p</option>
|
||||
<option value="360p">360p</option>
|
||||
<option value="240p">240p</option>
|
||||
</select>
|
||||
</div>
|
||||
</div>
|
||||
<div class="flex flex-col mt-2">
|
||||
<label>MPD URL</label>
|
||||
<input type="text" formControlName="mpdUrl" class="form-control" placeholder="ex: https://....">
|
||||
</div>
|
||||
<div class="flex flex-col mt-2">
|
||||
<label>Widevine L3 Decryption Keys (one per line, key:value)</label>
|
||||
<textarea formControlName="keys" rows="4" class="form-control" placeholder="ex: ca2c28ab6c6a4e91935e12b6bb37a952:779afc2503a1ea7947b4747d24fbeb63"></textarea>
|
||||
</div>
|
||||
<button type="submit" [disabled]="!processingForm.valid" class="btn btn-primary float-end mt-2">Add to Queue</button>
|
||||
</form>
|
||||
|
||||
<!-- <div *ngIf="jobId" class="mt-6">
|
||||
<h2 class="text-xl font-semibold mb-2">Job Status</h2>
|
||||
<p>Job ID: {{ jobId }}</p>
|
||||
<p>Status: {{ jobStatus }}</p> ({{jobProgress}}%)
|
||||
<div class="w-full bg-gray-200 rounded-full h-2.5 mt-2">
|
||||
<div class="bg-blue-600 h-2.5 rounded-full" [style.width.%]="jobProgress"></div>
|
||||
</div>
|
||||
</div> -->
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-12 col-lg-4 mt-4">
|
||||
<div class="card shadow">
|
||||
<div class="card-header">
|
||||
Jobs Queue ({{jobs.length}})
|
||||
</div>
|
||||
<div class="card-content p-2" style="max-height: 90vh;overflow-y:scroll">
|
||||
<div class="row" *ngIf="jobs.length === 0">
|
||||
<div class="col-12 text-center py-3">
|
||||
<i class="fa fa-circle-notch fa-spin fa-2x"></i>
|
||||
</div>
|
||||
</div>
|
||||
<div *ngFor="let job of jobs | orderBy: 'addedOn':true; let last = last" class="pb-2" [ngClass]="{'border-bottom mb-2': !last}">
|
||||
<div class="row">
|
||||
<div class="col-8 text-center border-right mb-2">
|
||||
<b>{{job.data.mp4Filename}}</b><br>
|
||||
</div>
|
||||
<div class="col-4 text-center mb-2">
|
||||
<i>{{job.data.wantedResolution || '1080p'}}</i>
|
||||
</div>
|
||||
<div class="col-6">
|
||||
<p class="text-sm mb-1">Job ID: {{ job.id }}</p>
|
||||
</div>
|
||||
<div class="col-6 text-end">
|
||||
<p class="text-sm mb-1">Status: {{ job.state }}</p>
|
||||
</div>
|
||||
<div class="col-6">
|
||||
<p class="text-sm mb-1">Added {{ job.addedOn | amTimeAgo }}</p>
|
||||
</div>
|
||||
<div class="col-6 text-end">
|
||||
<p class="text-sm mb-1">Finished {{ job.finishedOn | amTimeAgo }}</p>
|
||||
</div>
|
||||
<div class="col-12">
|
||||
<p class="text-sm mb-1">Duration: {{ ((job.finishedOn - job.processedOn)/1000) | amDuration:'seconds' }}</p>
|
||||
</div>
|
||||
</div>
|
||||
<div class="alert alert-danger mt-2" *ngIf="job.state === 'failed' && job.failedReason">
|
||||
{{job.failedReason}}
|
||||
</div>
|
||||
<div class="alert alert-success mt-2 mb-4" *ngIf="job.state === 'completed' && job.returnValue?.message">
|
||||
{{job.returnValue?.message}}<br>
|
||||
<button *ngIf="job.returnValue.filePath && job.returnValue.fileName" [disabled]="job.isDownloading" class="btn btn-success btn-sm float-end" (click)="downloadFileFromAPI(job.returnValue.filePath, job.returnValue.fileName, job)"><i *ngIf="!job.isDownloading" class="fa fa-download me-2"></i><i *ngIf="job.isDownloading" class="fa fa-circle-notch fa-spin me-2"></i>Download</button>
|
||||
</div>
|
||||
<div class="progress" *ngIf="job.state !== 'failed'">
|
||||
<div class="progress-bar" [ngClass]="{'bg-warning': job.state === 'waiting', 'bg-success': job.state === 'completed', 'bg-danger': job.state === 'failed'}" role="progressbar" [style.width.%]="job.progress" aria-valuemin="0" aria-valuemax="100">{{job.progress}}%</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
29
src/app/app.component.spec.ts
Normal file
29
src/app/app.component.spec.ts
Normal file
@@ -0,0 +1,29 @@
|
||||
import { TestBed } from '@angular/core/testing';
|
||||
import { AppComponent } from './app.component';
|
||||
|
||||
describe('AppComponent', () => {
|
||||
beforeEach(async () => {
|
||||
await TestBed.configureTestingModule({
|
||||
imports: [AppComponent],
|
||||
}).compileComponents();
|
||||
});
|
||||
|
||||
it('should create the app', () => {
|
||||
const fixture = TestBed.createComponent(AppComponent);
|
||||
const app = fixture.componentInstance;
|
||||
expect(app).toBeTruthy();
|
||||
});
|
||||
|
||||
it(`should have the 'crawlflix' title`, () => {
|
||||
const fixture = TestBed.createComponent(AppComponent);
|
||||
const app = fixture.componentInstance;
|
||||
expect(app.title).toEqual('crawlflix');
|
||||
});
|
||||
|
||||
it('should render title', () => {
|
||||
const fixture = TestBed.createComponent(AppComponent);
|
||||
fixture.detectChanges();
|
||||
const compiled = fixture.nativeElement as HTMLElement;
|
||||
expect(compiled.querySelector('h1')?.textContent).toContain('Hello, crawlflix');
|
||||
});
|
||||
});
|
||||
127
src/app/app.component.ts
Normal file
127
src/app/app.component.ts
Normal file
@@ -0,0 +1,127 @@
|
||||
import { Component, OnInit } from '@angular/core';
|
||||
import { CommonModule } from '@angular/common';
|
||||
import { ReactiveFormsModule, FormBuilder, FormGroup, Validators } from '@angular/forms';
|
||||
import { VideoProcessingService } from './video-processing.service';
|
||||
import { MomentModule } from 'ngx-moment';
|
||||
import { OrderModule } from 'ngx-order-pipe';
|
||||
|
||||
@Component({
|
||||
selector: 'app-root',
|
||||
standalone: true,
|
||||
imports: [CommonModule, ReactiveFormsModule, MomentModule, OrderModule],
|
||||
templateUrl: './app.component.html',
|
||||
styles: []
|
||||
})
|
||||
export class AppComponent implements OnInit {
|
||||
processingForm: FormGroup;
|
||||
jobId: string | null = null;
|
||||
jobStatus: string | null = null;
|
||||
jobProgress: number = 0;
|
||||
jobs: Array<any> = [];
|
||||
|
||||
initForm() {
|
||||
this.processingForm = this.fb.group({
|
||||
mp4Filename: ['', Validators.required],
|
||||
mpdUrl: ['', Validators.required],
|
||||
keys: ['', Validators.required],
|
||||
wantedResolution: ['1080p', Validators.required]
|
||||
});
|
||||
}
|
||||
|
||||
constructor(private fb: FormBuilder,
|
||||
private videoProcessingService: VideoProcessingService) {
|
||||
this.processingForm = this.fb.group({
|
||||
mp4Filename: ['', Validators.required],
|
||||
mpdUrl: ['', Validators.required],
|
||||
keys: ['', Validators.required],
|
||||
wantedResolution: ['1080p', Validators.required]
|
||||
});
|
||||
}
|
||||
|
||||
ngOnInit(): void {
|
||||
this.startPollingJobsStatus();
|
||||
}
|
||||
|
||||
downloadFileFromAPI(filePath: string, filename: string, job: any) {
|
||||
job.isDownloading = true;
|
||||
this.videoProcessingService.downloadFile(filePath).subscribe({
|
||||
next: (response) => {
|
||||
const blob = new Blob([response], { type: 'video/mp4' });
|
||||
const url = window.URL.createObjectURL(blob);
|
||||
const a = document.createElement('a');
|
||||
a.href = url;
|
||||
a.download = filename;
|
||||
a.click();
|
||||
window.URL.revokeObjectURL(url);
|
||||
job.isDownloading = false;
|
||||
},
|
||||
error: (error) => {
|
||||
console.error('Error downloading file:', error);
|
||||
job.isDownloading = false;
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
onSubmit() {
|
||||
if (this.processingForm.valid) {
|
||||
const formData = this.processingForm.value;
|
||||
|
||||
this.videoProcessingService.startProcess(Object.assign(formData, {
|
||||
keys: this.parseKeys(formData.keys)
|
||||
})).subscribe({
|
||||
next: (response) => {
|
||||
//this.jobId = response.jobId;
|
||||
},
|
||||
error: (error) => {
|
||||
console.error('Error starting process:', error);
|
||||
}
|
||||
});
|
||||
this.initForm();
|
||||
}
|
||||
}
|
||||
|
||||
parseKeys(keysString: string): { key: string, value: string }[] {
|
||||
console.log('KS =', keysString);
|
||||
return keysString.split('\n').map(line => line.trim())
|
||||
.filter(line => line.includes(':'))
|
||||
.map(line => {
|
||||
const [key, value] = line.split(':').map(part => part.trim());
|
||||
return { key, value };
|
||||
});
|
||||
}
|
||||
|
||||
// startPollingJobsStatus() {
|
||||
// const interval = setInterval(() => {
|
||||
// this.videoProcessingService.getJobsStatus(this.jobId!).subscribe({
|
||||
// next: (response) => {
|
||||
// this.jobStatus = response.state;
|
||||
// this.jobProgress = response.progress;
|
||||
// if (['completed', 'failed'].includes(response.state)) {
|
||||
// clearInterval(interval);
|
||||
// }
|
||||
// },
|
||||
// error: (error) => {
|
||||
// console.error('Error fetching job status:', error);
|
||||
// clearInterval(interval);
|
||||
// }
|
||||
// });
|
||||
// }, 1000);
|
||||
// }
|
||||
|
||||
startPollingJobsStatus() {
|
||||
const interval = setInterval(() => {
|
||||
this.videoProcessingService.getJobsStatus().subscribe({
|
||||
next: (response) => {
|
||||
this.jobs = response;
|
||||
// if (['completed', 'failed'].includes(response.state)) {
|
||||
// clearInterval(interval);
|
||||
// }
|
||||
},
|
||||
error: (error) => {
|
||||
console.error('Error fetching job status:', error);
|
||||
//clearInterval(interval);
|
||||
}
|
||||
});
|
||||
}, 1000);
|
||||
}
|
||||
}
|
||||
16
src/app/app.config.ts
Normal file
16
src/app/app.config.ts
Normal file
@@ -0,0 +1,16 @@
|
||||
import { ApplicationConfig, provideZoneChangeDetection } from '@angular/core';
|
||||
import { provideRouter } from '@angular/router';
|
||||
import { provideHttpClient } from '@angular/common/http';
|
||||
import { importProvidersFrom } from '@angular/core'; // Importe cette fonction
|
||||
import { MomentModule } from 'ngx-moment';
|
||||
|
||||
import { routes } from './app.routes';
|
||||
|
||||
export const appConfig: ApplicationConfig = {
|
||||
providers: [
|
||||
provideZoneChangeDetection({ eventCoalescing: true }),
|
||||
provideRouter(routes),
|
||||
provideHttpClient(),
|
||||
importProvidersFrom(MomentModule) // Utilise importProvidersFrom pour intégrer le module
|
||||
]
|
||||
};
|
||||
3
src/app/app.routes.ts
Normal file
3
src/app/app.routes.ts
Normal file
@@ -0,0 +1,3 @@
|
||||
import { Routes } from '@angular/router';
|
||||
|
||||
export const routes: Routes = [];
|
||||
24
src/app/video-processing.service.ts
Normal file
24
src/app/video-processing.service.ts
Normal file
@@ -0,0 +1,24 @@
|
||||
import { Injectable } from '@angular/core';
|
||||
import { HttpClient } from '@angular/common/http';
|
||||
import { Observable } from 'rxjs';
|
||||
|
||||
@Injectable({
|
||||
providedIn: 'root'
|
||||
})
|
||||
export class VideoProcessingService {
|
||||
private apiUrl = 'http://localhost:3000';
|
||||
|
||||
constructor(private http: HttpClient) { }
|
||||
|
||||
startProcess(data: any): Observable<{ jobId: string }> {
|
||||
return this.http.post<{ jobId: string }>(`${this.apiUrl}/start-process`, data);
|
||||
}
|
||||
|
||||
getJobsStatus(): Observable<Array<any>> {
|
||||
return this.http.get<Array<any>>(`${this.apiUrl}/jobs-status`);
|
||||
}
|
||||
|
||||
downloadFile(filePath: string): Observable<Blob> {
|
||||
return this.http.get(`${this.apiUrl}/download/${filePath}`, { responseType: 'blob' });
|
||||
}
|
||||
}
|
||||
15
src/index.html
Normal file
15
src/index.html
Normal file
@@ -0,0 +1,15 @@
|
||||
<!doctype html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<title>Crawlflix</title>
|
||||
<base href="/">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1">
|
||||
<link rel="icon" type="image/x-icon" href="favicon.ico">
|
||||
<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.3/dist/css/bootstrap.min.css" rel="stylesheet" integrity="sha384-QWTKZyjpPEjISv5WaRU9OFeRpok6YctnYmDr5pNlyT2bRjXh0JMhjY6hW+ALEwIH" crossorigin="anonymous">
|
||||
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.6.0/css/all.min.css" integrity="sha512-Kc323vGBEqzTmouAECnVceyQqyqdsSiqLQISBL29aUW4U/M7pSPA/gEUZQqv1cwx4OnYxTxve5UMg5GT6L4JJg==" crossorigin="anonymous" referrerpolicy="no-referrer" />
|
||||
</head>
|
||||
<body>
|
||||
<app-root></app-root>
|
||||
</body>
|
||||
</html>
|
||||
6
src/main.ts
Normal file
6
src/main.ts
Normal file
@@ -0,0 +1,6 @@
|
||||
import { bootstrapApplication } from '@angular/platform-browser';
|
||||
import { appConfig } from './app/app.config';
|
||||
import { AppComponent } from './app/app.component';
|
||||
|
||||
bootstrapApplication(AppComponent, appConfig)
|
||||
.catch((err) => console.error(err));
|
||||
1
src/styles.css
Normal file
1
src/styles.css
Normal file
@@ -0,0 +1 @@
|
||||
/* You can add global styles to this file, and also import other style files */
|
||||
Reference in New Issue
Block a user