Update PyPyDance parsing

This commit is contained in:
Natsumi
2021-11-04 21:01:13 +13:00
parent f8c9442d2d
commit 7a20804b7a

View File

@@ -7586,12 +7586,11 @@ speechSynthesis.getVoices();
await database.initTables();
await this.resetGameLog();
var location = '';
var pushToTable = false;
for (var gameLog of await gameLogService.getAll()) {
if (gameLog.type === 'location') {
location = gameLog.location;
}
this.addGameLogEntry(gameLog, location, pushToTable);
this.addGameLogEntry(gameLog, location);
}
this.getGameLogTable();
};
@@ -7610,12 +7609,11 @@ speechSynthesis.getVoices();
setTimeout(resolve, 10000);
});
var location = '';
var pushToTable = true;
for (var gameLog of await gameLogService.getAll()) {
if (gameLog.type === 'location') {
location = gameLog.location;
}
this.addGameLogEntry(gameLog, location, pushToTable);
this.addGameLogEntry(gameLog, location);
}
};
@@ -7626,14 +7624,13 @@ speechSynthesis.getVoices();
rawLogs[2],
rawLogs.slice(3)
);
var pushToTable = true;
this.addGameLogEntry(gameLog, this.lastLocation.location, pushToTable);
this.addGameLogEntry(gameLog, this.lastLocation.location);
};
$app.data.lastLocationDestination = '';
$app.data.lastLocationDestinationTime = 0;
$app.methods.addGameLogEntry = function (gameLog, location, pushToTable) {
$app.methods.addGameLogEntry = function (gameLog, location) {
var userId = '';
if (gameLog.userDisplayName) {
for (var ref of API.cachedUsers.values()) {
@@ -7747,7 +7744,7 @@ speechSynthesis.getVoices();
database.addGamelogPortalSpawnToDatabase(entry);
break;
case 'video-play':
this.addGameLogVideo(gameLog, location, userId, pushToTable);
this.addGameLogVideo(gameLog, location, userId);
return;
case 'api-request':
var bias = Date.parse(gameLog.dt) + 60 * 1000;
@@ -7775,7 +7772,7 @@ speechSynthesis.getVoices();
// VideoPlay(PyPyDance) "https://jd.pypy.moe/api/v1/videos/jr1NX4Jo8GE.mp4",0.1001,239.606,"0905 : [J-POP] 【まなこ】金曜日のおはよう 踊ってみた (vernities)"
var type = gameLog.data.substr(0, gameLog.data.indexOf(' '));
if (type === 'VideoPlay(PyPyDance)') {
this.addGameLogPyPyDance(gameLog, location, pushToTable);
this.addGameLogPyPyDance(gameLog, location);
}
return;
case 'notification':
@@ -7794,18 +7791,13 @@ speechSynthesis.getVoices();
database.addGamelogEventToDatabase(entry);
break;
}
if (pushToTable && entry) {
if (entry) {
this.queueGameLogNoty(entry);
this.addGameLog(entry);
}
};
$app.methods.addGameLogVideo = async function (
gameLog,
location,
userId,
pushToTable
) {
$app.methods.addGameLogVideo = async function (gameLog, location, userId) {
var videoUrl = gameLog.videoUrl;
var youtubeVideoId = '';
var videoId = '';
@@ -7860,20 +7852,11 @@ speechSynthesis.getVoices();
userId,
videoPos
};
if (pushToTable) {
this.setNowPlaying(entry);
this.queueGameLogNoty(entry);
this.addGameLog(entry);
}
database.addGamelogVideoPlayToDatabase(entry);
this.setNowPlaying(entry);
}
};
$app.methods.addGameLogPyPyDance = function (
gameLog,
location,
pushToTable
) {
$app.methods.addGameLogPyPyDance = function (gameLog, location) {
var data =
/VideoPlay\(PyPyDance\) "(.+?)",([\d.]+),([\d.]+),"(.+?)\s*(?:)?"/g.exec(
gameLog.data
@@ -7905,6 +7888,16 @@ speechSynthesis.getVoices();
}
}
}
if (videoUrl === this.nowPlaying.url) {
var entry = {
created_at: gameLog.dt,
videoUrl,
videoLength,
videoPos
};
this.setNowPlaying(entry);
return;
}
if (videoId === 'YouTube') {
var entry = {
dt: gameLog.dt,
@@ -7913,7 +7906,7 @@ speechSynthesis.getVoices();
videoPos,
videoId
};
this.addGameLogVideo(entry, location, userId, pushToTable);
this.addGameLogVideo(entry, location, userId);
} else {
var entry = {
created_at: gameLog.dt,
@@ -7927,12 +7920,7 @@ speechSynthesis.getVoices();
userId,
videoPos
};
if (pushToTable) {
this.setNowPlaying(entry);
this.queueGameLogNoty(entry);
this.addGameLog(entry);
}
database.addGamelogVideoPlayToDatabase(entry);
this.setNowPlaying(entry);
}
};
@@ -7989,21 +7977,37 @@ speechSynthesis.getVoices();
};
$app.methods.setNowPlaying = function (ctx) {
var displayName = '';
if (ctx.displayName) {
displayName = ` (${ctx.displayName})`;
if (this.nowPlaying.url !== ctx.videoUrl) {
this.queueGameLogNoty(ctx);
this.addGameLog(ctx);
database.addGamelogVideoPlayToDatabase(ctx);
var displayName = '';
if (ctx.displayName) {
displayName = ` (${ctx.displayName})`;
}
var name = `${ctx.videoName}${displayName}`;
this.nowPlaying = {
url: ctx.videoUrl,
name,
length: ctx.videoLength,
startTime: Date.parse(ctx.created_at) / 1000 - ctx.videoPos,
elapsed: 0,
percentage: 0,
remainingText: ''
};
} else {
this.nowPlaying = {
...this.nowPlaying,
length: ctx.videoLength,
startTime: Date.parse(ctx.created_at) / 1000 - ctx.videoPos,
elapsed: 0,
percentage: 0,
remainingText: ''
};
}
var name = `${ctx.videoName}${displayName}`;
this.nowPlaying = {
url: ctx.videoUrl,
name,
length: ctx.videoLength,
startTime: Date.parse(ctx.created_at) / 1000 - ctx.videoPos,
elapsed: 0,
percentage: 0,
remainingText: ''
};
if (!this.nowPlaying.playing) {
this.updateVrNowPlaying();
if (!this.nowPlaying.playing && ctx.videoLength > 0) {
this.nowPlaying.playing = true;
this.updateNowPlaying();
}
@@ -8011,7 +8015,7 @@ speechSynthesis.getVoices();
$app.methods.updateNowPlaying = function () {
var np = this.nowPlaying;
if (!np.url) {
if (!this.nowPlaying.playing) {
this.nowPlaying.playing = false;
return;
}
@@ -8201,8 +8205,10 @@ speechSynthesis.getVoices();
appId = '846232616054030376';
bigIcon = 'vr_dancing';
}
if (this.nowPlaying.playing) {
if (this.nowPlaying.name) {
L.worldName = this.nowPlaying.name;
}
if (this.nowPlaying.playing) {
Discord.SetTimestamps(
Date.now(),
(this.nowPlaying.startTime + this.nowPlaying.length) * 1000