<commit_before>from django.conf import settings
from django.shortcuts import render
import requests

def lastfm(request):
    try:
        url = ('http://ws.audioscrobbler.com/2.0/?'
               'method=user.getrecenttracks'
               '&user=sentryism&api_key={}'
               '&format=json&limit=15'.format(settings.LAST_FM))
        r = requests.get(url)
        data = r.json()
        tracks = data["recenttracks"]["track"]
        music = {}
        for index, track in enumerate(tracks):
            scrobble = {}
            scrobble['album'] = track["album"]["#text"]
            scrobble['artist'] = track["artist"]["#text"]
            scrobble['image'] = track["image"][3]["#text"]
            scrobble['name'] = track["name"]
            scrobble['url'] = track["url"]
            music[index] = scrobble
        return render(request, 'stats/lastfm.html', { 'music': music })
    except Exception as error:
        error_names = ['ass', 'butt', 'poop']
        return render(request, '500.html')<commit_msg>Added steam<commit_after>from django.conf import settings
from django.shortcuts import render
import pendulum
import requests

def lastfm(request):
    try:
        url = ('http://ws.audioscrobbler.com/2.0/?'
               'method=user.getrecenttracks'
               '&user=sentryism&api_key={}'
               '&format=json&limit=15'.format(settings.LAST_FM))
        r = requests.get(url)
        data = r.json()
        tracks = data['recenttracks']['track']
        music = {}
        for index, track in enumerate(tracks):
            scrobble = {}
            scrobble['album'] = track['album']['#text']
            scrobble['artist'] = track['artist']['#text']
            scrobble['image'] = track['image'][3]['#text']
            scrobble['name'] = track['name']
            scrobble['url'] = track['url']
            music[index] = scrobble
        return render(request, 'stats/lastfm.html', { 'music': music })
    except Exception as error:
        return render(request, '500.html')

def steam(request):
    try:
        url = ('http://api.steampowered.com/IPlayerService/'
               'GetRecentlyPlayedGames/v0001/?key={}'
               '&steamid=76561197999386785'
               '&format=json'.format(settings.STEAM))
        r = requests.get(url)
        data = r.json()
        data = data['response']['games']
        games = {}
        for index, game in enumerate(data):
            title = {}
            title['id'] = game['appid']
            title['name'] = game['name']
            playtime = pendulum.interval(minutes=game['playtime_2weeks'])
            title['playtime'] = playtime.in_words(locale='en_us')
            title['banner'] = ('http://cdn.edgecast.steamstatic.com/steam/'
                               'apps/{}/header.jpg'.format(game['appid']))
            games[index] = title
        print(games)
        return render(request, 'stats/steam.html', { 'games': games })
    except Exception as error:
        return render(request, '500.html')
{'fraction_non_alphanumeric': 0.15944426066821038, 'fraction_numerical': 0.013562686073436983, 'mean_word_length': 2.262135922330097, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5972205', 'n_tokens_mistral': 932, 'n_tokens_neox': 888, 'n_words': 163}