Jump to content

Create multi language libraries from your existing libraries


rbjtech

Recommended Posts

rbjtech

edit 30/08/2022

I've updated the script as follows -

- On repeat usage, added Progress Monitor when skipping existing STRM files (rather than thinking it's hung ..)
- Added Summary page of the New Libraries

This also works with TV Series - due to the nature of each episode needing it's own STRM file - it takes a little longer, but works just as well.

-------

I've created a simple script that creates a copy of the structure of an existing emby library (file path).  It then populates this new structure with strm (link) files back to the original video files.

You can then use this library as a new library within emby - and subsequently you can choose the metadata language as you would do as part of the normal setup.   

This means you can get :

  • native language metadata (if it exists)
  • native language artwork (if that exists)
  • subtitle language as required (you can do multi language subs in the core system)

The video file is played from the original library - so there is no need to duplicate the video files.

If required, user permission can be removed from the main library, leaving just this new library to browse in the users native language.

Usage (windows batch file)

Copy the batch file 'libstrm.bat' and 'library.txt' to the emby server in a suitable directory.

Modify the 'library.txt' file to match your system.  In the example file I have -

D:\TV Series\;D:\French TV Series\
D:\Films\;D:\German Films\

Also works with UNC -

\\media\TV Series\;\\media\French TV Series\
\\media\Films\;\\media\German Films\

The first path is the original location, the second path is the new library location (with the strm files).

Note - the path must end with a \ and the entries are separated by a semi-colon.

The 'library.txt' file can contain any number of drives and folders - I suggest testing with a sample to start with.

Run the 'libstrm.bat' file from a command.

Depending on the number of folders/files - it may take a few seconds or more to complete - but it will show progress as it goes.

Once complete - create new emby libraries pointing to the new locations - remembering to set the metadata language as required.

For example :-

french3.PNG.64522d06663d27506913c3198283343e.PNG

 

Once setup and emby has scanned the new folders (it will do this automatically if set to monitor - or a manual scan) - all the relevant metadata will be imported.

As an example - in my test French library :-

french1.thumb.PNG.c2b8b07248bf52d27c5f9139f29417d9.PNG

french2.thumb.PNG.c309beb593a9c0ed15359d04886e41d7.PNG

Note the French metadata, episode names and artwork.

In my test German library :-

german1.PNG.7dd0034a5fac3c40d88997800166c0c7.PNG

german2.thumb.PNG.dfab38f8e991a011b85cf9c07b2275ed.PNG

Again, German metadata & artwork.

Keeping the system updated ...

Because creating the strm files is manual - to add NEW media, the script can just be run again (via the Windows task schedule ever day for example).  If the strm file is already there, it will not recreate it.  However, if media is removed from the original library (remember it links to it, it is not a copy) - then the strm link will unfortunately break.  It can of course just be removed manually by deleting the strm file.   I've added a progress bar to now show when items are skipped (every 100 items gets a # displayed..)

Media Playback ...

The resulting playback will of course be identical to playing the original file (as it IS the original file) but any playback preferences will be remembered for that library.  So if the Audio was set to French with French subtitles, then next time it is played, it will remember those settings.   There may be a way of setting these to a library default in the native language - I have not experimented with this. 

Feedback welcome. :)

(rename the libstrm.bat.txt file to libstrm.bat)

 

library.txtlibstrm.bat.txt

Edited by rbjtech
Updated script
  • Like 4
  • Thanks 2
Link to comment
Share on other sites

videopalace

I have tested this script, it works fine by itself. Only the indication of video resolution and audio language should appear automatically when the library is scanned. Now this information only appears after playing a video (Playing 1 second is sufficient but difficult to set the library correctly for 4000 films).

For the rest TOP script

Link to comment
Share on other sites

Happy2Play
3 hours ago, Privateyes said:

I have tested this script, it works fine by itself. Only the indication of video resolution and audio language should appear automatically when the library is scanned. Now this information only appears after playing a video (Playing 1 second is sufficient but difficult to set the library correctly for 4000 films).

For the rest TOP script

That is do to strm files do not get probed until first playback.  To many cloud users complained.

Link to comment
Share on other sites

videopalace

Isn't there a workaround for examining the original video file (resolution and audio) before playing it?

Edited by Privateyes
Link to comment
Share on other sites

rbjtech

Hmmm - let me look into this.

