|
|
|
@ -1,50 +1,6 @@
@@ -1,50 +1,6 @@
|
|
|
|
|
import { MWMediaType } from "providers"; |
|
|
|
|
import { versionedStoreBuilder } from "utils/storage"; |
|
|
|
|
|
|
|
|
|
/* |
|
|
|
|
version 0 |
|
|
|
|
{ |
|
|
|
|
[{scraperid}]: { |
|
|
|
|
movie: { |
|
|
|
|
[{movie-id}]: { |
|
|
|
|
full: { |
|
|
|
|
currentlyAt: number, |
|
|
|
|
totalDuration: number, |
|
|
|
|
updatedAt: number, // unix timestamp in ms
|
|
|
|
|
meta: FullMetaObject, // no idea whats in here
|
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
}, |
|
|
|
|
show: { |
|
|
|
|
[{show-id}]: { |
|
|
|
|
[{season}-{episode}]: { |
|
|
|
|
currentlyAt: number, |
|
|
|
|
totalDuration: number, |
|
|
|
|
updatedAt: number, // unix timestamp in ms
|
|
|
|
|
show: { |
|
|
|
|
episode: string, |
|
|
|
|
season: string, |
|
|
|
|
}, |
|
|
|
|
meta: FullMetaObject, // no idea whats in here
|
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
*/ |
|
|
|
|
|
|
|
|
|
/* |
|
|
|
|
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, |
|
|
|
|
}; |
|
|
|
|
*/ |
|
|
|
|
import { WatchedStoreData } from "./context"; |
|
|
|
|
|
|
|
|
|
export const VideoProgressStore = versionedStoreBuilder() |
|
|
|
|
.setKey("video-progress") |
|
|
|
@ -54,32 +10,42 @@ export const VideoProgressStore = versionedStoreBuilder()
@@ -54,32 +10,42 @@ export const VideoProgressStore = versionedStoreBuilder()
|
|
|
|
|
.addVersion({ |
|
|
|
|
version: 1, |
|
|
|
|
migrate(data: any) { |
|
|
|
|
const output: any = { items: [] as any }; |
|
|
|
|
const output: WatchedStoreData = { items: [] }; |
|
|
|
|
|
|
|
|
|
if (!data || data.constructor !== Object) |
|
|
|
|
return output; |
|
|
|
|
|
|
|
|
|
Object.keys(data).forEach((scraperId) => { |
|
|
|
|
if (scraperId === "--version") return; |
|
|
|
|
if (scraperId === "save") return; |
|
|
|
|
|
|
|
|
|
if (data[scraperId].movie) { |
|
|
|
|
if (data[scraperId].movie && data[scraperId].movie.constructor === Object) { |
|
|
|
|
Object.keys(data[scraperId].movie).forEach((movieId) => { |
|
|
|
|
try { |
|
|
|
|
output.items.push({ |
|
|
|
|
mediaId: movieId.includes("player.php") ? movieId.split("player.php%3Fimdb%3D")[1] : movieId, |
|
|
|
|
mediaType: "movie", |
|
|
|
|
mediaType: MWMediaType.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) |
|
|
|
|
}); |
|
|
|
|
} catch (err) { |
|
|
|
|
console.error(`Failed to migrate movie: ${scraperId}/${movieId}`, data[scraperId].movie[movieId]); |
|
|
|
|
} |
|
|
|
|
}); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
if (data[scraperId].show) { |
|
|
|
|
if (data[scraperId].show && data[scraperId].show.constructor === Object) { |
|
|
|
|
Object.keys(data[scraperId].show).forEach((showId) => { |
|
|
|
|
if (data[scraperId].show[showId].constructor !== Object) |
|
|
|
|
return; |
|
|
|
|
Object.keys(data[scraperId].show[showId]).forEach((episodeId) => { |
|
|
|
|
try { |
|
|
|
|
output.items.push({ |
|
|
|
|
mediaId: showId, |
|
|
|
|
mediaType: "series", |
|
|
|
|
mediaType: MWMediaType.SERIES, |
|
|
|
|
providerId: scraperId, |
|
|
|
|
title: data[scraperId].show[showId][episodeId].meta.title, |
|
|
|
|
year: data[scraperId].show[showId][episodeId].meta.year, |
|
|
|
@ -88,12 +54,14 @@ export const VideoProgressStore = versionedStoreBuilder()
@@ -88,12 +54,14 @@ export const VideoProgressStore = versionedStoreBuilder()
|
|
|
|
|
episodeId: data[scraperId].show[showId][episodeId].show.episode, |
|
|
|
|
seasonId: data[scraperId].show[showId][episodeId].show.season, |
|
|
|
|
}); |
|
|
|
|
} catch (err) { |
|
|
|
|
console.error(`Failed to migrate series: ${scraperId}/${showId}/${episodeId}`, data[scraperId].show[showId][episodeId]); |
|
|
|
|
} |
|
|
|
|
}); |
|
|
|
|
}); |
|
|
|
|
} |
|
|
|
|
}); |
|
|
|
|
|
|
|
|
|
console.log(output); |
|
|
|
|
return output; |
|
|
|
|
}, |
|
|
|
|
create() { |
|
|
|
|