Oconnor 0 Posted October 10, 2017 Share Posted October 10, 2017 (edited) Hello, Hope this is the right forum! I've been trying to search google and the forums for any topics that could help but came back empty. I'm trying to use a python script to get 4 or 5 of the recently added media - with information about that episode. (Name, poster or other img, episode name, episode number, season number etc).Currently I am doing this with Sonarr - but that often means I get duplicate results because I download a better version after or something like that. Here is my current script when using Sonarr: apikey = '****' baseurl = 'http://10.0.0.***:****/' url = '%sapi/history?sortkey=date&sortDir=desc&pageSize=4&filterKey=eventType&filterValue=3&apikey=%s' % (baseurl, apikey) urlresult = urllib.urlopen(url) parsed_json = json.loads(urlresult.read()) item = 0 + a lot more code to sort it.After that I display it on my custom webpage.Is there anyway to do this with Emby? And maybe if I click it, it can redirect me to emby and play the file?I'd appreciate any help you can give. Best regards. EDIT: I managed to solve this by using postman to create my request. Great app. Got another question tho: Is it possible to display both watched and unwatched items? as in: isPlayed=false&TRUE Edited October 11, 2017 by Eirik226 Link to comment Share on other sites More sharing options...
Luke 37135 Posted October 11, 2017 Share Posted October 11, 2017 Hi there @, welcome. Have you taken a look at the wiki on our api? https://github.com/MediaBrowser/Emby/wiki Let us know if this helps. Thanks. Link to comment Share on other sites More sharing options...
Oconnor 0 Posted October 11, 2017 Author Share Posted October 11, 2017 Hi there @, welcome. Have you taken a look at the wiki on our api? https://github.com/MediaBrowser/Emby/wiki Let us know if this helps. Thanks. Hey! Yeah I have been using that a lot to see what's possible. As I mentioned I actually got it to work - but I'd love to display both watched and unwatched shows (maybe movies as well, but not so important) But I can't figure out the command for: isPlayed=false Is it possible to have it show isPlayed=falseANDtrue? And if isPlayed=true - add the watched marker on the picture? Here is what I have so far (And this works): import requests import json url = "http://10.0.0.90:8096/Users/****/Items/Latest" querystring = {"IncludeItemTypes":"Episode","Limit":"4","IsPlayed":"false"} headers = { 'x-mediabrowser-token': "****", 'x-emby-authorization': "MediaBrowser", 'userid': "****", 'client': "Windows", 'device': "W10", 'deviceid': "02004C4F4F50", 'version': "1.0.0", 'cache-control': "no-cache", 'postman-token': "****" } response = requests.request("GET", url, headers=headers, params=querystring) #print(response.text) parsed_json = json.loads(response.text) item = 0 print parsed_json for job in parsed_json: item = item + 1 itemnum = str(item) seriesname = job['SeriesName'] episodename = job['Name'] seriesID = job['SeriesId'] seasonInt = job['ParentIndexNumber'] season = str(seasonInt) episodenumInt = job ['IndexNumber'] episodenum = str(episodenumInt) overview = '' picture = '<img id="testis" src="http://10.0.0.90:8096/emby/Items/' + seriesID + '/Images/Banner?" style="height:75px;"></img><div id="download_' + itemnum + '" style="width:405px; height:auto;"><span style="font-size: 16px;" id="Download_' + itemnum + '_episodename"></span></br><span>S </span><span id="seasonNum_' + itemnum + '"></span><span> - E </span><span id="episodeNum_' + itemnum + '"></span><div id="episode_info_'+itemnum+'" style="white-space: pre-line; font-size: 12px;">Filler this episode is about filler</div></div>' print seriesname + ' - ' + episodename + ' (' + season + ' - ' + episodenum + ')' print picture *** = I have info there, just not sure if it's safe to show it around. this part of the script is where I upload it to my website, not really needed to show it. So basically what i'm trying to do is: 1. Show 4 latest added media (tv-shows) 2. Show both watched and unwatched shows (That way I won't have the same show up constantly because I don't really watch it) 3. If watched add watched marker (I saw on the wiki this should be possible) 4. Maybe add information about episode or a click link to go directly to that episode on Emby (I think the last solution is best) But I am currently stuck on step 2 - making both watched and unwatched latest added media show up. Link to comment Share on other sites More sharing options...
Luke 37135 Posted October 11, 2017 Share Posted October 11, 2017 yea if you want both then just omit the IsPlayed filter. Link to comment Share on other sites More sharing options...
Oconnor 0 Posted October 11, 2017 Author Share Posted October 11, 2017 yea if you want both then just omit the IsPlayed filter. @@Luke - I've tried that, does not seem to do the trick. I think it default to isPlayed=false if you don't have it in the URL Link to comment Share on other sites More sharing options...
Luke 37135 Posted October 11, 2017 Share Posted October 11, 2017 That's not true. Unfortunately we probably don't have as many examples as we should in our wiki, but i would suggest using the chrome debugger to watch the network requests for the built-in web app. let us know if this helps. thanks. Link to comment Share on other sites More sharing options...
Oconnor 0 Posted October 11, 2017 Author Share Posted October 11, 2017 That's not true. Unfortunately we probably don't have as many examples as we should in our wiki, but i would suggest using the chrome debugger to watch the network requests for the built-in web app. let us know if this helps. thanks. @@Luke - Well I've tried to leave it out and the result comes back same as ifPlayed=false - I'll try to look a bit further into it myself. It's no problem, keeping a wiki this big up to date is a big task. I'll try to use the debugger and see if I can learn anything from that, but I did try it in the past with little luck. I'll see what I can get out of it this time, thanks! Link to comment Share on other sites More sharing options...
Oconnor 0 Posted October 11, 2017 Author Share Posted October 11, 2017 I think i've solved this now - took me a few hours of failing. I ended up with redoing it all and not using latest media as my HTTP request but items instead - this allowed me to show both watched and unwatched shows, add marker if watched etc.Next step is to add movies to the mix as well, but not really sure if i'll do that.Thanks for all the help, if needed I can post the code if anyone is interested. Link to comment Share on other sites More sharing options...
Luke 37135 Posted October 12, 2017 Share Posted October 12, 2017 Right ok, my mistake. if you use the /latest endpoint then it will take into account user profile settings, so that's why. Link to comment Share on other sites More sharing options...
Oconnor 0 Posted October 12, 2017 Author Share Posted October 12, 2017 Right ok, my mistake. if you use the /latest endpoint then it will take into account user profile settings, so that's why. Yeah I figured as much myself after browsing the Emby latest page - but could not find the settings to change it, so I ended up with using items instead - thanks for the help anyway You helped me in the right direction. Link to comment Share on other sites More sharing options...
Luke 37135 Posted October 12, 2017 Share Posted October 12, 2017 Where did you look for the settings? Link to comment Share on other sites More sharing options...
Sludge Vohaul 22 Posted October 16, 2017 Share Posted October 16, 2017 @ Regarding code in #3. picture = '<img id="testis" src="http://10.0.0.90:8096/emby/Items/' + seriesID + '/Images/Banner?" style="height:75px;"></img><div id="download_' + itemnum + '" style="width:405px; height:auto;"><span style="font-size: 16px;" id="Download_' + itemnum + '_episodename"></span></br><span>S </span><span id="seasonNum_' + itemnum + '"></span><span> - E </span><span id="episodeNum_' + itemnum + '"></span><div id="episode_info_'+itemnum+'" style="white-space: pre-line; font-size: 12px;">Filler this episode is about filler</div></div>' Do yourself a favour and use a "templating engine". My Python days lie almost 2 decades back, so I am a Python newbie, but I was able to create a show-audiobook-metadata-website (with css, js and all the crap) through a remote session using FreeBSD's vi editor last year. The templating engine I used is Bottle. I liked it as far as one can like web development... -- sv Link to comment Share on other sites More sharing options...
Oconnor 0 Posted October 19, 2017 Author Share Posted October 19, 2017 I actually solved it using HTTP request and python scripts. But thanks for replying! 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