kjp4756 41 Posted February 2, 2015 Share Posted February 2, 2015 I'm currently using plex in a jail on freenas 9.3. Plex doesn't support auto updating the library on freebsd so I have came up with a work around. From what I can tell, mediabrowser server on freebsd has the same issue; no library auto scan on freebsd. I use a program called fswatch to monitor my media directory. When there is a change detected in the filesystem, I use wget to hit a URL on my plex server to initiate the update. Is there a similar thing I can do with mediabrowser? The ideal way would be initiate a scan via a shell program. Thanks Link to comment Share on other sites More sharing options...
pseudoheld 3 Posted February 3, 2015 Share Posted February 3, 2015 +1 for this! Link to comment Share on other sites More sharing options...
ebr 14947 Posted February 3, 2015 Share Posted February 3, 2015 Look at the API documentation. There is a call to start a library scan but you will need to authorize it by creating a key in the server and then providing that in your url. Link to comment Share on other sites More sharing options...
kjp4756 41 Posted February 3, 2015 Author Share Posted February 3, 2015 Thanks I did eventually find it in the API documentation last night. I didn't know about needing an API key. I do have a bit of a problem now. I can't seem to find the api documentation link on the server admin page. I found it yesterday but now I can't today. Can someone refresh my memory on where to find the api documentation? I went through every section and its nowhere to be found. Thanks. Link to comment Share on other sites More sharing options...
Sven 136 Posted February 3, 2015 Share Posted February 3, 2015 You can find some information on this page https://github.com/MediaBrowser/MediaBrowser.ApiClient Link to comment Share on other sites More sharing options...
kjp4756 41 Posted February 3, 2015 Author Share Posted February 3, 2015 Ok I'm making some progress. A POST request to http://localhost:8096/mediabrowser/Library/Refresh?api_key=986c63e561b9489f8d3042b57e898161 gives me "User does not have admin access". How do I give that api key admin access? I can't seem to figure that out. Link to comment Share on other sites More sharing options...
ebr 14947 Posted February 3, 2015 Share Posted February 3, 2015 That's a good question. @@Luke Link to comment Share on other sites More sharing options...
kjp4756 41 Posted February 3, 2015 Author Share Posted February 3, 2015 I think I need to authenticate a user first. I created a hidden user called scanmedia. I gave the user admin access and a password. I try to authenticate like this: curl -X POST -d '{"Password":"Pass1Word"}' -H "Content-Type:application/json" http://localhost:8096/mediabrowser/Users/ffa46d82a7bc896bdef22b85d5ad14c7/Authenticate?api_key=986c63e561b9489f8d3042b57e898161 I get a response with "Invalid username or password". Link to comment Share on other sites More sharing options...
ebr 14947 Posted February 4, 2015 Share Posted February 4, 2015 The password needs to be an sha1 hash. We never send clear text passwords over the wire. Link to comment Share on other sites More sharing options...
kjp4756 41 Posted February 4, 2015 Author Share Posted February 4, 2015 (edited) Thanks. I figured it was hashed some how. MD5 didn't work. Didn't think of sha1. Going the authentication route is probably going to be over my head. I'm trying to get this to work from a shell script. I am able to initiate a library scan if I use the api key for my admin account's web dashboard. That seems to work until I log out of the web ui. UPDATE: I am able to authenticate using an SHA1 hash of the password. Once I authenticated I was issues a new api_key. That's not what I want. I want to be able to use the api key I manually generated to update the library. There should be an option some where to grant certain rights to certain api keys. Edited February 4, 2015 by kjp4756 Link to comment Share on other sites More sharing options...
Draztik 0 Posted September 28, 2015 Share Posted September 28, 2015 Is there a way that can be utilizied in the same manor as the couchpotato notification via the API key using curl? https://github.com/RuudBurger/CouchPotatoServer/blob/37fb6e0fe6780e6a291ea90d87cc1e8c17896022/couchpotato/core/notifications/emby.py I would also like to update the library using a script. Link to comment Share on other sites More sharing options...
kjp4756 41 Posted September 28, 2015 Author Share Posted September 28, 2015 Here is how I initiate a library scan using curl via a bash script. It's kind of messy but it works for me. I use it with the file system monitor fswatch to initiate a scan. I put everything in to variables so it's easier to set the configuration options. I have a hidden emby user called scanmedia which this script uses. Deviceid is a UUID generated with uuidgen. The password is a blank password. The API requires sha1 encoded passwords. The value I have for password is the sha1 value of a blank password. I also have an init script used to start and daemonize the script. I can pose that if there is interest. Here is the main script. #!/usr/local/bin/bash PATH="$PATH:/usr/local/bin" TriggeredDelay=180 MediaLocation="/media/Movies /media/TV" client="scanmedia" device="localhost" deviceid="86B59261BCC841C3BB74A24C802E27FD" userid="ffa46d82a7bc896bdef22b85d5ad14c7" username="scanmedia" password="da39a3ee5e6b4b0d3255bfef95601890afd80709" while :; do fswatch --print0 --one-event --recursive $MediaLocation | while read -d '' event; do sleep $TriggeredDelay ApiKey="$(curl -s -H "Authorization: MediaBrowser Client=$client, Device=$device, DeviceId=$deviceid, Version=1.0.0.0, UserId=$userid" -d "username=$username" -d "password=$password" 'http://127.0.0.1:8096/users/authenticatebyname?format=json' | python -m json.tool | grep 'AccessToken' | sed 's/\"//g; s/AccessToken://g; s/\,//g; s/ //g')" curl -d 'StartScheduledTask' "http://localhost:8096/mediabrowser/ScheduledTasks/Running/2d67d886717cdade18d9640d4ebbb9cb?api_key=$ApiKey" done done 2 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