Jump to content
PenkethBoy

Get Extrafanart Directory Back - Windows - Powershell

Recommended Posts

PenkethBoy

(15/09/2020)

If like me you liked the Extrafanart sub directory to store all the downloaded fanartX.jpg files to keep the main item folder clear of clutter then you are in luck.

Context

In a recent beta / nfo plugin update the creation of extrafanart directories was remove (as Kodi does not support them anymore) and now fanartX files are saved to the main folder of an item. So this script allows you to clean up this situation.

The script is setup to work with Movies and Series (TV Shows) only at present and not Mixed content folders either - maybe a future update might cover this but for now only run it against supported structures.

User Notes - (version 1.2) - thanks to @CBers and @FrostByte for proofreading.

AddEFA - script to add extrafanart directory and move the fanartX files to it from the main directory of a newly added item - Movie or Series

1.0     Basic Function

1.1    This script is to add the extrafanart directory back since in the last few beta server versions the support for it was removed when a new Series or Movie is added to Emby.
1.2    It also moves fanartX.jpg files to the extrfanart directory if they exist. 
1.3    The extrafanart directory is not created if no fanartx files exist in the main directory for the item.
1.4    It leaves the fanart.jpg in the main directory of the item.

2.0    Script Requirements

2.1    The script is written in Powershell for version 7.0.3
2.2    The script requires at least Powershell 7.0 - Powershell can be downloaded from https://github.com/PowerShell/PowerShell/releases/tag/v7.0.3 - the latest Release version is 7.0.3 as of 15/09/2020. Remember to set the execution policy you require - Google it if you are not sure. 
2.3    If you try and run it in Powershell 5.1/6/0 etc it will abort and not run as some of the code is PS 7 specific.
2.4    Powershell 7 and 5.1 etc can coexist on the same machine with no issues (Windows)

3.0    Setup Requirements

3.1    I have attached to the first post a zip file (AddEFA.zip) containing 3 files
3.2    AddEFA.ps1 - the main script file, AddEFA_config.ps1 - config file for the main script file (more on this below) and these user notes.
3.3    Also in the zip file is a logs folder which the script will look for to write its log file too. The location of the logs folder can be changed in the _config file.
3.4    Unzip the file to your location of choice - the main folder for the script (AddEFA) can be changed to anything you like. BUT the ps1 files should not have their names modified.
3.5    Open the _config file in any text editor and amend the setting you want and don't forget to save it after you change things!
3.5.1    Log_Path - where you want the logs saved
3.5.2    MovieBaseDir - full paths to one or multiple movie root folders - unc paths are supported - Enclose BaseDir folders in single quotes(') and separate by commas.
3.5.3    SeriesBaseDir - as above - Enclose BaseDir folders in single quotes(') and separate by commas.
3.5.4    Log_Retention - how many days you want to keep the logs for.
3.6    Why a config file - for convenience - you can replace the main ps1 file and not have to keep updating your paths etc if I need to release a new version.
3.6.1    I anticipate that the config file format will not change - with current plans - but if I add some other functionality that requires it you will get a new version etc - and only at that time would you need to edit the config again - other than your own changes.

4.0    Running the script

4.1    First you need to open a PS7 console window - there are various ways to do it - I will just do the one that most will be able to follow.
4.1.1    Start>Powershell>Powershell 7 (x64) will open the console window.
4.1.2    Navigate to the folder where the AddEFA.ps1 and config files exist
4.1.3    To run the script you need to type the following
4.1.4    .\AddEFA -DoMovies -DoSeries     and then hit return - if you have things configured correctly the script will be off to the races.
4.1.5    Notice the full stop before the \ above? It's needed don't forget to type it - otherwise PS will complain!
4.1.6    The -Doxxxx are called parameters and at least one needs to be supplied - i.e. without them the script will do nothing much. You can supply both or singly - up to you.
4.1.7    If you get errors see below.
4.2    The script will write to the console window at the same time as the log - they are essentially the same - so if things fly by and you can't read what's happening - go see the log file.
4.3    When running the script it creates an AddEFA.lock file to the script directory. This is to prevent the script from being run twice or more concurrently - i.e. stopping multiple scripts fighting over files!
4.4    Once the script completes - the lock file is removed.
4.5    Once complete then your Movies/Series should have been updated where necessary - see log file for details of which was amended or not and why.
4.6    Beyond the scope of these notes but it's easy to schedule this script to run via task scheduler or the Emby ScripterX Plugin for say every couple of days - depending how much on average you add to your server.

5.0    Limitations / Restrictions

5.1    The BaseDir's you give the script, in the config file, need to have a structure which needs to be followed - see below.
5.2    MovieBaseDir\<movie individual main directory> - for me that would be M:\Movies\22 Bullets (2010) or M:\Movies\300 (2007) etc where M:\movies is the BaseDir
5.3    SeriesBaseDir\<Show individual main directory> - for me that would be M:\TV\Babylon 5 or M:\Movies\Catch-22 etc where M:\TV is the BaseDir
5.4    If you have any movies which are not in their own directories within the MovieBaseDir - put them in separate folders - or don't run the script if this is an issue
5.5    Equally the same basic structure is expected for Series - i.e. nothing not in a folder within the baseDir for Series - i.e. no loose episodes etc
5.6    If you say have your movies in Alphabetical groups say \movies\A-H, \movies\I-R etc then add those as the baseDir in the config as you can have more than one. Each of these directories will be processed one after the other.
5.6    Any other eclectic folder structure and you are on your own! Results might be weird!
5.7    The config file must be in same folder as the main script.

6.0    Errors you might see

6.1    These are common errors due to incorrect config/ finger trouble
6.2    You forget the full stop before the \
6.3    You spell the parameters wrong
6.4    A lock file exists in the script folder - either another instance of the script is running or shock horror the script crashed last time - this never happens ... :) 
6.5    The baseDir paths you have given are invalid/not accessible
6.6    The log_path is invalid/not accessible
etc - not going to try and cover everything under the sun!
6.7    Either PS or the script will indicate what is wrong for most of the common errors - read what they say and you should be able to figure it out.

7.0    Summary
7.1    The script has been tested by myself and @cbers/@frostbyte and if they can get it to work so should you :) 
7.2    If PS is new to you then you have a smallish learning curve to climb but its not huge - Google can help here.

Example Screenshots

428085227_Annotation2020-09-15134418.jpg.ab206b46b5f2b757d57cb793d3a15833.jpg

Fig1 - about to run script - note PS has its current directory - pointing at the script directory Point 4.1.2 above

2083231874_Annotation2020-09-15134513.jpg.308e3b6abc8d8f085dc304d3b3252aa6.jpg

Fig 2 - Script Running against my TV library

155912948_Annotation2020-09-15134539.jpg.1d61df7a6135a29ab06c80f643798ce8.jpg

Fig 3 - Script has finished in just over 3 seconds. Its not amended anything as no new TV shows added recently.

Files - AddEFA.zip - as decribed in 3.1 above.

AddEFA.zip

I will try and respond to queries/issue with the script when i can - i here most days so should respond quickly.

What i'm not going to do in this thread is answer PS issues other than directly related to this script. But i will if they are posted elsewhere if i can answer them.

I want to keep this thread on track and not wander off on some winding road to nowhere :) 


Think That's It :) 

Have Fun

PenkethBoy

 

 

  • Like 3

Share this post


Link to post
Share on other sites
PenkethBoy

reserved

 

Share this post


Link to post
Share on other sites
PenkethBoy

reserved

Share this post


Link to post
Share on other sites
PenkethBoy

reserved

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×
×
  • Create New...