D1sk 4 Posted August 20, 2024 Posted August 20, 2024 Hello together I have written a python program that removes the actors from the nfo. Only after the python code has cleaned up the nfo, Emby inserts them again without further ado. can i block this somehow in the nfo? #!/usr/bin/env python3 # Autoren: D1sk # Unternehmen: T4S # NFO-Tag-Eintrager (aus Dateinamen) v6 # Date: 20.07.2024 # Update_Date: 20.08.2024 # Zusatztool für Emby # Bibliotheken import os import re import xml.etree.ElementTree as ET import tkinter as tk from tkinter import filedialog, simpledialog, messagebox def process_nfo_file(nfo_path, additional_tags=None): try: # Öffne die NFO-Datei und lade sie in den ElementTree tree = ET.parse(nfo_path) xml_root = tree.getroot() # Entferne alle <actor>-Elemente for actor in xml_root.findall('.//actor'): xml_root.remove(actor) # Überprüfe, ob eines der vorhandenen <tag>-Elemente den gewünschten Inhalt hat if additional_tags: tags = [t.strip() for t in additional_tags.split('&')] existing_tags = {tag_element.text for tag_element in xml_root.findall('tag')} for tag in tags: if tag not in existing_tags: new_tag_element = ET.Element('tag') new_tag_element.text = tag # Finde das <runtime>-Element und füge das <tag>-Element direkt danach ein runtime_element = xml_root.find('runtime') if runtime_element is not None: index = list(xml_root).index(runtime_element) xml_root.insert(index + 1, new_tag_element) else: xml_root.append(new_tag_element) print(f"Neues Tag '{tag}' zu NFO-Datei '{os.path.basename(nfo_path)}' hinzugefügt.") else: print(f"Tag '{tag}' in NFO-Datei '{os.path.basename(nfo_path)}' ist bereits vorhanden.") # Schreibe die aktualisierte NFO-Datei zurück tree.write(nfo_path, encoding='utf-8', xml_declaration=True) print(f"Actors entfernt aus '{os.path.basename(nfo_path)}'.") except Exception as e: print(f"Fehler beim Verarbeiten der Datei {nfo_path}: {e}") def update_nfo_files(main_directory, additional_tags=None): # Muster zum Erkennen des Textes nach dem letzten Bindestrich bis zum Dateiende tag_pattern = r'-(.+)$' # Iteriere durch alle Ordner im Hauptverzeichnis for folder_root, dirs, files in os.walk(main_directory): for file in files: if file.endswith(".nfo") and file != "tvshow.nfo": nfo_path = os.path.join(folder_root, file) # Nur den Dateinamen ohne Pfad und Erweiterung extrahieren file_name = os.path.splitext(file)[0] # Extrahiere den Tag aus dem Dateinamen match = re.search(tag_pattern, file_name) if match: # Wenn ein Tag gefunden wird, extrahiere es tag = match.group(1) # Überprüfe, ob der Tag mehrere Gruppen enthält, die durch '&' getrennt sind tags = [t.strip() for t in tag.split('&')] # Füge zusätzliche Tags hinzu, falls vorhanden if additional_tags: tags.extend([t.strip() for t in additional_tags.split('&')]) # Verarbeite die NFO-Datei process_nfo_file(nfo_path, additional_tags='&'.join(tags)) # Verarbeite die tvshow.nfo-Datei, falls vorhanden tvshow_nfo_path = os.path.join(main_directory, 'tvshow.nfo') if os.path.exists(tvshow_nfo_path): process_nfo_file(tvshow_nfo_path, additional_tags) else: print("tvshow.nfo nicht gefunden. Kein Tag hinzugefügt.") print("Vorgang abgeschlossen.") def main(): root = tk.Tk() root.withdraw() # Frage den Benutzer, ob er ein eigenes Tag hinzufügen möchte add_tag_choice = messagebox.askyesno("Zusätzliche Tags", "Möchten Sie eigene Tags hinzufügen?") additional_tags = None if add_tag_choice: # Falls der Benutzer "Ja" auswählt, zeige ein Eingabefeld für die zusätzlichen Tags an additional_tags = simpledialog.askstring("Zusätzliche Tags", "Geben Sie die zusätzlichen Tags ein (mit '&' getrennt):") # Hauptverzeichnis, das durchsucht werden soll main_directory = filedialog.askdirectory(title='Animeordner auswählen') # Verarbeite die NFO-Dateien mit den gewählten Optionen update_nfo_files(main_directory, additional_tags) if __name__ == "__main__": main() After running through, the NFO looks like this No more actors <?xml version='1.0' encoding='utf-8'?> <tvshow> <plot>Westlich von Tokyo befindet sich eine Metropole mit ├╝ber 2,3 Millionen Einwohnern, welche aufgrund ihres 80%igen Anteils an Sch├╝lern und Studenten allgemeinhein als "Bildungsstadt" bekannt ist. Hier durchlaufen die Sch├╝ler ein Training als Esper und werden anhand ihrer F├ñhigkeiten in Level 0 bis 5 eingeteilt. Aktuell gibt es nur sieben Individuen, die es auf Level 5 geschafft haben. Eine von ihnen ist Mikoto Misaka. Gemeinsam mit ihren Freunden Kuroko und Uiharu, die zur Disziplinar-Organisation Judgment geh├╢ren, sowie der Ger├╝chte liebenden Saten bestehen sie viele Abenteuer. Spin-off von Toaru Majutsu no Index, der Mikoto zur Hauptfigur hat.</plot> <outline>Westlich von Tokyo befindet sich eine Metropole mit ├╝ber 2,3 Millionen Einwohnern, welche aufgrund ihres 80%igen Anteils an Sch├╝lern und Studenten allgemeinhein als "Bildungsstadt" bekannt ist. Hier durchlaufen die Sch├╝ler ein Training als Esper und werden anhand ihrer F├ñhigkeiten in Level 0 bis 5 eingeteilt. Aktuell gibt es nur sieben Individuen, die es auf Level 5 geschafft haben. Eine von ihnen ist Mikoto Misaka. Gemeinsam mit ihren Freunden Kuroko und Uiharu, die zur Disziplinar-Organisation Judgment geh├╢ren, sowie der Ger├╝chte liebenden Saten bestehen sie viele Abenteuer. Spin-off von Toaru Majutsu no Index, der Mikoto zur Hauptfigur hat.</outline> <lockdata>false</lockdata> <dateadded>2024-06-13 14:19:50</dateadded> <title>A Certain Scientific Railgun</title> <originaltitle>πü¿πüéπéïτºæσ¡ªπü«Φ╢àΘ¢╗τúüτá▓</originaltitle> <trailer>http://www.youtube.com/watch?v=dKLdA60lUw4</trailer> <trailer>http://www.youtube.com/watch?v=rIDa2o3bGlY</trailer> <rating>7.5</rating> <year>2009</year> <sorttitle>Certain Scientific Railgun</sorttitle> <mpaa>TV-14</mpaa> <imdb_id>tt1515996</imdb_id> <tmdbid>30977</tmdbid> <premiered>2009-10-03</premiered> <releasedate>2009-10-03</releasedate> <enddate>2020-09-25</enddate> <runtime>25</runtime> <genre>Science Fiction</genre> <genre>Fantasy</genre> <genre>Drama</genre> <genre>Comedy</genre> <genre>Animation</genre> <genre>Action</genre> <genre>Anime</genre> <studio>Tokyo MX</studio> <studio>AT-X</studio> <tag>Fansub</tag> <tag>Super Power</tag> <tag>Urban</tag> <tag>Primarily Female Cast</tag> <tag>Female Protagonist</tag> <tag>Urban Fantasy</tag> <tag>Tomboy</tag> <tag>Ensemble Cast</tag> <tag>Bisexual</tag> <tag>Superhero</tag> <tag>School</tag> <tag>Artificial Intelligence</tag> <tag>Boarding School</tag> <tag>Shounen</tag> <tag>Tsundere</tag> <tag>Kaiju</tag> <tag>Gangs</tag> <tag>Heterosexual</tag> <tag>Robots</tag> <tag>Ojou-sama</tag> <tag>Orphan</tag> <tag>Slapstick</tag> <tag>Crossdressing</tag> <tag>Super Robot</tag> <tag>Maids</tag> <tag>Police</tag> <tag>Gyaru</tag> <uniqueid type="tvdb">114921</uniqueid> <tvdbid>114921</tvdbid> <uniqueid type="official website">https://toaru-project.com/railgun/</uniqueid> <uniqueid type="imdb">tt1515996</uniqueid> <uniqueid type="tmdb">30977</uniqueid> <uniqueid type="anilist">6213</uniqueid> <anilistid>6213</anilistid> <episodeguide>{"tvdb":"114921","official website":"https://toaru-project.com/railgun/","imdb":"tt1515996","tmdb":"30977","anilist":"6213"}</episodeguide> <id>114921</id> <season>-1</season> <episode>-1</episode> <displayorder>aired</displayorder> <status>Ended</status> </tvshow> then a few minutes later like this again <?xml version="1.0" encoding="utf-8" standalone="yes"?> <tvshow> <plot><![CDATA[Westlich von Tokyo befindet sich eine Metropole mit über 2,3 Millionen Einwohnern, welche aufgrund ihres 80%igen Anteils an Schülern und Studenten allgemeinhein als "Bildungsstadt" bekannt ist. Hier durchlaufen die Schüler ein Training als Esper und werden anhand ihrer Fähigkeiten in Level 0 bis 5 eingeteilt. Aktuell gibt es nur sieben Individuen, die es auf Level 5 geschafft haben. Eine von ihnen ist Mikoto Misaka. Gemeinsam mit ihren Freunden Kuroko und Uiharu, die zur Disziplinar-Organisation Judgment gehören, sowie der Gerüchte liebenden Saten bestehen sie viele Abenteuer. Spin-off von Toaru Majutsu no Index, der Mikoto zur Hauptfigur hat.]]></plot> <outline><![CDATA[Westlich von Tokyo befindet sich eine Metropole mit über 2,3 Millionen Einwohnern, welche aufgrund ihres 80%igen Anteils an Schülern und Studenten allgemeinhein als "Bildungsstadt" bekannt ist. Hier durchlaufen die Schüler ein Training als Esper und werden anhand ihrer Fähigkeiten in Level 0 bis 5 eingeteilt. Aktuell gibt es nur sieben Individuen, die es auf Level 5 geschafft haben. Eine von ihnen ist Mikoto Misaka. Gemeinsam mit ihren Freunden Kuroko und Uiharu, die zur Disziplinar-Organisation Judgment gehören, sowie der Gerüchte liebenden Saten bestehen sie viele Abenteuer. Spin-off von Toaru Majutsu no Index, der Mikoto zur Hauptfigur hat.]]></outline> <lockdata>false</lockdata> <dateadded>2024-06-13 14:19:50</dateadded> <title>A Certain Scientific Railgun</title> <originaltitle>とある科学の超電磁砲</originaltitle> <actor> <name>Rina Satou</name> <role>Mikoto Misaka</role> <type>Actor</type> <tmdbid>1241566</tmdbid> <tvdbid>293450</tvdbid> <anidbid>97</anidbid> </actor> <actor> <name>Satomi Arai</name> <role>Kuroko Shirai</role> <type>Actor</type> <tmdbid>219563</tmdbid> <tvdbid>301628</tvdbid> </actor> <actor> <name>Kanae Itou</name> <role>Ruiko Saten</role> <type>Actor</type> <tvdbid>464298</tvdbid> </actor> <actor> <name>Aki Toyosaki</name> <role>Kazari Uiharu</role> <type>Actor</type> <tvdbid>307442</tvdbid> <tmdbid>235262</tmdbid> <imdbid>nm2760504</imdbid> <anidbid>1438</anidbid> </actor> <actor> <name>浅仓杏美</name> <role>Misaki Shokuhou</role> <type>Actor</type> <tmdbid>1325958</tmdbid> <tvdbid>448666</tvdbid> </actor> <actor> <name>Nozomi Sasaki</name> <role>Misaka Imouto</role> <type>Actor</type> <tmdbid>2413553</tmdbid> <tvdbid>505152</tvdbid> <anidbid>1992</anidbid> </actor> <actor> <name>Minako Kotobuki</name> <role>Mitsuko Kongou</role> <type>Actor</type> <tvdbid>451347</tvdbid> <tmdbid>1249310</tmdbid> </actor> <actor> <name>Haruka Tomatsu</name> <role>Kinuho Wannai</role> <type>Actor</type> <tmdbid>1248340</tmdbid> <tvdbid>715282</tvdbid> <anidbid>5</anidbid> <imdbid>nm2955927</imdbid> </actor> <actor> <name>Yoshino Nanjou</name> <role>Maaya Awatsuki</role> <type>Actor</type> <tvdbid>479697</tvdbid> </actor> <actor> <name>Minami Tsuda</name> <role>Junko Hokaze</role> <type>Actor</type> <tvdbid>292643</tvdbid> <tmdbid>1307031</tmdbid> <anidbid>21823</anidbid> </actor> <actor> <name>Konomi Kohara</name> <role>Dolly</role> <type>Actor</type> <tmdbid>1820616</tmdbid> <tvdbid>7891685</tvdbid> </actor> <actor> <name>Maaya Uchida</name> <role>Frenda Seivelun</role> <type>Actor</type> <tvdbid>294195</tvdbid> <tmdbid>1296667</tmdbid> </actor> <actor> <name>Miyu Tomita</name> <role>Mitori Kouzaku</role> <type>Actor</type> <tvdbid>464899</tvdbid> <tmdbid>1647636</tmdbid> <anidbid>43492</anidbid> </actor> <actor> <name>Hitomi Oowada</name> <role>Xochitl</role> <type>Actor</type> <tvdbid>7884367</tvdbid> </actor> <actor> <name>Akane Fujita</name> <role>Rita Iizumi</role> <type>Actor</type> <tmdbid>1668897</tmdbid> <tvdbid>483788</tvdbid> </actor> <actor> <name>Aoi Koga</name> <role>Naruha Sakuragi</role> <type>Actor</type> <tvdbid>7897330</tvdbid> <tmdbid>2251986</tmdbid> </actor> <actor> <name>Sayumi Suzushiro</name> <role>Rakko Yumiya</role> <type>Actor</type> <tvdbid>7937849</tvdbid> <tmdbid>2206133</tmdbid> </actor> <actor> <name>Kana Ueda</name> <role>Mii Konori</role> <type>Actor</type> <tvdbid>303210</tvdbid> <tmdbid>230471</tmdbid> <imdbid>nm1290090</imdbid> <anidbid>210</anidbid> </actor> <actor> <name>Nozomi Nishida</name> <role>Itsuki Yakumaru</role> <type>Actor</type> <tmdbid>1606202</tmdbid> <tvdbid>482632</tvdbid> </actor> <actor> <name>Yuka Nukui</name> <role>Taroumaru Seike</role> <type>Actor</type> <tvdbid>7976327</tvdbid> <tmdbid>1922616</tmdbid> </actor> <actor> <name>Atsumi Tanezaki</name> <role>Ryouko Kuriba</role> <type>Actor</type> <tmdbid>1588597</tmdbid> <tvdbid>7866747</tvdbid> </actor> <actor> <name>Atsushi Abe</name> <role>Touma Kamijou</role> <type>Actor</type> <tvdbid>280711</tvdbid> <tmdbid>1154449</tmdbid> </actor> <actor> <name>Yuuko Kaida</name> <role>Aiho Yomikawa</role> <type>Actor</type> <tvdbid>7888642</tvdbid> </actor> <actor> <name>Kengo Kawanishi</name> <role>Gunha Sogiita</role> <type>Actor</type> <tmdbid>1324472</tmdbid> <tvdbid>289883</tvdbid> </actor> <actor> <name>Mayu Mineda</name> <role>Shaei Miyama</role> <type>Actor</type> <tmdbid>2415149</tmdbid> <tvdbid>8255988</tvdbid> </actor> <actor> <name>Kazuyoshi Hayashi</name> <role>Keitz Nokleben</role> <type>Actor</type> <tvdbid>8289400</tvdbid> </actor> <actor> <name>Binbin Takaoka</name> <role>Kihara Gensei</role> <type>Actor</type> <tmdbid>1254298</tmdbid> <tvdbid>451370</tvdbid> </actor> <actor> <name>Iori Nomizu</name> <role>Febri</role> <type>Actor</type> <tmdbid>1254069</tmdbid> <tvdbid>450565</tvdbid> </actor> <actor> <name>Hitomi Nabatame</name> <role>Ryoukan</role> <type>Actor</type> <tvdbid>377762</tvdbid> <tmdbid>1241562</tmdbid> <anidbid>55</anidbid> </actor> <actor> <name>Ikumi Hayama</name> <role>Shinobu Nunotaba</role> <type>Actor</type> <tvdbid>470645</tvdbid> <tmdbid>1254299</tmdbid> </actor> <actor> <name>Aya Endou</name> <role>Tsuzuri Tessou</role> <type>Actor</type> <tvdbid>7873538</tvdbid> </actor> <actor> <name>Atsuko Tanaka</name> <role>Harumi Kiyama</role> <type>Actor</type> <tvdbid>314895</tvdbid> <tmdbid>34923</tmdbid> <anidbid>222</anidbid> </actor> <actor> <name>Ami Koshimizu</name> <role>Shizuri Mugino</role> <type>Actor</type> <tvdbid>307435</tvdbid> <tmdbid>1220947</tmdbid> <anidbid>51</anidbid> </actor> <trailer>http://www.youtube.com/watch?v=dKLdA60lUw4</trailer> <trailer>http://www.youtube.com/watch?v=rIDa2o3bGlY</trailer> <rating>7.5</rating> <year>2009</year> <sorttitle>Certain Scientific Railgun</sorttitle> <mpaa>TV-14</mpaa> <imdb_id>tt1515996</imdb_id> <tmdbid>30977</tmdbid> <premiered>2009-10-03</premiered> <releasedate>2009-10-03</releasedate> <enddate>2020-09-25</enddate> <runtime>25</runtime> <genre>Science Fiction</genre> <genre>Fantasy</genre> <genre>Drama</genre> <genre>Comedy</genre> <genre>Animation</genre> <genre>Action</genre> <genre>Anime</genre> <studio>Tokyo MX</studio> <studio>AT-X</studio> <tag>Fansub</tag> <tag>Super Power</tag> <tag>Urban</tag> <tag>Primarily Female Cast</tag> <tag>Female Protagonist</tag> <tag>Urban Fantasy</tag> <tag>Tomboy</tag> <tag>Ensemble Cast</tag> <tag>Bisexual</tag> <tag>Superhero</tag> <tag>School</tag> <tag>Artificial Intelligence</tag> <tag>Boarding School</tag> <tag>Shounen</tag> <tag>Tsundere</tag> <tag>Kaiju</tag> <tag>Gangs</tag> <tag>Heterosexual</tag> <tag>Robots</tag> <tag>Ojou-sama</tag> <tag>Orphan</tag> <tag>Slapstick</tag> <tag>Crossdressing</tag> <tag>Super Robot</tag> <tag>Maids</tag> <tag>Police</tag> <tag>Gyaru</tag> <uniqueid type="tvdb">114921</uniqueid> <tvdbid>114921</tvdbid> <uniqueid type="official website">https://toaru-project.com/railgun/</uniqueid> <uniqueid type="imdb">tt1515996</uniqueid> <uniqueid type="tmdb">30977</uniqueid> <uniqueid type="anilist">6213</uniqueid> <anilistid>6213</anilistid> <episodeguide>{"tvdb":"114921","official website":"https://toaru-project.com/railgun/","imdb":"tt1515996","tmdb":"30977","anilist":"6213"}</episodeguide> <id>114921</id> <season>-1</season> <episode>-1</episode> <displayorder>aired</displayorder> <status>Ended</status> </tvshow> I hope someone knows a solution because clicking on each file and locking it manually is an incredible effort
visproduction 315 Posted August 20, 2024 Posted August 20, 2024 Windows and Linux both have script commands to find any file type and lock it to read only. I thought that once the actors are choosen, you should not get a situation where an actor gets a new ID code. If the actor is already correct, I don't think you will run into a problem. So locking the files seem overkill. Maybe I didn't understand your initial issue. So to change the read only in Windows, see: https://www.howtogeek.com/205910/how-to-change-file-attributes-with-attrib-from-the-windows-command-prompt/ A correctly written command will change all .nfo files in an entire drive, or just a folder and subfolders with one 'Enter' click. Be aware, that you won't be able to update descriptions any more if you do this.
Happy2Play 9780 Posted August 20, 2024 Posted August 20, 2024 I would guess add the lockfields in your edit as there are field locks or lockdata for entire nfo. <lockedfields>Cast</lockedfields>
D1sk 4 Posted August 20, 2024 Author Posted August 20, 2024 10 minutes ago, visproduction said: Maybe I didn't understand your initial issue Hello @visproductionthx for the Information I remove all actors from the nfo with a script The aim is that there are no more Actors in the nfo and none are updated. However, as long as I don't click this lock button in the gui, they are always updated again in the nfo. My question is whether the command for the lock button can also be included in the python code?
D1sk 4 Posted August 20, 2024 Author Posted August 20, 2024 1 minute ago, Happy2Play said: I would guess add the lockfields in your edit as there are field locks or lockdata for entire nfo. Thx @Happy2Play i will try that
visproduction 315 Posted August 20, 2024 Posted August 20, 2024 Ah, OK, no actors... but their head shots are so pretty, especially the ladies. Well won't the script command to set the attributes for all .nfo work? But again that locks everything, which means it is more work to update a description or change a load date to move media down in the Latest order on the home page.
D1sk 4 Posted August 20, 2024 Author Posted August 20, 2024 @Happy2Playworks not just a few Minut later all actors are back 240820170536..mp4
Luke 42079 Posted August 20, 2024 Posted August 20, 2024 I would try locking using the user interface.
D1sk 4 Posted August 20, 2024 Author Posted August 20, 2024 1 minute ago, Luke said: I would try locking using the user interface. Hello Luke How can i do that with python?
Happy2Play 9780 Posted August 20, 2024 Posted August 20, 2024 What exactly are you doing as I just removed a movie from Emby, scanned to clear the db, edited the nfo to have no actors, add <lockedfields>Cast</lockedfields>. moved the media back into library and Emby imported the media and did not readd actors. I don't believe you can remove this info from something that is already in the database or at least remove all. You could try maybe an empty actor node. But pretty sure we have seen this before as you cannot clear nfo information only edit existing once imported.
Happy2Play 9780 Posted August 20, 2024 Posted August 20, 2024 Here is some previous discussion about Tags having the same issue as already import content can't be completely removed. So it may be a two fold process clearing nfo and each item in the db via the api. Or moving all media out, edit nfo move media back.
D1sk 4 Posted August 20, 2024 Author Posted August 20, 2024 33 minutes ago, Happy2Play said: I don't believe you can remove this info from something that is already in the database or at least remove all. You could try maybe an empty actor node. Making something mauel by hand is far too much effort. That's why I want to automate it with a script. If I then have to click and move every single episode in a season order, or lock every episode in the gui, I haven't gained anything. I don't understand why as soon as the actors are deleted from the nfo they are immediately added again by EMby. Is there any way to prevent this? Does Emby download these actors from the database or from the Net again?
Happy2Play 9780 Posted August 20, 2024 Posted August 20, 2024 1 minute ago, D1sk said: Making something mauel by hand is far too much effort. That's why I want to automate it with a script. If I then have to click and move every single episode in a season order, or lock every episode in the gui, I haven't gained anything. I don't understand why as soon as the actors are deleted from the nfo they are immediately added again by EMby. Is there any way to prevent this? Does Emby download these actors from the database or from the Net again? Dev will have to get into the technical side of this but once in the database you cannot just delete via the nfo file. As the database repopulated the nfo file. You can make edits but not complete removals. As you can remove all but one and it work assuming lockfield is not already in place.
Luke 42079 Posted August 20, 2024 Posted August 20, 2024 3 hours ago, D1sk said: Making something mauel by hand is far too much effort. That's why I want to automate it with a script. If I then have to click and move every single episode in a season order, or lock every episode in the gui, I haven't gained anything. I don't understand why as soon as the actors are deleted from the nfo they are immediately added again by EMby. Is there any way to prevent this? Does Emby download these actors from the database or from the Net again? If you have any metadata features enabled on the library, then any metadata refreshes are going to download that info again.
Happy2Play 9780 Posted August 20, 2024 Posted August 20, 2024 3 minutes ago, Luke said: If you have any metadata features enabled on the library, then any metadata refreshes are going to download that info again. In the end, it goes back to the other topic as you can not completely removes all of any specific field in a nfo as the database will regenerate it. You can add, edit or reduce to one but not completely remove any field already imported.
D1sk 4 Posted August 21, 2024 Author Posted August 21, 2024 Thx @Happy2Play Thank you for the information. I understand that if I delete something from the nfo, it is directly added back from the database. So, another question: can I somehow trigger the deletion of people via a script, similar to how I would do it manually in the GUI? For example, using AutoHotkey? Because if I remove people through the GUI and click the block button, they are also immediately removed from the nfo.
Happy2Play 9780 Posted August 21, 2024 Posted August 21, 2024 Not that I know of as in the UI you are working directly with specific db itemid metadata so externally you would have to use the API ItemUpdateService to remove info. So you would have to Post a update to every itemid but not sure how to trigger nfo save at the same time.
D1sk 4 Posted August 22, 2024 Author Posted August 22, 2024 Okay one idea is I delete this via Rest-API and then directly edit the nfo. but how? How do I get all Item_id. per file? I have seen that this is not saved in the nfo. So I can't extract them from there. Or can I filter this via the IDs in the nfo? tmdbid = '21855' # The TMDB ID from the NFO file item_id = get_item_id_by_tmdbid(tmdbid) # This function extracts the item_id as described above # API-Schlüssel und Server-URL api_key = 'ssssxxx' server_url = 'http://[dein-server-ip]:8096' # Funktion, um alle Schauspieler aus einem Emby-Media-Element zu entfernen def remove_actors_from_emby(item_id): url = f'{server_url}/Items/{item_id}/People' headers = { 'X-Emby-Token': api_key } response = requests.delete(url, headers=headers) if response.status_code == 204: print(f"Schauspieler erfolgreich aus dem Element {item_id} entfernt.") else: print(f"Fehler beim Entfernen der Schauspieler aus dem Element {item_id}: {response.status_code}")
D1sk 4 Posted August 22, 2024 Author Posted August 22, 2024 (edited) How i geht the People Information over the IDs https://myserver/items?Ids=33&api_key=xxx Edited August 22, 2024 by D1sk
Happy2Play 9780 Posted August 22, 2024 Posted August 22, 2024 (edited) Personally don't know all the requirements to be sent back in itemupdate as limiting to just people I get a bad request but people are removed from item. But not updated in nfo. @Lukeshould a bad request still work? System.ArgumentNullException: Value cannot be null. (Parameter 'source') Itemid is Emby's created number in the database for that media. Edited August 22, 2024 by Happy2Play
Luke 42079 Posted August 22, 2024 Posted August 22, 2024 You can update nfo and have the charges reflected. Just don’t refresh metadata. Let the normal library scan pick up the changes.
Happy2Play 9780 Posted August 22, 2024 Posted August 22, 2024 45 minutes ago, Luke said: You can update nfo and have the charges reflected. Just don't refresh metadata. Let the normal library scan pick up the changes. But just like the other topic you can update but cannot remove/clear any specific node. So removing all People from nfo will not work.
Luke 42079 Posted August 23, 2024 Posted August 23, 2024 13 minutes ago, Happy2Play said: But just like the other topic you can update but cannot remove/clear any specific node. So removing all People from nfo will not work. I think that should actually be resolved in 4.8+.
Happy2Play 9780 Posted August 23, 2024 Posted August 23, 2024 (edited) 3 minutes ago, Luke said: I think that should actually be resolved in 4.8+. I will have to retest on tags but exact same scenario with people as you can't remove completely only edit down to one or add. Retested Tags and that can be done via nfo edit as long as it isn't locked/lockfield. Edited August 23, 2024 by Happy2Play
D1sk 4 Posted August 25, 2024 Author Posted August 25, 2024 @Happy2Play If I can't delete them then I can overwrite them. First as described in the code I make the nfo to a html tree then I delete all Actos tags Then I check if there is an anilist id If yes I make an API call import requests def fetch_main_characters(anime_id): query = ''' query ($id: Int) { Media(id: $id, type: ANIME) { characters(role: MAIN) { nodes { id name { first last } image { large } } } } } ''' variables = { 'id': anime_id } url = 'https://graphql.anilist.co' response = requests.post(url, json={'query': query, 'variables': variables}) if response.status_code == 200: data = response.json() characters = data.get('data', {}).get('Media', {}).get('characters', {}).get('nodes', []) return characters else: raise Exception(f"GraphQL query failed with a {response.status_code} status code") def main(): anime_id = 98512 # Beispiel-Anime-ID try: characters = fetch_main_characters(anime_id) character_details = [] if characters: for character in characters: first_name = character['name'].get('first', '') last_name = character['name'].get('last', '') image_url = character.get('image', {}).get('large', '') if first_name and last_name: full_name = f"{first_name} {last_name}" else: full_name = first_name or last_name character_details.append({ 'name': full_name.strip(), 'image_url': image_url }) print(f"Main characters for Anime ID {anime_id}:") for detail in character_details: print(f"Name: {detail['name']}, Image URL: {detail['image_url']}") except Exception as e: print(f"Error: {e}") if __name__ == "__main__": main() I get the names of the main characters and the image url I then set the names as actor tags and save the html tree back to nfo But how can I update the images in Emby via API call? so that the image where I have crawled the url is used for the actor image? Thx for help
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now