예제 #1
0
파일: main.py 프로젝트: Calebe94/XTeam
def main(paramstring):
    params = dict(parse_qsl(paramstring))
    # First of all I need to Verify the settings before put it into the class
    _settings = xbmcaddon.Addon()
    dialog = xbmcgui.DialogProgress()
    dialog.create("Xteam...", "Loading your Games")
    addonID = _settings.getAddonInfo('id')
    addonPath = _settings.getAddonInfo('path')
    userdata = xbmc.translatePath('special://profile/addon_data/' + addonID)
    profilesFolder = os.path.join(userdata, "profiles")

    #Parsing Folders
    if not os.path.isdir(userdata):
        os.mkdir(userdata)
    if not os.path.isdir(profilesFolder):
        os.mkdir(profilesFolder)
    WINE = _settings.getSetting("steam_wine")
    steamID = _settings.getSetting("steam_id")
    if os.path.isdir(WINE) is not True:
        error_wine = xbmcgui.Dialog()
        error_wine.ok("ERROR!", "WINE PATH IS NOT A VALID PATH!")
    if os.path.isdir(os.getenv('HOME') + "/.steam/steam/") is not True:
        error_steam = xbmcgui.Dialog()
        error_steam.ok("ERROR!", "DOES NOT FIND THE STEAM PATH",
                       "CHECK IF STEAM IS INSTALLED!")
    steam = SteamAPI.SteamAPI(WINE, steamID, userdata)
    dialog.close()

    check_params(steam, paramstring)
예제 #2
0
    def __init__(self):
        filename = "PySteam.glade"
        self.builder = gtk.Builder()
        self.builder.add_from_file(filename)
        self.builder.connect_signals(self)
        self.window = self.builder.get_object("windowMain")
        self.window.show()
        self.friendsView = self.builder.get_object("friendsView")

        self.AddListColumn("Name", 0)
        self.AddListColumn("steamid", 1)
        self.AddListColumn("Status", 2)
        self.friendsList = gtk.ListStore(str, str, str)
        self.friendsList.set_default_sort_func(None)
        self.friendsView.set_model(self.friendsList)

        self.login = self.builder.get_object("loginDlg")
        self.login.show()

        self.steam = SteamAPI()
예제 #3
0
    def get_game_list(steam_key, user_id):
        steamConn = SteamAPI.SteamAPI(steam_key)

        #gather user's list of owned games into list of (id, playtime)
        games = steamConn.getOwnedGames(user_id)['response']['games']
        gameList = []
        for game in games:
            gameList.append((game['appid'], game['playtime_forever']))
        gameListSorted = sorted(gameList, key=lambda x: x[1])

        return gameListSorted
예제 #4
0
    def handle(self, *args, **options):

        steamConn = SteamAPI.SteamAPI(steam_key)
        #get list of all games and organize into map of id -> name
        updates = 0
        new_games = 0
        current_games = GameInfo.objects.count()
        appJson = steamConn.getAppList()
        apps = appJson['applist']['apps']
        appDetails = {}
        with progressbar.ProgressBar(max_value=len(apps),
                                     redirect_stdout=True) as progress:
            for idx, app in enumerate(apps):
                appid = app['appid']
                name = app['name']
                app = GameInfo.objects.filter(game_id=int(appid))
                if app.exists():
                    #                    self.stdout.write(self.style.SUCCESS("Already have %s" % name))
                    app = app.first()
                    if app.game_name != name:
                        self.stdout.write(
                            self.style.SUCCESS("%s, %s" %
                                               (app.game_name, name)))
                        updates += 1
                        app.game_name = name

                        app.save()
                else:
                    #self.stdout.write(self.style.SUCCESS("New game found: %s" % name))
                    new_games += 1
                    app = GameInfo(game_name=name,
                                   game_id=appid,
                                   fetch_date=timezone.now())
                    try:
                        app.save()
                    except Exception as e:
                        self.stdout.write(self.style.SUCCESS(name))

                        self.stdout.write(self.style.ERROR(e))
                progress.update(idx)

        self.stdout.write(
            self.style.SUCCESS(
                "Out of %s games, %s were updated. %s new games found." %
                (current_games, updates, new_games)))
