mirror of
https://github.com/fergalmoran/podnoms.git
synced 2025-12-22 09:18:08 +00:00
Go suck it
This commit is contained in:
1
.gitignore
vendored
1
.gitignore
vendored
@@ -5,3 +5,4 @@ promotion
|
||||
.working
|
||||
extension
|
||||
client/tags
|
||||
NYoutubeDL
|
||||
|
||||
@@ -28,6 +28,10 @@
|
||||
<div class="block-content">
|
||||
<button class="btn btn-primary"
|
||||
(click)="processOrphans()">Process Orphans</button>
|
||||
<button class="btn btn-primary"
|
||||
(click)="processPlaylists()">Process Playlists</button>
|
||||
<button class="btn btn-primary"
|
||||
(click)="updateYouTubeDl()">Update Youtube Downloader</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@@ -1,14 +1,14 @@
|
||||
import { Observable } from 'rxjs/Observable';
|
||||
import { SignalRService } from 'app/services/signalr.service';
|
||||
import { Component, OnInit } from '@angular/core';
|
||||
import { DebugService } from 'app/services/debug.service';
|
||||
import { environment } from 'environments/environment';
|
||||
import { JobsService } from 'app/services/jobs.service';
|
||||
import { Observable } from "rxjs/Observable";
|
||||
import { SignalRService } from "app/services/signalr.service";
|
||||
import { Component, OnInit } from "@angular/core";
|
||||
import { DebugService } from "app/services/debug.service";
|
||||
import { environment } from "environments/environment";
|
||||
import { JobsService } from "app/services/jobs.service";
|
||||
|
||||
@Component({
|
||||
selector: 'app-debug',
|
||||
templateUrl: './debug.component.html',
|
||||
styleUrls: ['./debug.component.css']
|
||||
selector: "app-debug",
|
||||
templateUrl: "./debug.component.html",
|
||||
styleUrls: ["./debug.component.css"]
|
||||
})
|
||||
export class DebugComponent implements OnInit {
|
||||
realtimeMessage: string;
|
||||
@@ -17,35 +17,59 @@ export class DebugComponent implements OnInit {
|
||||
debugInfo$: Observable<string>;
|
||||
apiHost = environment.API_HOST;
|
||||
signalrHost = environment.SIGNALR_HOST;
|
||||
pingPong = '';
|
||||
pingPong = "";
|
||||
|
||||
constructor(private _debugService: DebugService, private _jobsService: JobsService,
|
||||
private _signalrService: SignalRService) {}
|
||||
constructor(
|
||||
private _debugService: DebugService,
|
||||
private _jobsService: JobsService,
|
||||
private _signalrService: SignalRService
|
||||
) {}
|
||||
ngOnInit() {
|
||||
this._signalrService
|
||||
.init(`${environment.SIGNALR_HOST}hubs/debug`)
|
||||
.then(() => {
|
||||
this._signalrService.connection.on('Send', data => {
|
||||
console.log('DebugService', 'signalr', data);
|
||||
this._signalrService.connection.on("Send", data => {
|
||||
console.log("DebugService", "signalr", data);
|
||||
this.messagesReceived.push(data);
|
||||
this.realtimeMessage = '';
|
||||
this.realtimeMessage = "";
|
||||
});
|
||||
this.debugInfo$ = this._debugService.getDebugInfo();
|
||||
})
|
||||
.catch(err => console.error('debug.component.ts', '_signalrService.init', err));
|
||||
.catch(err =>
|
||||
console.error("debug.component.ts", "_signalrService.init", err)
|
||||
);
|
||||
|
||||
this._debugService.ping().subscribe(r => (this.pingPong = r));
|
||||
}
|
||||
|
||||
sendMessage() {
|
||||
this._debugService.sendRealtime(this.realtimeMessage).subscribe(r => console.log(r));
|
||||
this._debugService
|
||||
.sendRealtime(this.realtimeMessage)
|
||||
.subscribe(r => console.log(r));
|
||||
}
|
||||
doSomething() {
|
||||
alert('doSomething was did');
|
||||
alert("doSomething was did");
|
||||
}
|
||||
|
||||
processOrphans(){
|
||||
this._jobsService.processOrphans()
|
||||
.subscribe(e => console.log('debug.component.ts', 'processOrphans', e));
|
||||
processOrphans() {
|
||||
this._jobsService
|
||||
.processOrphans()
|
||||
.subscribe(e =>
|
||||
console.log("debug.component.ts", "processOrphans", e)
|
||||
);
|
||||
}
|
||||
processPlaylists() {
|
||||
this._jobsService
|
||||
.processPlaylists()
|
||||
.subscribe(e =>
|
||||
console.log("debug.component.ts", "processPlaylists", e)
|
||||
);
|
||||
}
|
||||
updateYouTubeDl() {
|
||||
this._jobsService
|
||||
.updateYouTubeDl()
|
||||
.subscribe(e =>
|
||||
console.log("debug.component.ts", "updateYouTubeDl", e)
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -6,9 +6,16 @@ import { environment } from 'environments/environment';
|
||||
|
||||
@Injectable()
|
||||
export class JobsService {
|
||||
constructor(private _http: AuthHttp) {}
|
||||
constructor(private _http: AuthHttp) { }
|
||||
|
||||
processOrphans(): Observable<Response> {
|
||||
return this._http.get(environment.API_HOST + '/job/processorphans');
|
||||
}
|
||||
|
||||
processPlaylists(): Observable<Response> {
|
||||
return this._http.get(environment.API_HOST + '/job/processplaylists');
|
||||
}
|
||||
updateYouTubeDl(): Observable<Response> {
|
||||
return this._http.get(environment.API_HOST + '/job/updateyoutubedl');
|
||||
}
|
||||
}
|
||||
|
||||
@@ -4,18 +4,25 @@ using Microsoft.AspNetCore.Authorization;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using PodNoms.Api.Services.Jobs;
|
||||
|
||||
namespace PodNoms.Api.Controllers
|
||||
{
|
||||
namespace PodNoms.Api.Controllers {
|
||||
[Authorize]
|
||||
[Route("[controller]")]
|
||||
[ApiExplorerSettings(IgnoreApi = true)]
|
||||
public class JobController : Controller
|
||||
{
|
||||
public class JobController : Controller {
|
||||
[HttpGet("processorphans")]
|
||||
public IActionResult ProcessOrphans()
|
||||
{
|
||||
public IActionResult ProcessOrphans() {
|
||||
var infoJobId = BackgroundJob.Enqueue<ClearOrphanAudioJob>(service => service.Execute());
|
||||
return Ok();
|
||||
}
|
||||
[HttpGet("processplaylists")]
|
||||
public IActionResult ProcessPlaylists() {
|
||||
var infoJobId = BackgroundJob.Enqueue<ProcessPlaylistsJob>(service => service.Execute());
|
||||
return Ok();
|
||||
}
|
||||
[HttpGet("updateyoutubedl")]
|
||||
public IActionResult UpdateYouTubeDl() {
|
||||
var infoJobId = BackgroundJob.Enqueue<UpdateYouTubeDlJob>(service => service.Execute());
|
||||
return Ok();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -16,7 +16,7 @@
|
||||
<PackageReference Include="AutoMapper" Version="6.2.2" />
|
||||
<PackageReference Include="AutoMapper.Extensions.Microsoft.DependencyInjection" Version="3.2.0" />
|
||||
<PackageReference Include="Handlebars.NetStandard" Version="1.8.1" />
|
||||
<PackageReference Include="NYoutubeDl" Version="0.6.3" />
|
||||
<PackageReference Include="NYouTubeDl" Version="0.6.3" />
|
||||
<PackageReference Include="Polly" Version="5.2.0" />
|
||||
<PackageReference Include="RestSharp" Version="106.1.0" />
|
||||
<PackageReference Include="ImageSharp" Version="1.0.0-*" />
|
||||
|
||||
@@ -16,7 +16,11 @@ namespace PodNoms.Api.Services.Downloader {
|
||||
|
||||
private readonly string _url;
|
||||
private readonly string _downloader;
|
||||
public VideoDownloadInfo Properties { get; private set; }
|
||||
|
||||
private DownloadInfo _properties;
|
||||
public VideoDownloadInfo Properties => _properties is VideoDownloadInfo ? (VideoDownloadInfo)_properties : null;
|
||||
public DownloadInfo RawProperties => _properties;
|
||||
|
||||
protected const string DOWNLOADRATESTRING = "iB/s";
|
||||
protected const string DOWNLOADSIZESTRING = "iB";
|
||||
protected const string ETASTRING = "ETA";
|
||||
@@ -55,15 +59,15 @@ namespace PodNoms.Api.Services.Downloader {
|
||||
await Task.Run(() => {
|
||||
var youtubeDl = new YoutubeDL();
|
||||
youtubeDl.VideoUrl = this._url;
|
||||
DownloadInfo info = youtubeDl.GetDownloadInfo();
|
||||
var info = youtubeDl.GetDownloadInfo();
|
||||
|
||||
if (info != null &&
|
||||
(info.Errors.Count == 0 || info.VideoSize != null)) {
|
||||
if (info is PlaylistDownloadInfo) {
|
||||
this._properties = info;
|
||||
if (info is PlaylistDownloadInfo && ((PlaylistDownloadInfo)info).Videos.Count > 0) {
|
||||
ret = AudioType.Playlist;
|
||||
} else if (info is VideoDownloadInfo) {
|
||||
ret = AudioType.Valid;
|
||||
this.Properties = (VideoDownloadInfo)info;
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
@@ -27,8 +27,8 @@ namespace PodNoms.Api.Services.Jobs {
|
||||
var downloader = new AudioDownloader(playlist.SourceUrl, _applicationsSettings.Downloader);
|
||||
var info = await downloader.GetInfo();
|
||||
if (info == AudioType.Playlist){
|
||||
var
|
||||
for (var item in downloader.Properties.)
|
||||
//var
|
||||
//for (var item in downloader.Properties.)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
15
server/Services/Jobs/UpdateYouTubeDlJob.cs
Normal file
15
server/Services/Jobs/UpdateYouTubeDlJob.cs
Normal file
@@ -0,0 +1,15 @@
|
||||
using System.Threading.Tasks;
|
||||
using NYoutubeDL;
|
||||
using PodNoms.Api.Services.Jobs;
|
||||
|
||||
namespace PodNoms.Api.Services.Jobs {
|
||||
public class UpdateYouTubeDlJob : IJob {
|
||||
public async Task Execute() {
|
||||
await Task.Run(() => {
|
||||
var yt = new YoutubeDL();
|
||||
yt.Options.GeneralOptions.Update = true;
|
||||
yt.Download("https://www.youtube.com/watch?v=OJ2wOKDzKyI");
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
3
server/commands
Normal file
3
server/commands
Normal file
@@ -0,0 +1,3 @@
|
||||
get-info
|
||||
youtube-dl --flat-playlist -i -J -s <url>
|
||||
|
||||
Reference in New Issue
Block a user