Coder Social home page Coder Social logo

scorer.py's Introduction

scorer.py

A simple python script to fetch cricket scores and send notifications.

alt tag

Features

  • Allows you to choose from concurrent matches
  • Change choice by arrow keys

Requirements

  • beautifulSoup4
  • requests
  • python2 only

Installation

sudo python setup.py install [Make sure you are using python2]

Usage

scorer

Todo

  • Use argparse to add some command line arguments like debug etc.
  • Use the pushbullet api and allow users to get notifications on their devices using pushbullet.
  • Use telegram api to make something similar to Natasha on hike.
  • Use the matchid from current url and use the cricinfo api to get other notification like overs, batsmen playing, and other such stats when there is no change in the score.
  • create a command line option to run this notification system as a GUI.
  • Use twitter api to get the latest tweets based on match hastags and use it to feed the notifications when there is no score change.
  • Use a configuration file
  • Add documentation
  • Add an option for proxy server host and port That's all I could think for now.

NOTE: Works on Linux only. For OS X version, check this project.

scorer.py's People

Contributors

asdofindia avatar avinassh avatar devjon avatar harsham4026 avatar kavirajk avatar nirmalvp avatar srivallabh avatar surajssd avatar thefourtheye avatar tushar-rishav avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

scorer.py's Issues

Add a way to pass command line arguments to scorer

Would like to use command line arguments to pass to the script:
The options could be the following:

--delay No of seconds to delay before notifications
--config-file Path to config file
--debug Debug flag
--log-file Path to log file
--pushbullet Would you like to use pushbullet API
--api-key If yes what's your API key?
--score-change Only get notified when there is a change in the score or a wicket falls?

--boundaries Only get notified when a boundary is hit?
--sixes Get notified when sixes are hit.
Can be more options. Please comment if you find any new options.

TypeError: unsupported operand type(s) for +: 'NoneType' and 'str'

screenshot 42
screenshot 44

Hello, so i came a cross the mentioned error on
fetch_scores.py", line 86, in getLastestScore titleToDisplay = battingTeamName + " vs " + bowlingTeamName TypeError: unsupported operand type(s) for +: 'NoneType' and 'str'

i did a little debugging and notice lets take the game Andhra 321/9 * v Bengal 300/10, playingTeams value returns {'1592': None, '1623': None} which means battingTeamName = None and titleToDisplay = battingTeamName + " vs " + bowlingTeamName will cause the error above.

So even if a proper formating is done, lets say titleToDisplay = "{} vs {}".format(battingTeamName, bowlingTeamName), it will solve the error but displayed end result (in this case title:None vs None) will be useless.

NOTE:i am currently running the script on windows machine using some work arounds(also planning to share the ported code(to be discussed :)}

Addition of a config file to store default options?

As @neo1691 suggested that we should add command line options to the script. It is a good idea but I think we should mention all default values in a config file located at the app dir or /etc/ something.

We can write a sample file like below.

/***** /etc/scorer/config *****/
[config]
config_file = "/path/to/config/file"

[log]
log_file = "/path/to/log/file"
log_level = "debug"

[app]
delay = 5

[secret]
api_key = 'xxxxxxxxx'
access_token = "xxxxxxxxxxx"

This way it not only makes code cleaner but also makes it easy to change the default values (using ConfigParser) through command line options or code itself.

What do you guys think about the config file option?

requests.exceptions.ConnectionError

Traceback (most recent call last):
File "scorer.py", line 44, in
r = requests.get(url)
File "/usr/lib/python2.7/dist-packages/requests/api.py", line 55, in get
return request('get', url, *_kwargs)
File "/usr/lib/python2.7/dist-packages/requests/api.py", line 44, in request
return session.request(method=method, url=url, *_kwargs)
File "/usr/lib/python2.7/dist-packages/requests/sessions.py", line 455, in request
resp = self.send(prep, *_send_kwargs)
File "/usr/lib/python2.7/dist-packages/requests/sessions.py", line 558, in send
r = adapter.send(request, *_kwargs)
File "/usr/lib/python2.7/dist-packages/requests/adapters.py", line 378, in send
raise ConnectionError(e)
requests.exceptions.ConnectionError: HTTPConnectionPool(host='static.cricinfo.com', port=80): Max retries exceeded with url: /rss/livescores.xml (Caused by <class 'socket.gaierror'>: [Errno -2] Name or service not known)