예제 #5
0
파일: main.py 프로젝트: Calebe94/XTeam
def check_params(_steamAPI, parameters):
    params = dict(parse_qsl(parameters))
    if params:
        if params['category'] == "Settings":
            xbmcaddon.Addon().openSettings()
        elif params['category'] == "Downloads":
            download = xbmcgui.Dialog()
            download.ok("NOT AVAILABLE YET!",
                        "THIS FEATURE IS IN DEVELOPMENT!")
            main_screen(_steamAPI.LIBRARY)
        elif params['category'] == "Installed":
            list_games(_steamAPI, "Installed")
            if params['action'] == 'play':
                if params['platform'] == 'linux':
                    _steamAPI.linux(params['game'])
                    dialog = xbmcgui.DialogProgress()
                    dialog.create("Xteam...",
                                  "Launching the Following app ID:",
                                  params['game'])
                    while not SteamAPI.pgrep('steam'):
                        dialog.create("Xteam...",
                                      "Launching the Following app ID:",
                                      params['game'])
                    dialog.close()
                elif params['platform'] == 'windows':
                    _steamAPI.wine(params['game'])
                else:
                    list_games(_steamAPI, "Installed")
            else:
                list_games(_steamAPI, "Installed")
        elif params['category'] == "Library":
            list_games(_steamAPI, "Library")
            if params['action'] == 'play':
                library = xbmcgui.Dialog()
                library.ok("NOT AVAILABLE!",
                           "THIS ADDON CAN'T INSTALL GAMES YET!",
                           "THIS FEATURE WILL BE AVAILABLE SOON!")
        else:
            raise ValueError("Invalid Paramstring:{0}!".format(parameters))
    else:
        main_screen(_steamAPI.LIBRARY)
예제 #6
0
import sys
import requests
import SteamAPI
import random
import os

from secret_steam_key import *

random.seed(os.urandom(4))

steamConn = SteamAPI.SteamAPI(steam_key)
steamID = sys.argv[1]
try:
    int(steamID)
except:
    steamID = steamConn.getPlayerID(steamID)

#get username
player = steamConn.getPlayerSummary(steamID)
print("Username: ", player.name)

#gather user's list of owned games into list of (id, playtime)
games = steamConn.getOwnedGames(steamID)['response']['games']

gameList = []
for game in games:
    gameList.append((game['appid'], game['playtime_forever']))
gameListSorted = sorted(gameList, key=lambda x: x[1])

#get list of all games and organize into map of id -> name
appJson = steamConn.getAppList()
예제 #7
0
def getGame(userName, neverPlayed):
    if(priorUserInfo.userName == userName):
        if(neverPlayed == 1):
            randomGame = SteamAPI.getRandomUnplayedGame(priorUserInfo.unplayedGames)
            outputText.set(randomGame)
            gameData = GiantBombAPI.getGBData(randomGame)

            #if, else needed to make sure there was no error when getting the gameData
            if(GiantBombAPI.getLink(gameData) != 0):
                priorUserInfo.previousGameLink = GiantBombAPI.getLink(gameData)
            else:
                priorUserInfo.previousGameLink = "no"

            #if, else needed to make sure there was no error when getting gameData
            if (gameData != 0):
                GBgameInfo = GiantBombAPI.getMoreInfo(gameData)
            else:
                GBgameInfo = "No information could be found about this title. "

        elif(neverPlayed == 0):
            randomGame = SteamAPI.getRandomGame(priorUserInfo.Games)
            outputText.set(randomGame)
            gameData = GiantBombAPI.getGBData(randomGame)

            #if, else needed to make sure there was no error when getting the gameData
            if(GiantBombAPI.getLink(gameData) != 0):
                priorUserInfo.previousGameLink = GiantBombAPI.getLink(gameData)
            else:
                priorUserInfo.previousGameLink = "no"

            #if, else needed to make sure there was no error when getting gameData
            if (gameData != 0):
                GBgameInfo = GiantBombAPI.getMoreInfo(gameData)
            else:
                GBgameInfo = "No information could be found about this title. "

    else:
        Games = SteamAPI.getUsersGames(userName)
        priorUserInfo.Games = Games
        unplayedGames = SteamAPI.getUsersUnplayedGames(userName)
        priorUserInfo.unplayedGames = unplayedGames

        if(neverPlayed == 1):
            randomGame = SteamAPI.getRandomUnplayedGame(unplayedGames)
            outputText.set(randomGame)
            priorUserInfo.previousGame = randomGame
            gameData = GiantBombAPI.getGBData(randomGame)

            #if, else needed to make sure there was no error when getting the gameData
            if(GiantBombAPI.getLink(gameData) != 0):
                priorUserInfo.previousGameLink = GiantBombAPI.getLink(gameData)
            else:
                priorUserInfo.previousGameLink = "no"

            #if, else needed to make sure there was no error when getting gameData
            if (gameData != 0):
                GBgameInfo = GiantBombAPI.getMoreInfo(gameData)
            else:
                GBgameInfo = "No information could be found about this title. "

        elif(neverPlayed == 0):
            randomGame = SteamAPI.getRandomGame(Games)
            outputText.set(randomGame)
            gameData = GiantBombAPI.getGBData(randomGame)

            #if, else needed to make sure there was no error when getting the gameData
            if(GiantBombAPI.getLink(gameData) != 0):
                priorUserInfo.previousGameLink = GiantBombAPI.getLink(gameData)
            else:
                priorUserInfo.previousGameLink = "no"

            #if, else needed to make sure there was no error when getting gameData
            if (gameData != 0):
                GBgameInfo = GiantBombAPI.getMoreInfo(gameData)
            else:
                GBgameInfo = "No information could be found about this title. "


    infoBox.config(state=NORMAL)
    infoBox.insert(END, GBgameInfo)
    infoBox.insert(END, '\n\n')
    infoBox.see(END)
    infoBox.config(state=DISABLED)
    priorUserInfo.userName = userName
