Jump to content

Transfer tags from Radarr to Emby


Go to solution Solved by Neminem,

Recommended Posts

mannyrothman
Posted

Movies are tagged in Radarr with who requested them via Overseerr. For example, if I requested a movie, the movie will be tagged with “1 - manny” in Radarr. Is there any way to have those same movies tagged with “1 - manny” in Emby?

Happy2Play
Posted

I would assume you have to have Radarr write nfo files.

But might create other issues.

 

mannyrothman
Posted
6 minutes ago, Happy2Play said:

I would assume you have to have Radarr write nfo files.

But might create other issues.

 

I see. How can I have Radarr generate an nfo file that includes it's tag for each movie?

Happy2Play
Posted

A fellow user will have to comment as I don't use any of the *arrs.  I wouldn't think it would be that hard to test.

  • Solution
Neminem
Posted
4 hours ago, mannyrothman said:

Is there any way to have those same movies tagged with “1 - manny” in Emby?

Not sure if this is needed, You should see tags here.
Never used Radarr tags.
image.thumb.png.ff4faa346adad2af48bd77488502a445.png

But enabling this in Radarr will write the nfo file.

image.thumb.png.659143ce1301c723e33adf0691453f58.png

mannyrothman
Posted
30 minutes ago, jaycedk said:

Not sure if this is needed, You should see tags here.
Never used Radarr tags.
image.thumb.png.ff4faa346adad2af48bd77488502a445.png

But enabling this in Radarr will write the nfo file.

image.thumb.png.659143ce1301c723e33adf0691453f58.png

This is perfect! I’ll enable this. Thank you!

  • 7 months later...
Posted
On 6/25/2024 at 11:57 AM, mannyrothman said:

This is perfect! I’ll enable this. Thank you!

Have you tried? Are they compatible?

Happy2Play
Posted (edited)

One would have to post a *arrs nfo file showing an example of them not working to potentially check compatibility.  But it is a pretty simple field.

  <tag>3d</tag>
  <tag>alien</tag>
  <tag>alien planet</tag>
  <tag>anti war</tag>
  <tag>battle</tag>
  <tag>culture clash</tag>
  <tag>future</tag>
  <tag>futuristic</tag>
  <tag>love affair</tag>
  <tag>marine</tag>
  <tag>mind and soul</tag>
  <tag>power relations</tag>
  <tag>romance</tag>
  <tag>society</tag>
  <tag>soldier</tag>
  <tag>space</tag>
  <tag>space colony</tag>
  <tag>space travel</tag>
  <tag>space war</tag>
  <tag>tribe</tag>

I believe nested also

	<Tags>
		<Tag>culture clash</Tag>
		<Tag>future</Tag>
		<Tag>space war</Tag>
		<Tag>space colony</Tag>
		<Tag>society</Tag>
		<Tag>space travel</Tag>
		<Tag>futuristic</Tag>
		<Tag>romance</Tag>
		<Tag>space</Tag>
		<Tag>alien</Tag>
		<Tag>tribe</Tag>
		<Tag>alien planet</Tag>
		<Tag>marine</Tag>
		<Tag>soldier</Tag>
		<Tag>battle</Tag>
		<Tag>love affair</Tag>
		<Tag>anti war</Tag>
		<Tag>power relations</Tag>
		<Tag>mind and soul</Tag>
		<Tag>3d</Tag>
	</Tags>

 

But think the bigger issues is how ofton the *arrs touch the nfo files causing Emby to reread.

Edited by Happy2Play
  • 1 year later...
embylad892746
Posted (edited)

Hi guys, abit late here.

I have a reliable but slightly crude method of updating my radarr/sonarr tags to emby.

basically it works like this:
- query radarr/sonarr for list of tags
- go the movie/tv show location
- for radarr tagging :check if <movie name>.nfo exists in root of emby movie folder
- for sonarr tagging: check if tvshow.nfo exists in root of emby series folder
- if the respective tag is not in there already, appends tag to end of the respective nfo file.

Please note:
- this only adds tags, will not delete or update
- in my radarr/sonarr containers, i mount: `- /mnt/media/:/data` but since im running this script outside the containers,  i need to modify nfo files on the host system (which doesn't know about container "/data" path - this is why i replace "/data/" with "/mnt/media/" to find the file on my host system. You may or may not this part.

Proper solution would be to not modify nfo files directly on filesystem, but to use Emby API. I would ideally make a radarr and sonarr version of the script and add them to each container as import hooks. If i get time i'll look into it. Surely a proper solution already exists, but i haven't found one. 

The aforementioned solution seems by @Neminem seems to give radarr/sonarr full power to modify emby nfo files, which takes emby away from being the real metadata manager for the media, which can result in problems described here: 

 

Ideally, i want to create a proper solution where we only copy tags from radarr/sonarr --> emby while keeping emby as the full metadata manager for media. Currently, there is no option in  radarr/sonarr to sync only tags to emby metadata.

 

my script (pip install pyarr):

from pyarr import Sonarr, Radarr
import os

radarr_url = '<radarr url>'
radarr_api = '<radarr api token>'
radarr = Radarr(radarr_url, radarr_api)

sonarr_url = '<sonarr url>'
sonarr_api = '<sonarr api token'
sonarr = Sonarr(sonarr_url, sonarr_api)

# Radarr Tagging
print("========== Radarr --> Emby tags ==========")
tag_details = radarr.tag.get_detail()
for tag in tag_details:
    label = tag["label"]
    movie_ids = tag["movieIds"]
    print(f"{label}: {len(movie_ids)}")
    for movie_id in movie_ids:
        movie = radarr.movie.get(movie_id)
        try:
            movie_path = movie["movieFile"]["path"].replace(
                "/data/", "/mnt/media/")
        except:
            continue
        movie_root_path = os.path.split(movie_path)[0]
        movie_file_name = os.path.split(movie_path)[1]
        nfo_file_name = movie_file_name.replace(
            ".mp4", ".nfo").replace(".mkv", ".nfo")
        nfo_file_path = os.path.join(movie_root_path, nfo_file_name)
        if os.path.exists(nfo_file_path):
            with open(nfo_file_path, "r") as file:
                nfo_data = file.read()
                if f"<tag>{label}</tag>" in nfo_data:
                    # print("ALREADY TAGGED. SKIPPING...")
                    continue
                nfo_new = nfo_data.replace(
                    "</movie>", f"  <tag>{label}</tag>\n</movie>")
            with open(nfo_file_path, "w") as file:
                file.write(nfo_new)
                print(f"{nfo_file_path} tagged with {label}")

# Sonarr Tagging
print("========== Sonarr --> Emby tags ==========")
sonarr_tag_details = sonarr.tag.get_detail()
for tag in sonarr_tag_details:
    label = tag["label"]
    series_ids = tag["seriesIds"]
    print(f"{label}: {len(series_ids)}")
    for series_id in series_ids:
        try:
            series = sonarr.series.get(series_id)
            series_path = series["path"].replace("/data/", "/mnt/media/")
            nfo_file_path = os.path.join(series_path, "tvshow.nfo")
            if os.path.exists(nfo_file_path):
                with open(nfo_file_path, "r") as file:
                    nfo_data = file.read()
                    if f"<tag>{label}</tag>" in nfo_data:
                        continue
                    nfo_new = nfo_data.replace(
                        "</tvshow>", f"  <tag>{label}</tag>\n</tvshow>")
                with open(nfo_file_path, "w") as file:
                    file.write(nfo_new)
                    print(f"{nfo_file_path} tagged with {label}")
        except Exception as e:
            print(f"Error processing series {series_id}: {e}")
            continue

 

Edited by embylad892746

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...