jaquestati 45 Posted September 29, 2023 Posted September 29, 2023 is there a way to scan a single folder in a library? On Ubuntu.. thanks
adminExitium 355 Posted September 29, 2023 Posted September 29, 2023 Try the /Library/Media/Updated endpoint.
jaquestati 45 Posted September 29, 2023 Author Posted September 29, 2023 19 minutes ago, adminExitium said: Try the /Library/Media/Updated endpoint. thanks : ) but could you explain it to me like i am an idiot... and have no idea what i'm doing : )
adminExitium 355 Posted September 29, 2023 Posted September 29, 2023 Just to confirm, you want the API that needs to be called or something from the UI?
Luke 42077 Posted September 29, 2023 Posted September 29, 2023 7 hours ago, jaquestati said: thanks : ) but could you explain it to me like i am an idiot... and have no idea what i'm doing : ) 7 hours ago, adminExitium said: Try the /Library/Media/Updated endpoint. No that’s wrong. That’s just to inform the server that something has changed.
Luke 42077 Posted September 29, 2023 Posted September 29, 2023 Can you try performing the action in chrome and monitor the request using the browser debug console?
adminExitium 355 Posted September 29, 2023 Posted September 29, 2023 1 minute ago, Luke said: No that’s wrong. That’s just to inform the server that something has changed. Yeah, but won't that result in a scan of that folder too? Based on the barebones first post, I have no idea whether it's an existing folder or a new folder so didn't want to suggest the full /Library/Refresh method instead.
Luke 42077 Posted September 29, 2023 Posted September 29, 2023 10 minutes ago, adminExitium said: Yeah, but won't that result in a scan of that folder too? Based on the barebones first post, I have no idea whether it's an existing folder or a new folder so didn't want to suggest the full /Library/Refresh method instead. It should I guess yes. Just not the intended purpose. 1
hthgihwaymonk 34 Posted September 29, 2023 Posted September 29, 2023 Looking at how autoscan sends single scan requests to emby - It looks like it is using `/Library/Media/Updated` in combination with `/Library/SelectableMediaFolders` Not sure if it is using `/Library/SelectableMediaFolders` to see if the folder exists in emby 1st or not, as it's written in go and I have a hard enough time using python
plexstreams1 3 Posted October 6, 2023 Posted October 6, 2023 (edited) I am also interested in this. If I know a new media has been added to the library under a certain path /mnt/media/movies/movie 1 (2023) what API actions can I use to tell Emby to just scan in this one path and update the library? Edited October 6, 2023 by plexstreams1
hthgihwaymonk 34 Posted October 7, 2023 Posted October 7, 2023 I'm not 100% sure I have the payload correct, I'll check again on it in the morning process_item_libraries() calls the emby api to collect all the folder paths in all of your libraries And when you pass the script a file "/some/path/to/your/movie.mkv", it checks to make sure that path exists in one of your libraries before sending the item to emby import sys import requests import os emby_url = '< your URL >' emby_api_key = '< your api key >' def create_item(item_path, updateType): url = f"{emby_url}/emby/Library/Media/Updated" payload = { "Updates": [{"Path": item_path, "UpdateType": updateType}] } headers = { "X-Emby-Token": emby_api_key } response = requests.post(url, json=payload, headers=headers) if response.status_code == 204: print("Item created successfully.") else: print("Error occurred while creating the item:", response.status_code) def process_item_library(item): item_path = os.path.dirname(item) url = f"{emby_url}/emby/Library/SelectableMediaFolders?api_key={emby_api_key}" response = requests.get(url) if response.status_code == 200: json_data = response.json() for folder in json_data: for subfolder in folder["SubFolders"]: if subfolder["Path"] in item_path: # just a bit of testing #parentID_value = folder["Id"] #guid_value = folder["Guid"] #subfolder_id = subfolder["Id"] #subfolder_path = subfolder["Path"] #print(f"ParentID: {parentID_value}, Guid: {guid_value}, Subfolder Id: {subfolder_id}, path: {subfolder_path}, item_path: {item_path}") # create_item(item_path, "Created") return print("No Library match found for the given item folder.") else: print("Error occurred while getting the JSON:", response.status_code) if len(sys.argv) > 1: item = sys.argv[1] # Use the first command-line argument as item_folder get_item_library(item) else: print("No item folder provided as a command-line argument.") Usage: python3 myscript.py "/some path/to/my file/media file (2023).mkv" 1
plexstreams1 3 Posted October 9, 2023 Posted October 9, 2023 (edited) This is what I was trying but Emby is just not re-scanning that folder to detect a change. I am running this: curl --location 'http://server:8096/emby/Library/Media/Updated' \ --header 'X-Emby-Token: XXXXXXXXXXXXXX' \ --header 'Content-Type: text/plain' \ --data '{ "Updates": [ { "Path": "/mnt/Media/Movies/Movies-Temp/3 Demons (2022) [imdb-tt13173736]/20_14_02.mkv", "UpdateType": "Created" } ] }' I get a 204 back so the request was accepted. I have also tried other UpdateType such as Deleted and Modified with the same result. Emby just doesn't scan. What am I doing wrong. For example, I delete the movie folder, run the curl command and the movie is still there after a few minutes. Nothing in the Emby log aside from the info that the request was accepted Edited October 9, 2023 by plexstreams1
Luke 42077 Posted October 10, 2023 Posted October 10, 2023 21 hours ago, plexstreams1 said: This is what I was trying but Emby is just not re-scanning that folder to detect a change. I am running this: curl --location 'http://server:8096/emby/Library/Media/Updated' \ --header 'X-Emby-Token: XXXXXXXXXXXXXX' \ --header 'Content-Type: text/plain' \ --data '{ "Updates": [ { "Path": "/mnt/Media/Movies/Movies-Temp/3 Demons (2022) [imdb-tt13173736]/20_14_02.mkv", "UpdateType": "Created" } ] }' I get a 204 back so the request was accepted. I have also tried other UpdateType such as Deleted and Modified with the same result. Emby just doesn't scan. What am I doing wrong. For example, I delete the movie folder, run the curl command and the movie is still there after a few minutes. Nothing in the Emby log aside from the info that the request was accepted Hi there, why do you think emby doesn't scan?
adminExitium 355 Posted October 10, 2023 Posted October 10, 2023 On 10/10/2023 at 02:24, plexstreams1 said: running this: The content-type should be application/json btw, since you are sending a JSON object. Not sure if that's causing the issue. If that doesn't fix it, you need to post the embyserver logs around the time the request was sent.
plexstreams1 3 Posted October 11, 2023 Posted October 11, 2023 Content-Type appears to be an issue. Weird. Thank you everyone for responding. For completeness, this appears to work. curl --location 'http://server:8096/emby/Library/Media/Updated' \ --header 'X-Emby-Token: XXXXXXXXXXXXXX' \ --header 'Content-Type: application/json' \ --data '{ "Updates": [ { "Path": "/mnt/Media/Movies/Movies-Temp/3 Demons (2022) [imdb-tt13173736]/20_14_02.mkv", "UpdateType": "Created" } ] }' 1
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