Guest Posted May 5, 2021 Share Posted May 5, 2021 Same way I think.. crazy but I haven't used API's or anything.. I get command line and some code writing.. but some of this that people throw around I have not played with.. I find two things online.. one is where you install cURL and one where you already have it distributed with Windows.. Could try running some basic and see about a response.. curl -help Should give you a string of options.. verifies if it is there.. Link to comment Share on other sites More sharing options...
jmansell90 4 Posted May 5, 2021 Share Posted May 5, 2021 (edited) 53 minutes ago, dcol said: And how would I go about that in a Windows environment? I would create the file "update-emby.ps1" (name it whatever, save it wherever) with the following: $EMBYIP = "127.0.0.1" $APIKEY = "YOUR API KEY" $FOLDERS = @(FOLDERID1, FOLDERID2, FOLDERID3) foreach ($FOLDER in $FOLDERS) { Invoke-WebRequest -Uri "http://$EMBYIP/emby/Items/$FOLDER/Refresh?Recursive=true&ImageRefreshMode=Default&MetadataRefreshMode=Default&ReplaceAllImages=false&ReplaceAllMetadata=false&api_key=$APIKEY" ` -Method "POST" ` -Headers @{ "Accept"="*/*" "Accept-Encoding"="gzip, deflate" } } Modify the first 3 lines to your environment; 127.0.0.1 may work since you are already on that machine. Then go into your Task Scheduler (win+R and enter taskschd. msc) Create a new Scheduled Task to run your powershell script every... X minutes. This is largely untested, as I am recombining my libraries into one so it needs to do the massive scan; it wont let me use this until that is done. If any of these instructions are confusing, you might hold off. There's little risk but scheduled tasks can be pretty powerful to play with Edited May 5, 2021 by jmansell90 Bad API call data 1 Link to comment Share on other sites More sharing options...
Veggav 8 Posted May 5, 2021 Share Posted May 5, 2021 Nothing like the community getting together to solve a problem. Link to comment Share on other sites More sharing options...
dcol 165 Posted May 5, 2021 Share Posted May 5, 2021 22 minutes ago, jmansell90 said: I would create the file "update-emby.ps1" (name it whatever, save it wherever) with the following: $EMBYIP = "127.0.0.1" $APIKEY = "YOUR API KEY" $FOLDERS = @(FOLDERID1, FOLDERID2, FOLDERID3) foreach ($FOLDER in $FOLDERS) { Invoke-WebRequest -Uri "http://$EMBYIP/emby/Items/$FOLDER/Refresh?Recursive=true&ImageRefreshMode=Default&MetadataRefreshMode=Default&ReplaceAllImages=false&ReplaceAllMetadata=false&api_key=$APIKEY" ` -Method "POST" ` -Headers @{ "Accept"="*/*" "Accept-Encoding"="gzip, deflate" } } Modify the first 3 lines to your environment; 127.0.0.1 may work since you are already on that machine. Then go into your Task Scheduler (win+R and enter taskschd. msc) Create a new Scheduled Task to run your powershell script every... X minutes. This is largely untested, as I am recombining my libraries into one so it needs to do the massive scan; it wont let me use this until that is done. If any of these instructions are confusing, you might hold off. There's little risk but scheduled tasks can be pretty powerful to play with Never did an API before. I will try it. Do I just add a new API and name it anything I want, then use the number it provided? Also, What are the FolderID's? Is that a direct path to the actual folder, or are they already defined somewhere? Link to comment Share on other sites More sharing options...
jmansell90 4 Posted May 5, 2021 Share Posted May 5, 2021 Just now, dcol said: Never did an API before. I will try it. Do I just add a new API and name it anything I want, then use the number it provided? Also, What are the FolderID's? Is that a direct path to the actual folder, or are they already defined somewhere? See my post a few posts back about how to find the folder ID. It is not the direct path but an ID that Emby gives the folder internally. The gist of it is, go into your media library>Folders>THE FOLDER and look at the URL. ParentId is your Folder ID. As for the API key, that is in Emby>Settings>API Key and click "New". Name it something like 'api library scan script' so you know what it is and copy the long string it gives you Link to comment Share on other sites More sharing options...
dcol 165 Posted May 5, 2021 Share Posted May 5, 2021 2 hours ago, jmansell90 said: See my post a few posts back about how to find the folder ID. It is not the direct path but an ID that Emby gives the folder internally. The gist of it is, go into your media library>Folders>THE FOLDER and look at the URL. ParentId is your Folder ID. As for the API key, that is in Emby>Settings>API Key and click "New". Name it something like 'api library scan script' so you know what it is and copy the long string it gives you I get the following error when I run the ps1 file At N:\emby\updatescan.ps1:3 char:46 + $FOLDERS = @(c2257bbd84a4b4bb4f9f4e16cd641326, f137a2dd21bbc1b99aa5c0 ... + ~ Missing argument in parameter list. + CategoryInfo : ParserError: (:) [], ParseException + FullyQualifiedErrorId : MissingArgument Link to comment Share on other sites More sharing options...
jmansell90 4 Posted May 5, 2021 Share Posted May 5, 2021 18 minutes ago, dcol said: I get the following error when I run the ps1 file At N:\emby\updatescan.ps1:3 char:46 + $FOLDERS = @(c2257bbd84a4b4bb4f9f4e16cd641326, f137a2dd21bbc1b99aa5c0 ... + ~ Missing argument in parameter list. + CategoryInfo : ParserError: (:) [], ParseException + FullyQualifiedErrorId : MissingArgument Bad Parent ID. It should be a 6 digit number. If the library only has one folder, then this method of getting it doesn't work. I worked around it by adding another folder (an empty temp folder) and then trying again. Link to comment Share on other sites More sharing options...
dcol 165 Posted May 5, 2021 Share Posted May 5, 2021 (edited) 10 minutes ago, jmansell90 said: Bad Parent ID. It should be a 6 digit number. If the library only has one folder, then this method of getting it doesn't work. I worked around it by adding another folder (an empty temp folder) and then trying again. This is the ParentID I found in the URL when I open a library. There are many folders in the library https://www.<hidden>.com/web/index.html#!/videos?serverId=c46368b5a9f946e5b12bc48569c6ad7b&parentId=c2257bbd84a4b4bb4f9f4e16cd641326 Edited May 5, 2021 by dcol Link to comment Share on other sites More sharing options...
Happy2Play 8282 Posted May 5, 2021 Share Posted May 5, 2021 I can assume Libraries and Folders are two different things (technically). Libraries have 32 digit ids and folders have 6 digit ids. Libraries can be made up of multiple folders and or you can have nested folders within a library. Link to comment Share on other sites More sharing options...
dcol 165 Posted May 5, 2021 Share Posted May 5, 2021 So then, how do I find the 6 digit FolderID? Link to comment Share on other sites More sharing options...
Happy2Play 8282 Posted May 5, 2021 Share Posted May 5, 2021 Just now, dcol said: So then, how do I find the 6 digit FolderID? Depends on your structure/library setup but it is in the url. Example http://localhost:8096/web/index.html#!/videos?serverId=5b8c8a53cc0dxxxxb6c0480ef3c918cc&parentId=f137a2dd21bbc1b99aa5c0f6bf02a805 (Library folder view) http://homeserver:8096/web/index.html#!/list/list.html?parentId=35856&serverId=5b8c8a53cc0dxxxxb6c0480ef3c918cc (A actual sub folder via Library folder view) Link to comment Share on other sites More sharing options...
Guest Posted May 5, 2021 Share Posted May 5, 2021 Which means you got to folder view in EMBY as mentioned above. Link to comment Share on other sites More sharing options...
dcol 165 Posted May 5, 2021 Share Posted May 5, 2021 (edited) Folder view still has 32 digit ID using current file structure It seems the subfolders have a 6 digit ID and the parent folder has a 32 digit id. This is my structure Movies\Avatar\avatar.mp4 So I need to do Movies\Movies\Avatar\Avatar.mp4 to get the 6 digit ID Edited May 5, 2021 by dcol Link to comment Share on other sites More sharing options...
Guest Posted May 5, 2021 Share Posted May 5, 2021 FOLDER VIEW Link to comment Share on other sites More sharing options...
Happy2Play 8282 Posted May 5, 2021 Share Posted May 5, 2021 1 minute ago, dcol said: It seems the subfolders have a 6 digit ID and the parent folder has a 32 digit id. This is my structure Movies\Avatar\avatar.mp4 So I need to do Movies\Movies\Avatar\Avatar.mp4 to get the 6 digit ID For what you are trying to accomplish yes you need a subfolder library structure or more then one folder added to a library. Link to comment Share on other sites More sharing options...
dcol 165 Posted May 5, 2021 Share Posted May 5, 2021 (edited) That is the issue, I have no generic sub folders under Movies, just the movie subfolder then the movie under that folder. When I goto folder view, there are only the movie parent folders, then the movie is in that folder. Edited May 5, 2021 by dcol Link to comment Share on other sites More sharing options...
Guest Posted May 5, 2021 Share Posted May 5, 2021 (edited) And yes the first click into folders you get a long ID... Yeah and I am getting a four digit in my movies.. a six in the music.. and the four is the same for all three folders? EDIT: I am getting a Four digit in one of my libraries but it seems to not be following the right folder recognition or structure. Edited May 5, 2021 by Guest Link to comment Share on other sites More sharing options...
dcol 165 Posted May 5, 2021 Share Posted May 5, 2021 Not sure this API approach is going to work. Link to comment Share on other sites More sharing options...
Happy2Play 8282 Posted May 5, 2021 Share Posted May 5, 2021 (edited) This is getting overly complicated. If you want to only scan Movies folder you can (my parentid in example). http://localhost:8096/emby/Items/f137a2dd21bbc1b99aa5c0f6bf02a805/Refresh?api_key={apikey} This scans a library. Edited May 5, 2021 by Happy2Play 1 Link to comment Share on other sites More sharing options...
dcol 165 Posted May 5, 2021 Share Posted May 5, 2021 18 minutes ago, Happy2Play said: This is getting overly complicated. If you want to only scan Movies folder you can (my parentid in example). http://localhost:8096/emby/Items/f137a2dd21bbc1b99aa5c0f6bf02a805/Refresh?api_key={apikey} This scans a library. That is not working either. I get site cannot be reached. I don't think localhost works in my configuration. Also I do not use port 8096 in the network settings Link to comment Share on other sites More sharing options...
Happy2Play 8282 Posted May 5, 2021 Share Posted May 5, 2021 (edited) 13 minutes ago, dcol said: That is not working either. I get site cannot be reached. I don't think localhost works in my configuration. Also I do not use port 8096 in the network settings Have you went to the api and entered the parentid? Look at the returned result and or log entry when you run the command. For me I would put this is a script file and click it to run a scan on that library any time. C:\Windows\System32\curl.exe -X POST "http://homeserver:8096/emby/Items/b1ad04b1336537bcdad1e2f7e35a4d17/Refresh?Recursive=true&MetadataRefreshMode=Default&ImageRefreshMode=Default&ReplaceAllMetadata=false&ReplaceAllImages=false&api_key={enter api key}" -d "" But url is obviously environmental (LANIP, Localhost, WANIP, DDNS) Edited May 5, 2021 by Happy2Play 1 Link to comment Share on other sites More sharing options...
teddybear75 11 Posted May 6, 2021 Share Posted May 6, 2021 (edited) 7 hours ago, Happy2Play said: Have you went to the api and entered the parentid? Look at the returned result and or log entry when you run the command. For me I would put this is a script file and click it to run a scan on that library any time. C:\Windows\System32\curl.exe -X POST "http://homeserver:8096/emby/Items/b1ad04b1336537bcdad1e2f7e35a4d17/Refresh?Recursive=true&MetadataRefreshMode=Default&ImageRefreshMode=Default&ReplaceAllMetadata=false&ReplaceAllImages=false&api_key={enter api key}" -d "" But url is obviously environmental (LANIP, Localhost, WANIP, DDNS) This worked fine for me, both on folder ids and library ids, thanks to everyone involed in this. I only see progress of lib scans in "Home" and not "Dashboard" as i see in a regular scan, but thats no big deal. In my environment, i dit not have to inlcude "c:\windows\system32\curl.exe" i just used "curl" Will have to set up a task in windows task scheduler, not sure if i should set up one job pr scan, or make a bat file with all scans, but i will know after a few trials and errors If i use a bat file, should i include pauses between each line (scan), or can i throw all the commands at once at emby server? Edited May 6, 2021 by teddybear75 Link to comment Share on other sites More sharing options...
jmansell90 4 Posted May 6, 2021 Share Posted May 6, 2021 6 hours ago, teddybear75 said: This worked fine for me, both on folder ids and library ids, thanks to everyone involed in this. I only see progress of lib scans in "Home" and not "Dashboard" as i see in a regular scan, but thats no big deal. In my environment, i dit not have to inlcude "c:\windows\system32\curl.exe" i just used "curl" Will have to set up a task in windows task scheduler, not sure if i should set up one job pr scan, or make a bat file with all scans, but i will know after a few trials and errors If i use a bat file, should i include pauses between each line (scan), or can i throw all the commands at once at emby server? I tested with this yesterday. If you run all immediately after each other, Emby appears to queue them in the same order but run them one at a time which is fine. When I tested with pauses, it just seemed like a waste of time. Maybe a 1s pause if you have dozens of requests to run but otherwise you should be fine. 1 Link to comment Share on other sites More sharing options...
teddybear75 11 Posted May 6, 2021 Share Posted May 6, 2021 (edited) 2 hours ago, jmansell90 said: I tested with this yesterday. If you run all immediately after each other, Emby appears to queue them in the same order but run them one at a time which is fine. When I tested with pauses, it just seemed like a waste of time. Maybe a 1s pause if you have dozens of requests to run but otherwise you should be fine. Thanks, that saves me a bit of time. 5 requests Edited May 6, 2021 by teddybear75 Link to comment Share on other sites More sharing options...
dcol 165 Posted May 6, 2021 Share Posted May 6, 2021 16 hours ago, Happy2Play said: Have you went to the api and entered the parentid? Look at the returned result and or log entry when you run the command. For me I would put this is a script file and click it to run a scan on that library any time. C:\Windows\System32\curl.exe -X POST "http://homeserver:8096/emby/Items/b1ad04b1336537bcdad1e2f7e35a4d17/Refresh?Recursive=true&MetadataRefreshMode=Default&ImageRefreshMode=Default&ReplaceAllMetadata=false&ReplaceAllImages=false&api_key={enter api key}" -d "" But url is obviously environmental (LANIP, Localhost, WANIP, DDNS) Following your script, got it working. Had to fix IP and port in the URL. I put a few of these in one batch file. This will be helpful for libraries I keep on a NAS, which does not recognize Emby's RealTime monitoring. I will add the batch file to the Windows Task Scheduler. Also to clarify, I added a new API key using the name of the library and inserted the API 32 character code it generated into your script. Then used the ParentID from the URL in the library page in your script after /emby/items/ Now I don't need a full scan that often anymore. Changed the scheduled task in Emby to 7 days. The only reason for me to do a full scan anymore is to update any metadata. Libraries that reside on the Emby server use realtime monitoring to update the database, and now with this script, I can update the libraries on remote devices that are unaffected by realtime monitoring. This is the reason I needed something like this. Thanks! 1 Link to comment Share on other sites More sharing options...
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