forked from Outils-PeerTube/peertube-plugin-auto-import-ytb
Prettier
This commit is contained in:
parent
afdd320056
commit
db856aa6e2
36
src/main.ts
36
src/main.ts
|
@ -1,5 +1,5 @@
|
|||
import { ListenerRssAggregator } from 'listener-rss-agregator';
|
||||
import { ListenerRSSInfos } from 'listener-rss';
|
||||
import { ListenerRssAggregator } from "listener-rss-agregator";
|
||||
import { ListenerRSSInfos } from "listener-rss";
|
||||
type ListenerData = {
|
||||
ChannelId: number;
|
||||
firstUpdate: boolean;
|
||||
|
@ -10,8 +10,8 @@ let listenersDataBinding = new Map<string, ListenerData>();
|
|||
let logger: any;
|
||||
let firstUpdate = true;
|
||||
|
||||
import * as path from 'path';
|
||||
import fs from 'fs';
|
||||
import * as path from "path";
|
||||
import fs from "fs";
|
||||
|
||||
async function register({
|
||||
registerSetting,
|
||||
|
@ -22,35 +22,35 @@ async function register({
|
|||
logger = peertubeHelpers.logger;
|
||||
|
||||
registerSetting({
|
||||
name: 'ytb-urls',
|
||||
label: 'liste des urls youtube a auto-importer',
|
||||
type: 'input-textarea',
|
||||
name: "ytb-urls",
|
||||
label: "liste des urls youtube a auto-importer",
|
||||
type: "input-textarea",
|
||||
});
|
||||
|
||||
logger.warn('setting register');
|
||||
fs.appendFileSync(path.join(basePath, '/storage.bd'), ''); // append
|
||||
logger.warn("setting register");
|
||||
fs.appendFileSync(path.join(basePath, "/storage.bd"), ""); // append
|
||||
|
||||
const configAggregator = await ListenerRssAggregator.instantiateAggregator(
|
||||
path.join(basePath, '/storage.bd')
|
||||
path.join(basePath, "/storage.bd")
|
||||
);
|
||||
myManager = new ListenerRssAggregator(configAggregator);
|
||||
|
||||
logger.warn('Aggregator created');
|
||||
logger.warn("Aggregator created");
|
||||
|
||||
const inputs = await settingsManager.getSetting('ytb-urls');
|
||||
const inputs = await settingsManager.getSetting("ytb-urls");
|
||||
if (inputs) await addListeners(inputs);
|
||||
|
||||
logger.warn('Config loaded');
|
||||
logger.warn("Config loaded");
|
||||
|
||||
settingsManager.onSettingsChange(async (settings: any) => {
|
||||
await addListeners(settings['ytb-urls']);
|
||||
await addListeners(settings["ytb-urls"]);
|
||||
});
|
||||
|
||||
myManager.on('newEntries', (entries: any) => {
|
||||
myManager.on("newEntries", (entries: any) => {
|
||||
const datas = listenersDataBinding.get(entries.addressListener);
|
||||
if (!datas) return;
|
||||
|
||||
logger.warn('Nouvelles entrées détéctées: ' + JSON.stringify(entries));
|
||||
logger.warn("Nouvelles entrées détéctées: " + JSON.stringify(entries));
|
||||
});
|
||||
}
|
||||
|
||||
|
@ -59,7 +59,7 @@ async function addListeners(listenerInput: string) {
|
|||
try {
|
||||
listeners = JSON.parse(listenerInput);
|
||||
} catch {
|
||||
logger.warn('Erreur: malformé');
|
||||
logger.warn("Erreur: malformé");
|
||||
return;
|
||||
}
|
||||
let newListeners = listeners.filter(
|
||||
|
@ -84,7 +84,7 @@ async function addListeners(listenerInput: string) {
|
|||
await myManager.saveOverride(listeners);
|
||||
firstUpdate = true;
|
||||
|
||||
if (logger) logger.warn('Configuration modifiée: ' + listenerInput);
|
||||
if (logger) logger.warn("Configuration modifiée: " + listenerInput);
|
||||
|
||||
myManager.startAll();
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue
Block a user