Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Boxoffice Guide... #133

Merged
merged 8 commits into from
Jul 22, 2018
Merged

Conversation

Pratik-Sanghani
Copy link
Contributor

Feature added as per issue #3
Get List of all Movies running in the Cinemas of Town.
show_scrap_benji

Copy link

@sara-02 sara-02 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@Pratik-Sanghani Please read the Pep8 guide for whitespacing the expression,
https://www.python.org/dev/peps/pep-0008/?#whitespace-in-expressions-and-statements
And update the PR. Al lot of places have no space between variable, and expressions. Please update that.
Apart from that my only concern is the rate limiting on bookmyshow. Hope we don't end up blocking that person's ID from Bookmyshow itself. Please check on that and update the error message accordingly. We can add a sleep between 2 consecutive bookmyshow requests. A simple Error may not be very helpful.
Apart from that, the logic seems correct.

windows/benji.py Outdated
for friend in tweepy.Cursor(api.friends).items():
print("\nName: ", json.dumps(friend.name), " Username: ", json.dumps(friend.screen_name))

elif len(link[-1]) == "twitter":
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is logically not correct len(link[-1]) will give you an integer, which cannot be equal to a string value.
What was the intended change? I would prefer it be reverted to the old if condition.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry, it was a mistake.

windows/benji.py Outdated
#Box Office Status
elif link[-1] == "boxoffice":
try:
url="https://in.bookmyshow.com/"+ link[0] +"/movies/nowshowing"
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is there any rate limiting on the bookmyshow.com?

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should add a disclaimer that Benji assumes the location to be in India.
Book my show works in Indonesia | UAE | Sri Lanka as well.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think that there is any rate limiting on the bookmyshow.com.
I used only simple web scrapping. And we don't have to login into bookmyshow.com Account.
I'll write that this feature is only available within Indian Region.

windows/benji.py Outdated
elif link[-1] == "boxoffice":
try:
url="https://in.bookmyshow.com/"+ link[0] +"/movies/nowshowing"
r= requests.get(url)
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

r =  requests.get(url)

Proper spacing.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok. Thanks.

@sara-02
Copy link

sara-02 commented Jul 20, 2018

@Pratik-Sanghani I will review the PR again, once you have addressed the Python styling issue and have the rate-limiting figured out.
This will be a nice feature to have, let us get it through. :)

@Pratik-Sanghani
Copy link
Contributor Author

Please review the PR and let me know if changes are required. :) @sara-02

Copy link

@sara-02 sara-02 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Few changes in logic to reduce avoid using extra variables and help represent the info better.
Also, please clarify the change for the twitter if condition. The change looks unnecessary.

for friend in tweepy.Cursor(api.friends).items():
print("\nName: ", json.dumps(friend.name), " Username: ", json.dumps(friend.screen_name))

elif link[-1] == "twitter":
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I still don't understand what was wrong with the previous if condition, you are anyway checking the link[-1]==twitter again in the nested if condition.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

previous if condition was giving me Error List Index Out of Range : as per below:
screenshot 68

Instead of generating issue , i Solved it.

end = str(i).index('data-event-code')
data = str(i)[start+18 : end-2]

if data == "false":
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

One doubt, when we are hitting the now_showing URL then why do we have a list of coming soon movies? Should we not filter only the ones that are currently running?
Or maybe display the 2 list sepratetly?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It Displays Movies for which Advance Bookings are Opened. And Releasing on next Weekends.

if data == "true":
show_status_list.append("Coming Soon...")

Tags_list = []
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Instead of using 3 lists tags list, name list and show status list, you can create a dictionary of items with the name being the key and the tags being the value, and get rid of the status list altogether
Something like:

{"Now showing": {name: taglist}, {name2:taglist},
"Coming soon": {name3:taglist},{name4:taglist}
}

Also, the tag list for each name should be a set, not a list, t avoid duplicate tags.
Not that lists are wrong, but a dict will be a better presentation of this data. WDYT?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I can't do it , though status and names are scraped with different levels of the soup.

speak.runAndWait()
cntr = len(Name_list)
print("----------------------------------------------")
print(link[0].capitalize())
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should differentiate printing the names which are currently showing from the coming soon ones, something like

Print("Now showing")
Print(iterate through dict["Now showing"]
Print("Coming Soon")
Print(iterate through dict["Coming Soon"]


soup_level2 = []
show_status_list = []
shows_list = soup.find_all('div', attrs={'class': 'card-container wow fadeIn movie-card-container'})
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We can actually get rid of the show_list dict, check the suggestion below

@the-ethan-hunt
Copy link
Owner

@sara-02 are we ready to merge this?

@sara-02
Copy link

sara-02 commented Jul 21, 2018

@the-ethan-hunt Yes

@the-ethan-hunt the-ethan-hunt merged commit aa4b6dc into the-ethan-hunt:master Jul 22, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants