Skip to content

Commit

Permalink
replace more old iso parse date
Browse files Browse the repository at this point in the history
  • Loading branch information
MrBrax committed Apr 26, 2022
1 parent 2afe202 commit 0391332
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 13 deletions.
4 changes: 2 additions & 2 deletions server/src/Controllers/Channels.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import { replaceAll } from "../Helpers/ReplaceAll";
import { Helper } from "../Core/Helper";
import { Config } from "../Core/Config";
import path from "path";
import { parse } from "date-fns";
import { parse, parseJSON } from "date-fns";
import { Webhook } from "../Core/Webhook";

export async function ListChannels(req: express.Request, res: express.Response): Promise<void> {
Expand Down Expand Up @@ -275,7 +275,7 @@ export async function DownloadVideo(req: express.Request, res: express.Response)
// vod.streamer_name = channel.display_name || channel.login;
// vod.streamer_login = channel.login;
// vod.streamer_id = channel.userid || "";
vod.started_at = parse(video.created_at, Helper.TWITCH_DATE_FORMAT, new Date());
vod.started_at = parseJSON(video.created_at);

const duration = Helper.parseTwitchDuration(video.duration);
vod.ended_at = new Date(vod.started_at.getTime() + (duration * 1000));
Expand Down
5 changes: 3 additions & 2 deletions server/src/Core/Automator.ts
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,8 @@ export class Automator {

public getDateTime() {
// return date(TwitchHelper::DATE_FORMAT);
return format(new Date(), Helper.TWITCH_DATE_FORMAT);
// return format(new Date(), Helper.TWITCH_DATE_FORMAT);
return JSON.stringify(new Date());
}

public streamURL() {
Expand Down Expand Up @@ -579,7 +580,7 @@ export class Automator {
this.vod.meta = this.payload_eventsub;
// this.vod.json.meta = $this.payload_eventsub; // what
this.vod.capture_id = this.getVodID() || "1";
this.vod.started_at = parseJSON(data_started); // parse(data_started, Helper.TWITCH_DATE_FORMAT, new Date());
this.vod.started_at = parseJSON(data_started);

if (this.force_record) this.vod.force_record = true;

Expand Down
12 changes: 4 additions & 8 deletions server/src/Core/Helper.ts
Original file line number Diff line number Diff line change
Expand Up @@ -136,14 +136,6 @@ export class Helper {
return BaseConfigDataFolder.vod + (Config.getInstance().cfg("channel_folders") && username !== "" ? path.sep + username : "");
}

public static JSDateToPHPDate(date: Date) {
return {
date: format(date, this.PHP_DATE_FORMAT),
timezone_type: 3,
timezone: "UTC",
};
}

/**
* For some reason, twitch uses "1h1m1s" for durations, not seconds
* thanks copilot
Expand Down Expand Up @@ -283,6 +275,10 @@ export class Helper {
return exists ? full_path : false;
}

/**
* As of 2022, tcd does no longer work due to the Twitch API being shut down
* @deprecated
*/
public static path_tcd(): string | false {
if (!Config.getInstance().cfg("bin_dir")) return false;
const full_path = path.join(Config.getInstance().cfg("bin_dir"), `tcd${this.is_windows() ? ".exe" : ""}`);
Expand Down
2 changes: 1 addition & 1 deletion server/src/Core/TwitchVOD.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1060,7 +1060,7 @@ export class TwitchVOD {
}

for (const video of channel_videos) {
const video_time = parse(video.created_at, Helper.TWITCH_DATE_FORMAT, new Date());
const video_time = parseJSON(video.created_at);
if (!video_time) continue;

if (Math.abs(this.started_at.getTime() - video_time.getTime()) < 1000 * 60 * 5) { // 5 minutes
Expand Down

0 comments on commit 0391332

Please sign in to comment.