mirror of
https://github.com/movie-web/movie-web.git
synced 2024-12-29 17:46:05 +00:00
Begin data migration
This commit is contained in:
parent
8419956b7b
commit
95f623922a
|
@ -32,6 +32,20 @@ version 0
|
|||
}
|
||||
*/
|
||||
|
||||
/*
|
||||
item = {
|
||||
mediaId: media.mediaId,
|
||||
mediaType: media.mediaType,
|
||||
providerId: media.providerId,
|
||||
title: media.title,
|
||||
year: media.year,
|
||||
percentage: 0,
|
||||
progress: 0,
|
||||
episodeId: media.episodeId,
|
||||
seasonId: media.seasonId,
|
||||
};
|
||||
*/
|
||||
|
||||
export const VideoProgressStore = versionedStoreBuilder()
|
||||
.setKey("video-progress")
|
||||
.addVersion({
|
||||
|
@ -40,7 +54,47 @@ export const VideoProgressStore = versionedStoreBuilder()
|
|||
.addVersion({
|
||||
version: 1,
|
||||
migrate(data: any) {
|
||||
// TODO migration
|
||||
const output: any = { items: [] as any };
|
||||
|
||||
Object.keys(data).forEach((scraperId) => {
|
||||
if (scraperId === "--version") return;
|
||||
if (scraperId === "save") return;
|
||||
|
||||
if (data[scraperId].movie) {
|
||||
Object.keys(data[scraperId].movie).forEach((movieId) => {
|
||||
output.items.push({
|
||||
mediaId: movieId.includes("player.php") ? movieId.split("player.php%3Fimdb%3D")[1] : movieId,
|
||||
mediaType: "movie",
|
||||
providerId: scraperId,
|
||||
title: data[scraperId].movie[movieId].full.meta.title,
|
||||
year: data[scraperId].movie[movieId].full.meta.year,
|
||||
progress: data[scraperId].movie[movieId].full.currentlyAt,
|
||||
percentage: Math.round((data[scraperId].movie[movieId].full.currentlyAt / data[scraperId].movie[movieId].full.totalDuration) * 100)
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
if (data[scraperId].show) {
|
||||
Object.keys(data[scraperId].show).forEach((showId) => {
|
||||
Object.keys(data[scraperId].show[showId]).forEach((episodeId) => {
|
||||
output.items.push({
|
||||
mediaId: showId,
|
||||
mediaType: "series",
|
||||
providerId: scraperId,
|
||||
title: data[scraperId].show[showId][episodeId].meta.title,
|
||||
year: data[scraperId].show[showId][episodeId].meta.year,
|
||||
percentage: Math.round((data[scraperId].show[showId][episodeId].currentlyAt / data[scraperId].show[showId][episodeId].totalDuration) * 100),
|
||||
progress: data[scraperId].show[showId][episodeId].currentlyAt,
|
||||
episodeId: data[scraperId].show[showId][episodeId].show.episode,
|
||||
seasonId: data[scraperId].show[showId][episodeId].show.season,
|
||||
});
|
||||
});
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
console.log(output);
|
||||
return output;
|
||||
},
|
||||
create() {
|
||||
return {
|
||||
|
|
Loading…
Reference in a new issue