Beispiel #1
0
def getLiveMatches(all_matches):
    matches = sports.all_matches()
    basketball = filterLiveMatches(matches['basketball'])
    baseball = filterLiveMatches(matches['baseball'])
    all_matches['games'] = basketball + baseball
    print("getLiveMatches")
    print(all_matches)
Beispiel #2
0
    def test_match(self):
        self.assertIsNotNone(self.hockey_match)
        self.assertEqual(str(self.hockey_match),
                         'Pittsburgh Penguins 2-0 Nashville Predators')
        self.assertEqual(repr(self.hockey_match),
                         'Pittsburgh Penguins 2-0 Nashville Predators')

        self.assertIsNotNone(sports.all_matches())
Beispiel #3
0
def respond(voice_data):
    if "football" in voice_data:
        speak.Speak("is it today match, odds , team or team points")
        if "today match" in voice_data:
            all_matches = sports.all_matches()
            football = all_matches[sports.FOOTBALL]
            speak.Speak(football)
        if "odds" in voice_data:
            speak.Speak("which match odds are you looking for")
            sports = sports.get_sport(sports.FOOTBALL)
            speak.Speak = (sports.ODDS, odd)
        if "odds" in voice_data:
            speak.Speak("which match points are you looking for")
            sports = sports.get_sport(sports.FOOTBALL)
            print = (sports.POINTS, points)
        else:
            if "team" in voice_data:
                speak.Speak("which team")
                voice_data = ''
                football = sports.get_team(sports.FOOTBALL, team)
                speak.Speak(football)
    else:
        if "tennis" in voice_data:
            speak.Speak("is it today match or player name or odds")
        if "today match" in voice_data:
            all_matches = sports.all_matches()
            tennis = all_matches[sports.TENNIS]
            speak.Speak(tennis)
        if "odds" in voice_data:
            speak.Speak("which match odds are you looking for")
            sports = sports.get_sport(sports.TENNIS)
            speak.Speak = (sports.ODDS, odd)
        else:
            if "player name" in voice_data:
                speak.Speak("which player")
                print("--------------")
                team = input("----")
                print("--------------")
                tennis = sports.get_team(sports.TENNIS, team)
                print(tennis)

    time.sleep(1)
    while 1:
        voice_data = record_audio()
        respond(voice_data)
Beispiel #4
0
def get_matches():
    all_matches = sports.all_matches()
    # print(type(all_matches)) = 'dict'
    filtered_sports = {}
    for keys, values in all_matches.items():
        matches = str(values).split(',')
        filtered_matches = [x.split("0-0") for x in matches if "0-0" in x]
        filtered_sports[keys] = filtered_matches

    return clean_dict(filtered_sports)
Beispiel #5
0
    nse = Nse()

    stocks = {
        "ADANIPORTS": 284.95,
        "HINDALCO": 152.30,
        "ONGC": 279.70,
        "SBIN": 259.70
    }

    qty = {
        "ADANIPORTS": 20,
        "HINDALCO": 20,
        "ONGC": 20,
        "SBIN": 20
    }

    stock = nse.get_quote(str(company.get()))
    stock1Close = stock['closePrice']

    n = str(stock)

    x = sports.all_matches()
    c = x[sport.get()]
    m = str(c)

    notifier = ToastNotifier()
    notifier.show_toast(sport.get(), m, duration=int(Notf_t.get()))
    notifier.show_toast(company.get(), n, duration=int(Notf_t.get()))

    time.sleep(int(Int_t.get()))
Beispiel #6
0
 def show_games(self):
     matches = sports.all_matches()
     match_info = (matches['baseball'] + matches['basketball'])
     return str(match_info)
    "rugby-league": sports.RUGBY_L,
    "rugby-union": sports.RUGBY_U,
    "soccer": sports.SOCCER,
    "tennis": sports.TENNIS,
    "volleyball": sports.VOLLEYBALL,
}

argumentList = sys.argv
if len(argumentList) < 2:
    print("Please enter a sport")
    sys.exit()

if len(argumentList) == 2:
    sport = argumentList[1].lower()
    if sport in sports_dict.keys():
        all_matches = sports.all_matches()[sport]
        for match in all_matches:
            print(match)
    else:
        print("This sport details are not supported yet")

