imdbpy rating data missing - python-2.7

i have a question about the imdbpy module for python, for some reason i can't retrieve some data about tv shows even though they exist on the imdb.com website.
for example if i use this code:
from imdb import IMDb
i = IMDb()
s = i.search_movie('killjoys')
m = i.get_movie(s[0].movieID)
print m.get('rating')
the result is None even though on the imdb.com it's available
so what should i so here? and thanks for the help :)

Consider two things:
the Movie objects in the result list from a query contains only limited data (the ones you can see from a search on the web).
for a series, the "combined" page doesn't show the rating.
So, in your example, the first result would refer to imdbID 3952222.
You can update the (main) information using:
i.update(m)
but again this would only add main information, by default (the ones from the http://www.imdb.com/title/tt3952222/combined page)
So, you need to also parse the "vote details" page with:
i.update(m, ['main', 'vote details'])
(or just 'vote details' if you don't need to fetch and parse the main details).

the solution i found is to use a different library called omdb
import omdb
tv_show_name = "hannibal"
movie = omdb.get(title=tv_show_name, fullplot=True, media_type="series")
rating = movie.imdb_rating
there you go this might help someone someday ;)

Related

Django Dynamic Form Selection

I want to achieve Dynamic form selection using Django
Vehicle_Type_Choices = (
(‘car’,’Car’),
(‘bike’,’Bike’),
(‘auto’,’Auto’),
)
vehicle_type = models.CharField(max_length=10,choices=Vehicle_Type_Choices)
Now I have 3 different forms (I.e CarForm, BikeForm, AutoForm) for Vehicle specifications based on the type of vehicle selected.
Now, I want if the user selects the Choice Car above, I want to display the CarForm (or) if the user selects Bike, then BikeForm has to be displayed for further filling of Data.
Please Help me to achieve the above scenario .
Thanks and regards
One of the most simple ways would be to just go to another page after a selection has been made (i.e. wizard type), anything else would need lots of javascript.
There is one package that can do form splitting, but never use it and not sure if/how can help in your situation, but I guess its worth taking a look: django-formtools

Musicbrainz querying artist and release

I am trying to get an artist and their albums. So reading this page https://musicbrainz.org/doc/Development/XML_Web_Service/Version_2 i created the following query to get Michael Jackson's albums
http://musicbrainz.org/ws/2/artist/?query=artist:michael%20jackson?inc=releases+recordings
My understanding is to add ?inc=releases+recordings at the end of the URL which should return Michael Jackson's albums however this doesnt seem to return the correct results or i cant seem to narrow down the results? I then thought to use the {MBID} but again thats not returned in the artists query (which is why im trying to use inc in my query)
http://musicbrainz.org/ws/2/artist/?query=artist:michael%20jackson
Can anyone suggest where im going wrong with this?
You're not searching for the correct Entity. What you want is to get the discography, not artist's infos. Additionally, query fields syntax is not correct (you must use Lucene Search Syntax).
Here is what you're looking for:
http://musicbrainz.org/ws/2/release-group/?query=artist:"michael jackson" AND primarytype:"album"
We're targeting the release-group entity to get the albums, searching for a specific artist and filtering the results to limit them to albums. (accepted values are: album, single, ep, other)
There are more options to fit your needs, for example you can filter the type of albums using the secondarytype parameter. Here is the query to retrieve only live albums:
http://musicbrainz.org/ws/2/release-group/?query=artist:"michael jackson" AND primarytype:"album" AND secondarytype="live"
Here is the doc:
https://musicbrainz.org/doc/Development/XML_Web_Service/Version_2/Search
Note that to be able to use MB's API you need to understand how it is structured, especially, the relations between release_group, release and medium.

How do I save the web service response to the same excel sheet I extracted the data from?

For example:
The given sample HP Flights SampleAppData.xls and using the CreateFlightOrder, we can link the data to the test functions and get a OrderNumber and Price response from the Web Service. And in the SampleAppData.xls Input tab, we can see that there is a empty column of OrderNumber.
So here is my question, is there any ways that I can take the OrderNumber response and fill the empty column in SampleAppData.xls?
My point to do this is because, let's say I have many test cases to do and will take days, and today I do this certain test and I would need the result of today for the next day's test.
Although I know that the responses are saved in the result but it beats the point of automation if I am required to check the response for each and every test cases?
Yes of course you can. There are a number of ways to do this. The simplest is as follows.
'Datatable.Value("columnName","sheetName")="Value"
DataTable.Value(“Result”,”Action1”)=“Pass”
Once you have recorded the results in the Datasheet, your can export them using
DataTable.ExportSheet("C:\SavePath\Results.xls")
You can write back the response programatically , if you already imported mannually .
You can use GetDataSource Class of UFT API , it will work like this lets say you imported excel from FlightSampleData.xls, and named it as FlightSampleData, you have sheet, accessing the sheet will be like below:
GetDataSource("FlightSampleData!input).Set(ROW,ColumnName,yourValue);
GetDataSource("FlightSampleData!input).Get(ROW,ColumnName);
for exporting you can use ExportToExcelFile method of GetDataSourse class after your test run . Please let me know if you have any furthur question about this.

Loading data from associated model in same query in rails

Basically, I have a Listing model, where each listing has a country id. I need the country name in my search results view. I know I can do #listing.country.name, but this performs an extra query for each listing in my search results. I'm using Thinking Sphinx, and in my controller I have
#listings = Listing.search(#ts_params).page(page_num).per(limit)
I have tried adding .includes(:countries) and variations thereof but no luck.
What's the best way to go about this? I want the country data to be fetched in the same query as the listings.
I have exactly the same issue with listing images - it is performing an extra query for every listing to find the image, when surely it can be done in one with joins.
Are you trying to eager load the associated model (to avoid an N + 1 query problem), or are you trying to load the associated model into fields on the parent model?
If it's the former, you're probably better off forgetting about :select and instead of :joins using:
ts_params[:sql][:include] = :countries, :listing_images
Now you should be able to call listing.countries and listing.listing_images to access child models, as normal.
Thinking Sphinx provides functionality to eager load associated entities, so for eager loading we don't need to add [:sql]. Following is the way to do this.
For eager loading associated entities using sphinx.
ts_params[:include] = [:country, :listing_image]
I managed to solve this using the :sql hash provided by Thinking Sphinx. I now have the following:
#ts_params[:sql][:joins] = "INNER JOIN countries ON countries.id = listings.country_id INNER JOIN listing_images ON listing_images.listing_id = listings.id"
#ts_params[:sql][:select] = "listings.*, countries.name as country_name, listing_images.image as image_name"
This is correctly retrieving the country name and image name, but I still have a bit of work to do in making it work with the images - I think that will deserve its own question!
Current v4 syntax is:
Article.search :sql => {:include => :user}
Ref: https://freelancing-gods.com/thinking-sphinx/v4/searching.html

Django Spreadsheet Application

I am in the making of a Django application where you will be able to upload an excel spreadsheet file and have it inserted into the application. But I sorta got the importing sorted out.
What I need is a way to store the values dynamically, I basicly need X number of fields for each row, with each three possible types.
These would be:
Boolean
String
Number
How would I go about doing so?
Let's say I have some models that contains this information:
A spreadsheet with a name, and some "header"-cells that will indidate which fields (and their name) that belong to that spreadsheet (but dynamically expanding).
A row that can have multiple cells, each with a type of either a boolean, a string or a number.
An example could be like this:
Spreadsheet 100
name (string)
city (string)
religious? (boolean)
phonenumber (number)
and then I need to pair the cells underneath with the appropiate header, like this:
row
name = "Bob Curious"
city = "New York"
religious = "Yes"
phonenumber = "888 888 888"
I hope that explains it good enough, if not, please go ahead and ask for anything you might like explained.
Thanks in advance! :)
This post is pretty old so I'm not sure whether you still need help with your issue, but I've found xlrd to be an excellent tool for scraping spreadsheet data. I would suggest investigating this package further.
Maybe others would like to hear more about the solution for this question. My plugin django-excel would help with excel data import into and export from one or more django models. What's more, the plugin provides one programming interface to handle data in ods(using odfpy or ezodf), xls(using xlrd), xlsx(using openpyxl) and csv formats. I hope it may help you.