예제 #8
0
class PySteam:
    def __init__(self):
        filename = "PySteam.glade"
        self.builder = gtk.Builder()
        self.builder.add_from_file(filename)
        self.builder.connect_signals(self)
        self.window = self.builder.get_object("windowMain")
        self.window.show()
        self.friendsView = self.builder.get_object("friendsView")

        self.AddListColumn("Name", 0)
        self.AddListColumn("steamid", 1)
        self.AddListColumn("Status", 2)
        self.friendsList = gtk.ListStore(str, str, str)
        self.friendsList.set_default_sort_func(None)
        self.friendsView.set_model(self.friendsList)

        self.login = self.builder.get_object("loginDlg")
        self.login.show()

        self.steam = SteamAPI()

    def AddListColumn(self, title, columnId):
        column = gtk.TreeViewColumn(title, gtk.CellRendererText(), text=columnId)
        column.set_resizable(True)
        self.friendsView.append_column(column)

    def userStatusToString(self, status):
        if status == UserStatus.Online:
            return "Online"
        elif status == UserStatus.Away:
            return "Away"
        elif status == UserStatus.Snooze:
            return "Snooze"
        elif status == UserStatus.Busy:
            return "Busy"
        elif status == UserStatus.Offline:
            return "Offline"

    def on_windowMain_destroy(self, widget):
        gtk.main_quit()

    def on_friendsView_button_press_event(self, widget, event):
        if event.type == gtk.gdk._2BUTTON_PRESS:
            pointer = event.window.get_pointer()
            selection = widget.get_path_at_pos(pointer[0], pointer[1])
            index = selection[0][0]
            ChatBox(self.steam, self.users[index])

    def on_login_clicked(self, widget):
        usernamef = self.builder.get_object("username")
        passwordf = self.builder.get_object("password")
        steamguardlb = self.builder.get_object("steamguardlb")
        steamguardf = self.builder.get_object("steamguard")
        username = usernamef.get_text()
        password = passwordf.get_text()

        status = self.steam.Authenticate(str(username), str(password), "")
        if status == LoginStatus.SteamGuard:
            steamguardlb.show()
            steamguardf.show()
            steamguard = steamguardf.get_text()
            status = self.steam.Authenticate(str(username), str(password), str(steamguard))

        if status == LoginStatus.LoginSuccessful:
            usernamef.set_text("")
            passwordf.set_text("")
            self.login.hide()
            poll = self.steam.Poll()
            friends = self.steam.GetFriends()
            self.users = self.steam.GetUserInfo(friends)
            #count = 0
            for user in self.users:
                self.friendsList.append([user.nickname, user.steamid, self.userStatusToString(user.status)])
예제 #9
0
파일: Example.py 프로젝트: nuds7/PySteam
from SteamAPI import *

steam = SteamAPI()

username = raw_input("Username: "******"Password: "******"")
if status == LoginStatus.SteamGuard:
    steamguard = raw_input("SteamGuard Code: ")
    status = steam.Authenticate(str(username), str(password), str(steamguard))

if status == LoginStatus.LoginSuccessful:
    poll = steam.Poll()
    friends = steam.GetFriends()
    users = steam.GetUserInfo(friends)
    count = 0
    for user in users:
        print str(count) + ": Nick: " + user.nickname + " Steamid: " + str(user.steamid)
        count = count + 1

    msgid = raw_input("Who do you want to msg?: ")
    msg = raw_input("Message: ")

    steam.SendMessage(users[int(msgid)], msg)

else:
    print "Failed to login!"
예제 #10
0
import json
import SteamAPI
import random
from environment import Env

API_KEY = Env.STEAM_API_KEY
steamAPI = SteamAPI.GetInfo(API_KEY)


class Player:
    """
    Attributes
    -----------
    personaname : str
        The user's username.
    steamid : str
        The user's steam ID.
    owned_games : list [{"obj":Game, "appid": int, "name": str, "playtime_forever": int}]
        The user's owned games
    friends_list_rough : list [{"steamid": str, "relationship": str, "friend_since": int}]
        Easy-list of friends, for ids.
    friends_detailed : list[Player]
        list that contains Player object.
    """
    def __init__(self, *, steamid=None):
        self.steamid = steamid
        self.owned_games = None
        self.friends_list_rough = None
        self.friends_detailed = None
        self.personaname = None
        self._isdetailed = False
예제 #11
0
    def get_user_name(steam_key, user_id):
        steamConn = SteamAPI.SteamAPI(steam_key)

        #get username
        player = steamConn.getPlayerSummary(user_id)
        return player.name
예제 #12
0
    def get_user_id(steam_key, user_id):
        steamConn = SteamAPI.SteamAPI(steam_key)

        #get username
        playerID = steamConn.getPlayerID(user_id)
        return playerID