Lot of hardcoding in the current version

The current version of latest score gets a lot of hardcoding. The code currently breaks when there is no international match going on live.

The hardcoding in the json is the culprit.

I have fixed the code partially, will release the stable version alongwith the proper code structure according to python standards.

No JSON objects could be decoded

Getting the mention error.
I ran the script when no matches were available. That's all i think might be the cause for this.

Fetching matches..
INFO:root:Sending requests
INFO:urllib3.connectionpool:Starting new HTTP connection (1): static.cricinfo.com
DEBUG:urllib3.connectionpool:Setting read timeout to None
DEBUG:urllib3.connectionpool:"GET /rss/livescores.xml HTTP/1.1" 200 2657
INFO:urllib3.connectionpool:Starting new HTTP connection (1): www.espncricinfo.com
DEBUG:urllib3.connectionpool:Setting read timeout to None
DEBUG:urllib3.connectionpool:"GET /netstorage/656493.json HTTP/1.1" 302 0
DEBUG:urllib3.connectionpool:Setting read timeout to None
DEBUG:urllib3.connectionpool:"GET /ci/engine/match/656493.json?view=live;wrappertype=live;zakamai=1 HTTP/1.1" 200 21863
Traceback (most recent call last):
File "scorer.py", line 77, in
parsingJson = json.loads(dataFromJSONUrl.text)
File "/usr/lib/python2.7/json/init.py", line 338, in loads
return _default_decoder.decode(s)
File "/usr/lib/python2.7/json/decoder.py", line 366, in decode
obj, end = self.raw_decode(s, idx=_w(s, 0).end())
File "/usr/lib/python2.7/json/decoder.py", line 384, in raw_decode
raise ValueError("No JSON object could be decoded")
ValueError: No JSON object could be decoded

Need help with setuptools:

I have made some changes to the structureCode branch and now I have added a setup.py to it.

Doing python setup.py build build's the project and creates a build directory in the project root folder and sudo python setup.py install installs the project somewhere in the path of the system.

But I have no idea how to run the app from anywhere else after installing.

Someone with prior experience with setuptools might be able to help me out here.

Thank you.

Code breaks when there is no notification daemon working.

Hi had a very interesting scenario on an ubuntu box where somehow the notification daemon was disabled. even notify-send was not working. The code failed with the following error:

Traceback (most recent call last):
File "/usr/local/bin/scorer", line 9, in
load_entry_point('scorer==0.1', 'console_scripts', 'scorer')()
File "/usr/local/lib/python2.7/dist-packages/scorer-0.1-py2.7.egg/scorer/app.py", line 38, in main
notify.popUpMessage(title, score)
File "/usr/local/lib/python2.7/dist-packages/scorer-0.1-py2.7.egg/scorer/notification.py", line 8, in popUpMessage
pynotify.Notification(title, message, "dialog-information").show()
gio.Error: Could not connect: Connection refused

Need to handle this error better!

Re:workflow of the events in the fetching the code

HI,

I am new to Python and Github as well.:P

Request you to put up a flow of events(interactions) as I am planning to implement the functionality using JS and understand the present code in this project.

P.S.: I am unsure if i can put such requests in issues and found this a way to put up this request. EXCUSE ME for this.

Need more documentation for the code

I have no experience with either rst or sphinx, but if someone can write documentation for all the modules and their functions then it would be great for the future developers to contribute back to the project.

Also I would like to add in the developer guidelines wiki that future contributions need to be submitted with proper documentation.

No score in notification

With the latest merge from @asdofindia this bug has been introduced in the code base.

a

I will add logging to the code to see what's happening in the code.

Need more wiki for this project.

I need to write wiki pages describing the use of this project.
One page to describe how to install this script (After packaging it with pip)
One page to layout developer guidelines.
One page for command line flags. (After the implementation of optparse/argvparse etc)

And more.

suggestion to use proxy and also to specify fetch frequency

It's better to have fetching data from proxy server if cric info is blocked.

One of the todo mentions, usage of argparse. It can also have an argument which takes time in seconds, which specifies how often script should check for new results.

I am already doing these in OS X version.

  • for proxy link, you can use this: http://anonymouse.org/cgi-bin/anon-www.cgi/http://static.cricinfo.com/rss/livescores.xml
  • for argparse usage example, Line 17-25

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.