We should be able to create a .nfo file easily after we create the strm - maybe copy portions of it from the original .nfo if it exists ..

This should (may..) force a scan of that item, correcting/updating the nfo with the missing items.. 

Edited by rbjtech
Link to comment
Share on other sites

rbjtech

@Privateyes Hmm not a lot of luck I'm afraid.

I can create the .nfo file - that is not an issue,  i've tried creating a dummy fileinfo section in the .nfo, even stuffed with fake data  - but it just gets wiped after a metadata refresh - it never gets read.

It must setting something in the database to say the strm is played - as you'll note that as soon as you play the strm, it replaces the Media Info with the real media info - it no longer says its an strm.

@Happy2Play Is this a know issue/limitation ?  Is there a way to force it using the API do you know ?

 

Link to comment
Share on other sites

Happy2Play
3 hours ago, rbjtech said:

Happy2Play Is this a know issue/limitation ?  Is there a way to force it using the API do you know ?

Pretty sure it is by design as all cloud users complained about library scans taking forever.  Where importing a strm file is almost instantaneous with no overhead for the probing every item.

But @Lukewould have to comment on if it possible to force probe these items.

  • Thanks 1
Link to comment
Share on other sites

  • 8 months later...

thanks for the script, it's working well.

i've got another question. is it in possible to filter media libraries by name? I've implemented a direct language switcher on the homepage to switch my system language and it would be nice, to directly navigate into a library selected by the name. (in my case would be the name for the language)

Link to comment
Share on other sites

  • 5 months later...
anthony_m

Great work and very happy to have found this script!

My emby server is a Qnap NAS so not sure where to put these two files as I cannot readily find my emby database on it. Has anybody with a similar setup already used it successfully?

Link to comment
Share on other sites

  • 2 weeks later...
rbjtech
On 10/08/2022 at 11:10, anthony_m said:

Great work and very happy to have found this script!

My emby server is a Qnap NAS so not sure where to put these two files as I cannot readily find my emby database on it. Has anybody with a similar setup already used it successfully?

You can run the windows batch file on any windows machine - so as long as you can access the 'shares' (on the nas) then it works equally as well using UNC names.

In this example library.txt file - I am using the share \\media\Films\ as the source and the share \\media\DownloadTemp\ as the destination.

The French and German folders (libraries) will be created on the share if they don't already exist.

\\media\Films\;\\media\DownloadTemp\French\
\\media\Films\;\\media\DownloadTemp\German\

I just tested this - it works beautifully !

Link to comment
Share on other sites

rbjtech

@chef @Cheesegeezer

'Multi Language Metadata' 

I'd forgotten all about this script I wrote - it's such a simple concept - and works beautifully.  

The only flaw is keeping the STRM files up to date with deletions and new additions, running it again adds items, but deleted items keep the strm file.

I know we are involved with many projects (lol) but do you think this could be put in a Plugin ?

Looking at the number of downloads - it did have a fair amount of interest - but via a Catalogue plugin, it will probably get a lot more.

It should be REALLY easy to do. (famous last words.. haha)

With a plugin, the user would create the new Alternate language library - and then choose the 'source' and 'destination' libraries - and it would simply create and copy strm links from all the existing content to the new library.   It could do this at a file level (as the script does) or do it by referencing the emby db file path.

You just repeat if you want multiple alternate libraries - or you could add multiple destinations (as the script does) 

A 'watch' monitor checks for new or deleted items (as we have done on many plugins) and it removes the strm file.

What do you think ?

I probably should learn how to write Plugin's myself 🤪 - this would be a nice easy one to start with I think ...

Edited by rbjtech
  • Like 3
Link to comment
Share on other sites

  • 1 year later...
rbjtech
24 minutes ago, Dibbes said:

@rbjtechDid you ever figure this out?

You mean the strm file not showing the full metadata until accessed ?

Link to comment
Share on other sites

rbjtech
2 minutes ago, Dibbes said:

Yup

No I didn't pursue it myself - but as Luke alluded to - by simply using a session key to look at the item /sessions/[id]/viewing - you can trick emby into thinking it has visted that item and thus populate the full metadata. 

  • Thanks 1
Link to comment
Share on other sites

TeamB
4 hours ago, rbjtech said:

No I didn't pursue it myself - but as Luke alluded to - by simply using a session key to look at the item /sessions/[id]/viewing - you can trick emby into thinking it has visted that item and thus populate the full metadata. 

I wrote a plugin that triggers a STRM to be probed:

 

  • Like 1
Link to comment
Share on other sites

Dibbes

Feels like I'll be doing some combining of various scripts and plugins then... ScripterX, RBJTech's STRM script and the extract plugin... let's see what that comes back with 🙂

Thanks both, @rbjtechand @TeamB!

  • Like 1
Link to comment
Share on other sites

rbjtech
1 hour ago, Dibbes said:

Feels like I'll be doing some combining of various scripts and plugins then... ScripterX, RBJTech's STRM script and the extract plugin... let's see what that comes back with 🙂

Thanks both, @rbjtechand @TeamB!

Looking forward to it :)

Depending on the timescales for the Smartplaylists - now we have better playlist management and a way to probe strm files, I may also revisit my 'Recommendation' Plugin/Script and convert that into a proper Plugin.    That uses a similiar concept, but simply creates a new strm item in a 'watch/recommended' library created by simply retrieving those items from a suitable named user created playlist (now in the db, don't need to query the xml anymore).

https://emby.media/community/index.php?/topic/99029-personalised-recommendations-library-work-in-progress/#comment-1033255

Edited by rbjtech
  • Like 1
Link to comment
Share on other sites

Dibbes

As I said per PM, @rbjtechI couldn't get your batch script to work... (this says more about me than about your batch script, lol)

Either way, I wrote a PowerShell script doing the same thing, based on your work. It also asks if you'd like to copy any image files and subtitle files, so that Emby does not have to re-download these. You can either put a file called "paths.txt" in the same folder as the script, or, if paths.txt cannot be found, you will be asked to enter a path. Output is on screen and in a log.txt saved in the same folder as the script.

It's scanning recursive and does not distinguishes between movies and series (music was deliberately omitted), so my suggestion is to put the script in the root folder of the library (not the root of the server or root of the volume) you want to create the .strm files from.

Any feedback, give me a shout.

Note: To use with the Scripter-X plugin, you must supply the paths.txt file and comment out the sections for copying the subtitles and images, or it will eternally hang on that question 🙂

strm-library.ps1

Edited by Dibbes
  • Like 1
Link to comment
Share on other sites

rbjtech
10 hours ago, Dibbes said:

As I said per PM, @rbjtechI couldn't get your batch script to work... (this says more about me than about your batch script, lol)

Either way, I wrote a PowerShell script doing the same thing, based on your work. It also asks if you'd like to copy any image files and subtitle files, so that Emby does not have to re-download these. You can either put a file called "paths.txt" in the same folder as the script, or, if paths.txt cannot be found, you will be asked to enter a path. Output is on screen and in a log.txt saved in the same folder as the script.

It's scanning recursive and does not distinguishes between movies and series (music was deliberately omitted), so my suggestion is to put the script in the root folder of the library (not the root of the server or root of the volume) you want to create the .strm files from.

Any feedback, give me a shout.

Note: To use with the Scripter-X plugin, you must supply the paths.txt file and comment out the sections for copying the subtitles and images, or it will eternally hang on that question 🙂

strm-library.ps1 4.04 kB · 3 downloads

Thanks @Dibbes- looking good.

The only observation is that by copying the image files - you may not want to do this as the original idea is to get the image files from the alternative language (if available), they will usually have the name embedded in the artwork for the native language - but copying the subs, good call. :)

 

Edited by rbjtech
Link to comment
Share on other sites

Dibbes
58 minutes ago, rbjtech said:

Thanks @Dibbes- looking good.

The only observation is that by copying the image files - you may not want to do this as the original idea is to get the image files from the alternative language (if available), they will usually have the name embedded in the artwork for the native language - but copying the subs, good call. :)

 

Copying either the subtitles or the images is optional. It will ask you if you'd like to, however, if the subtitles/images are already there, it won't overwrite 🙂

  • Like 1
Link to comment
Share on other sites

Dibbes

I put together something that cleans up the .strm folders as well... saves doing it manually when the video no long exists in the original location.

What it does:
Scans all .strm files recursively in a directory structure, reads the .strm files and checks if the original video file still exist. If the video file does not exist, it will ask if you want to delete the .strm file.

NOTE: If the path is not accessible for any reason (DNS, Access Rights, etc.), the script will ask to delete everything.

StrmFileCleanup.ps1

Edited by Dibbes
  • Like 1
Link to comment
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...