if len(argumentList) == 3:
    sport = argumentList[1].lower()
    if (sport == "baseball" or sport == "basketball" or sport == "football"
            or sport == "hockey"):
        sport = sports_dict.get(sport)
        team = argumentList[2].lower()
        team_info = sports.get_team(sport, team)
        print(team_info)
    else:
        print("This sport details are not supported yet")
Beispiel #8
0
def index(request):
    api = NewsApiClient(api_key='6fb766f0d7ec43c2b412b9a4fc88a64b')
    user_agent = 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_11_5) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/50.0.2661.102 Safari/537.36'
    config = Config()
    config.browser_user_agent = user_agent
    myloc = geocoder.ip('me')
    lati = myloc.lat
    longi = myloc.lng
    f_url = "http://api.openweathermap.org/data/2.5/weather?" + "appid=" + "770fdaded25c020b900de22ab272b41a" + "&lat=" + str(lati) + "&lon=" + str(longi)
    weather_data = requests.get(f_url).json()
    max_temp = weather_data['main']['temp_max']
    max_temp = ((max_temp - 273) * 1.8) + 32
    min_temp = weather_data['main']['temp_min']
    min_temp = ((min_temp - 273) * 1.8) + 32
    temp = weather_data['main']['temp']
    temp = ((temp - 273) * 1.8) + 32
    responses = requests.get("https://api.covid19api.com/summary", verify = False)
    data = responses.json()
    #print(data['Countries'])
    x = 0
    alldata = data['Countries']
    for data in alldata:
        if alldata[x]['Country'] == "United States of America":
            #print(alldata[x]['TotalConfirmed'])
            total_confirmed = alldata[x]['TotalConfirmed']
            new_deaths = alldata[x]['NewDeaths']
            new_confirmed = alldata[x]['NewConfirmed']
            total_deaths = alldata[x]['TotalDeaths']
            new_recovered = alldata[x]['NewRecovered']
            total_recovered = alldata[x]['TotalRecovered']
            date = alldata[x]['Date']
            break
        else:
            x = x + 1
    request.session['name']= weather_data['name']
    hotn = api.get_top_headlines()
    lst_titles = []
    lst_authors = []
    lenval = len(hotn['articles'])
    #print(lenval)
    hotnews.objects.all().delete()
    z = 0
    while z < lenval:
        title = hotn['articles'][z]['title']
        author = hotn['articles'][z]['author']
        source = hotn['articles'][z]['source']['name']
        description = hotn['articles'][z]['description']
        #content = hotn['articles'][z]['content']
        urls = hotn['articles'][z]['url']
        imgurl = hotn['articles'][z]['urlToImage']
        article = Article(url = urls, language='en')
        try:
            article.download()
            article.parse()
            #print(article.text)
            content = article.text
            leaning = TextBlob(content)
            lean = leaning.sentiment.polarity
            polar = leaning.sentiment.subjectivity
            #print(lean)
            #print(polar)
            if (source != "Buzzfeed"):
                new_news = hotnews(title = title, source = source, author = author, description = description, content=content, lean=lean, polar=polar)
                new_news.save()
            #print(source)
            z = z + 1
        except:
            z = z + 1
            continue;
    news = hotnews.objects.get_queryset().order_by('id')
    length = len(news)
    #print(length)
    paginator = Paginator(news, 4)
    page = request.GET.get('page')
    news = paginator.get_page(page)
    all_matches = sports.all_matches()
    baseball = all_matches['basketball']
    print(baseball)
    return render(request, "newslist/index.html", {
        "news": news,
        "max_temp": max_temp,
        "min_temp": min_temp,
        "temp": temp,
        "location": location,
        "new_deaths": new_deaths,
        "new_confirmed": new_confirmed,
        "total_confirmed": total_confirmed,
        "total_deaths": total_deaths,
        "new_deaths": new_deaths,
        "new_recovered": new_recovered,
        "total_recovered": total_recovered,
        "date": date
    })
Beispiel #9
0
 def getSportsMatches(self):
     all_sports_matches = sports.all_matches()
     all_targeted_matches = all_sports_matches[self.target_sport]
     return all_targeted_matches