This commit is contained in:
UKDTOM 2021-05-05 02:01:37 +02:00
parent af129f1de5
commit c15e12e7d2
2 changed files with 72 additions and 89 deletions

View file

@ -53,7 +53,7 @@
v-model="selLibrary" v-model="selLibrary"
id="selLibrary" id="selLibrary"
:options="selLibraryOptions" :options="selLibraryOptions"
@change="selLibraryChanged" @change="selLibraryChanged($event, selLibrary)"
name="selLibrary"> name="selLibrary">
</b-form-select> </b-form-select>
</b-form-group> </b-form-group>
@ -175,26 +175,32 @@
await this.getPMSSections(); await this.getPMSSections();
this.selLibraryWait = true; this.selLibraryWait = true;
}, },
/*
selLibrary: async function(){ selLibrary: async function(){
this.$store.commit("UPDATE_SELECTEDSECTION", this.selLibrary); this.$store.commit("UPDATE_SELECTEDSECTION", this.selLibrary);
}, },
*/
selMediaType: async function(){ selMediaType: async function(){
this.$store.commit("UPDATE_SELECTEDLIBTYPE", this.selMediaType); // this.$store.commit("UPDATE_SELECTEDLIBTYPE", this.selMediaType);
this.selLevel = ""; this.selLevel = "";
this.selLibrary = ""; this.selLibrary = "";
}, },
/*
selExpTypeSec: async function(){ selExpTypeSec: async function(){
this.$store.commit("UPDATE_SELECTEDLIBTYPESEC", this.selExpTypeSec); this.$store.commit("UPDATE_SELECTEDLIBTYPESEC", this.selExpTypeSec);
}, },
selLevel: async function(){ selLevel: async function(){
this.$store.commit("UPDATE_EXPORTLEVEL", this.selLevel); this.$store.commit("UPDATE_EXPORTLEVEL", this.selLevel);
}, },
*/
selectedServerAddressUpdateInProgress: async function(){ selectedServerAddressUpdateInProgress: async function(){
this.selLibraryWait = false; this.selLibraryWait = false;
}, },
/*
selPType: async function(){ selPType: async function(){
this.$store.commit("UPDATE_SELECTEDPLISTTYPE", this.selPType); this.$store.commit("UPDATE_SELECTEDPLISTTYPE", this.selPType);
} }
*/
}, },
created() { created() {
log.info("ET Created"); log.info("ET Created");
@ -209,12 +215,12 @@
} }
else if ( this.selExpTypeSec == et.ETmediaType.Libraries) else if ( this.selExpTypeSec == et.ETmediaType.Libraries)
{ {
this.$store.commit("UPDATE_EXPORTLEVEL", 'all'); //this.$store.commit("UPDATE_EXPORTLEVEL", 'all');
return false; return false;
} }
else if (this.selExpTypeSec == et.ETmediaType.Playlists) else if (this.selExpTypeSec == et.ETmediaType.Playlists)
{ {
this.$store.commit("UPDATE_EXPORTLEVEL", 'all'); //this.$store.commit("UPDATE_EXPORTLEVEL", 'all');
return false; return false;
} }
else else
@ -339,9 +345,12 @@
} }
log.verbose(`Sections to select among are: ${JSON.stringify(this.selLibraryOptions)}`); log.verbose(`Sections to select among are: ${JSON.stringify(this.selLibraryOptions)}`);
}, },
selLibraryChanged: async function(){ selLibraryChanged: async function(value, name){
log.verbose(`Library key to export selected as: ${arguments[0]}`);
console.log('Ged 5566', value, name)
log.verbose(`Library key to export selected as: ${arguments[0]}`);
et.expSettings.selLibKey = this.selLibrary;
}, },
selExpTypeSecChanged: async function(){ selExpTypeSecChanged: async function(){
@ -444,7 +453,7 @@
} }
this.selLibraryOptions = result; this.selLibraryOptions = result;
}, },
getMedia() { async getMedia() {
log.info("getMedia Called"); log.info("getMedia Called");
if (wtconfig.get('General.ExportPath', "") == "") if (wtconfig.get('General.ExportPath', "") == "")
{ {
@ -458,11 +467,20 @@
}) })
return return
} }
this.$store.commit("UPDATE_EXPORTLEVEL", this.selLevel);
this.$store.commit("UPDATE_SELECTEDSECTION", this.selLibrary);
this.$store.commit("UPDATE_EXPORTSTATUS", i18n.t("Modules.ET.Status.StartExport")); this.$store.commit("UPDATE_EXPORTSTATUS", i18n.t("Modules.ET.Status.StartExport"));
et.exportMedias(); console.log('Ged before export')
//this.$store.dispatch("exportMedias");
// Populate et. settings with the selected values
et.expSettings.baseURL = this.$store.getters.getSelectedServerAddress;
et.expSettings.accessToken = this.$store.getters.getSelectedServerToken;
et.expSettings.libType = this.selMediaType;
et.expSettings.libTypeSec = this.selExpTypeSec;
et.expSettings.exportLevel = this.selLevel;
//et.expSettings.selLibKey = this.selLibrary;
await et.exportMedias();
console.log('Ged after export')
}, },
async checkSrvSelected() { async checkSrvSelected() {
log.debug("checkSrvSelected started"); log.debug("checkSrvSelected started");

View file

@ -70,7 +70,7 @@ const et = new class ET {
2003: 'Photo', 2003: 'Photo',
3001: 'Playlists' 3001: 'Playlists'
}, },
this.selSecOption ={ this.selSecOption = {
1: [ 1: [
{ {
"text": i18n.t('Modules.ET.optExpType.SecMovies'), "text": i18n.t('Modules.ET.optExpType.SecMovies'),
@ -131,55 +131,48 @@ const et = new class ET {
"value": this.ETmediaType.Libraries "value": this.ETmediaType.Libraries
} }
] ]
},
this.expSettings = {
baseURL: '',
accessToken: '',
libType: '',
libTypeSec: '',
exportLevel: '',
selLibKey: '',
levelName: '',
libName: ''
} }
} }
async exportMedias() { async exportMedias() {
var baseURL = store.getters.getSelectedServerAddress; this.expSettings.libName = et.getLibDisplayName(this.expSettings.selLibKey, store.getters.getPmsSections);
var accessToken = store.getters.getSelectedServerToken; if ([ et.ETmediaType.Libraries, et.ETmediaType.Playlists].indexOf(this.expSettings.libType) > -1)
var libType = store.getters.getLibType;
var pListType = store.getters.getSelectedLibTypeSec;
console.log('Ged 1', baseURL)
console.log('Ged 2', accessToken)
console.log('Ged 3', libType)
console.log('Ged 4', pListType)
let levelName;
var libName = et.getLibDisplayName(store.getters.getSelectedSection, store.getters.getPmsSections);
if ([ et.ETmediaType.Libraries, et.ETmediaType.Playlists].indexOf(libType) > -1)
{ {
levelName = 'All' this.expSettings.levelName = 'All'
} }
else else
{ {
levelName = et.getLevelDisplayName(store.getters.getSelectedExportLevel, libType); this.expSettings.levelName = et.getLevelDisplayName(this.expSettings.exportLevel, this.expSettings.libType);
} }
console.log('Ged 7', levelName) await excel2.createOutFile( {
libName: this.expSettings.libName,
level: this.expSettings.levelName,
excel2.createOutFile( { libType: this.expSettings.libType,
libName: libName, baseURL: this.expSettings.baseURL,
level: levelName, accessToken: this.expSettings.accessToken,
libType: libType, exType: this.expSettings.libType,
baseURL: baseURL, pListType: this.expSettings.libTypeSec,
accessToken: accessToken, libTypeSec: this.expSettings.libTypeSec
exType: libType,
pListType: pListType,
libTypeSec: store.getSelectedLibTypeSec
} ); } );
} }
async getSectionData({sectionName, baseURL, accessToken, libType, libTypeSec}) async getSectionData()
{ {
const sectionData = [] const sectionData = []
// Find LibType steps // Find LibType steps
const step = wtconfig.get("PMS.ContainerSize." + libType, 20) const step = wtconfig.get("PMS.ContainerSize." + this.expSettings.libType, 20)
log.debug(`Got Step size as: ${step}`) log.debug(`Got Step size as: ${step}`)
let libKey, element let element
// Get Section Key
libKey = await et.getSectionKey({libName: sectionName, baseURL: baseURL, accessToken: accessToken})
log.debug(`Got SectionKey as: ${libKey}`)
// Now read the fields and level defs // Now read the fields and level defs
// Current item // Current item
let idx = 0 let idx = 0
@ -187,33 +180,34 @@ const et = new class ET {
let chuncks, postURI let chuncks, postURI
let size let size
do { do {
if (libType == et.ETmediaType.Photo) if (this.expSettings.libType == et.ETmediaType.Photo)
{ {
element = '/library/sections/' + libKey + '/all'; element = '/library/sections/' + this.expSettings.selLibKey + '/all';
postURI = `?addedAt>>=-2208992400&X-Plex-Container-Start=${idx}&X-Plex-Container-Size=${step}&type=${libTypeSec}&${this.uriParams}`; postURI = `?addedAt>>=-2208992400&X-Plex-Container-Start=${idx}&X-Plex-Container-Size=${step}&type=${this.expSettings.libTypeSec}&${this.uriParams}`;
} }
else if (libType == et.ETmediaType.Playlist) else if (this.expSettings.libType == et.ETmediaType.Playlist)
{ {
element = '/playlists/' + libKey; element = '/playlists/' + this.expSettings.selLibKey;
postURI = `/items?X-Plex-Container-Start=${idx}&X-Plex-Container-Size=${step}`; postURI = `/items?X-Plex-Container-Start=${idx}&X-Plex-Container-Size=${step}`;
} }
else if (libType == et.ETmediaType.Libraries) else if (this.expSettings.libType == et.ETmediaType.Libraries)
{ {
element = '/library/sections/all'; element = '/library/sections/all';
postURI = `?X-Plex-Container-Start=${idx}&X-Plex-Container-Size=${step}`; postURI = `?X-Plex-Container-Start=${idx}&X-Plex-Container-Size=${step}`;
} }
else if (libType == et.ETmediaType.Playlists) else if (this.expSettings.libType == et.ETmediaType.Playlists)
{ {
element = '/playlists/all'; element = '/playlists/all';
postURI = `?X-Plex-Container-Start=${idx}&X-Plex-Container-Size=${step}`; postURI = `?X-Plex-Container-Start=${idx}&X-Plex-Container-Size=${step}`;
} }
else else
{ {
element = '/library/sections/' + libKey + '/all'; element = '/library/sections/' + this.expSettings.selLibKey + '/all';
postURI = `?X-Plex-Container-Start=${idx}&X-Plex-Container-Size=${step}&type=${libTypeSec}&${this.uriParams}`; postURI = `?X-Plex-Container-Start=${idx}&X-Plex-Container-Size=${step}&type=${this.expSettings.libTypeSec}&${this.uriParams}`;
} }
log.info(`Calling getSectionData url ${baseURL + element + postURI}`);
chuncks = await et.getItemData({baseURL: baseURL, accessToken: accessToken, element: element, postURI: postURI}); log.info(`Calling getSectionData url ${this.expSettings.baseURL + element + postURI}`);
chuncks = await et.getItemData({baseURL: this.expSettings.baseURL, accessToken: this.expSettings.accessToken, element: element, postURI: postURI});
size = JSONPath({path: '$.MediaContainer.size', json: chuncks}); size = JSONPath({path: '$.MediaContainer.size', json: chuncks});
const totalSize = JSONPath({path: '$.MediaContainer.totalSize', json: chuncks}); const totalSize = JSONPath({path: '$.MediaContainer.totalSize', json: chuncks});
log.info(`getSectionData chunck size is ${size} and idx is ${idx} and totalsize is ${totalSize}`) log.info(`getSectionData chunck size is ${size} and idx is ${idx} and totalsize is ${totalSize}`)
@ -227,34 +221,6 @@ const et = new class ET {
return sectionData; return sectionData;
} }
async getSectionSizeByKey({sectionKey, baseURL, accessToken, libType})
{
let sizeURI, sizePostURI, sizeContents;
if (libType == 'playlist')
{
sizeURI = '/playlists/' + sectionKey
sizePostURI = '/items?X-Plex-Container-Start=0&X-Plex-Container-Size=0'
}
else
{
sizeURI = '/library/sections/' + sectionKey
sizePostURI = '/all?X-Plex-Container-Start=0&X-Plex-Container-Size=0'
}
sizeContents = await et.getItemData({baseURL: baseURL, accessToken: accessToken, element: sizeURI, postURI: sizePostURI});
const size = await JSONPath({path: '$..totalSize', json: sizeContents});
return size
}
async getSectionSizeByName({sectionName, baseURL, accessToken})
{
const libKey = await et.getSectionKey({libName: sectionName, baseURL: baseURL, accessToken: accessToken})
const sizeURI = '/library/sections/' + libKey
const sizePostURI = '/all?X-Plex-Container-Start=0&X-Plex-Container-Size=0'
const sizeContents = await et.getItemData({baseURL: baseURL, accessToken: accessToken, element: sizeURI, postURI: sizePostURI});
const size = await JSONPath({path: '$..totalSize', json: sizeContents});
return size
}
async getItemData({baseURL, accessToken, element, postURI=defpostURI}) async getItemData({baseURL, accessToken, element, postURI=defpostURI})
{ {
const url = baseURL + element + postURI; const url = baseURL + element + postURI;
@ -535,7 +501,6 @@ const et = new class ET {
return defFields['fields'][fieldName]['subtype']; return defFields['fields'][fieldName]['subtype'];
} }
getFieldsKeyVal( libType, level) { getFieldsKeyVal( libType, level) {
// Get fields for level // Get fields for level
let fields let fields
@ -1349,7 +1314,7 @@ const excel2 = new class Excel {
}); });
} }
async createOutFile( {libName, level, libType, baseURL, accessToken, exType, pListType, libTypeSec} ) async createOutFile( {libName, level, libType, baseURL, accessToken, exType, pListType} )
{ {
const header = excel2.GetHeader(level, libType, pListType); const header = excel2.GetHeader(level, libType, pListType);
log.debug(`header: ${header}`); log.debug(`header: ${header}`);
@ -1365,7 +1330,7 @@ const excel2 = new class Excel {
var sectionData, x; var sectionData, x;
{ {
// Get all the items in small chuncks // Get all the items in small chuncks
sectionData = await et.getSectionData({sectionName: libName, baseURL: baseURL, accessToken: accessToken, libType: libType, libTypeSec: libTypeSec}); sectionData = await et.getSectionData();
log.verbose(`Amount of chunks in sectionData are: ${sectionData.length}`); log.verbose(`Amount of chunks in sectionData are: ${sectionData.length}`);
let item; let item;
let counter = 1; let counter = 1;
@ -1451,4 +1416,4 @@ const excel2 = new class Excel {
} }
} }
export {et, excel2}; export { et, excel2 };