This commit is contained in:
Isaac Grynsztein
2018-01-13 22:14:10 -05:00
parent d6cb024de1
commit 1eaf897be0
26 changed files with 284 additions and 12 deletions

View File

@@ -27,7 +27,7 @@
</form>
<br/>
<mat-checkbox [(ngModel)]="audioOnly" style="float: left; margin-top: -12px">Only Audio</mat-checkbox>
<button style="float: right; margin-top: -16px" (click)="downloadClicked()" [disabled]="downloadingmp3" type="submit" mat-raised-button color="primary">Download</button>
<button style="float: right; margin-top: -16px" (click)="downloadClicked()" [disabled]="downloadingfile" type="submit" mat-raised-button color="primary">Download</button>
</mat-card-content>
</div>
</mat-card>

View File

@@ -13,12 +13,12 @@ import 'rxjs/add/operator/toPromise';
styleUrls: ['./app.component.css']
})
export class AppComponent {
downloadingmp3: boolean = false;
downloadingfile: boolean = false;
audioOnly: boolean;
urlError: boolean = false;
path: string = '';
url: string = '';
exists: boolean = false;
exists: string = "";
topBarTitle: string = "Youtube Downloader";
constructor(private postsService: PostsService) {
this.audioOnly = true;
@@ -48,13 +48,13 @@ export class AppComponent {
{
this.postsService.getFileStatusMp3(name).subscribe(fileExists => {
this.exists = fileExists;
if (this.exists == false)
if (this.exists == "failed")
{
this.downloadHelperMp3(name);
}
else
{
window.location.href = 'https://grynsztein.com/audio/' + this.path + ".mp3";
window.location.href = this.exists;
}
});
@@ -64,13 +64,13 @@ export class AppComponent {
{
this.postsService.getFileStatusMp4(name).subscribe(fileExists => {
this.exists = fileExists;
if (this.exists == false)
if (this.exists == "failed")
{
this.downloadHelperMp4(name);
}
else
{
window.location.href = 'https://grynsztein.com/video/' + this.path + ".mp4";
window.location.href = this.exists;
}
});
@@ -85,7 +85,7 @@ export class AppComponent {
if (this.audioOnly)
{
this.downloadingmp3 = true;
this.downloadingfile = true;
this.postsService.makeMP3(this.url).subscribe(posts => {
this.path = posts;
if (this.path != "-1")
@@ -97,7 +97,7 @@ export class AppComponent {
}
else
{
this.downloadingmp3 = true;
this.downloadingfile = true;
this.postsService.makeMP4(this.url).subscribe(posts => {
this.path = posts;
if (this.path != "-1")

View File

@@ -48,12 +48,12 @@ export class PostsService {
.map(res => res.json());
}
getFileStatusMp3(name: string): Observable<boolean> {
getFileStatusMp3(name: string): Observable<string> {
return this.http.post(this.path + "mp3fileexists",{name: name})
.map(res => res.json());
}
getFileStatusMp4(name: string): Observable<boolean> {
getFileStatusMp4(name: string): Observable<string> {
return this.http.post(this.path + "mp4fileexists",{name: name})
.map(res => res.json());
}