mirror of
https://github.com/lutris/lutris
synced 2024-09-15 22:09:55 +00:00
Provide alternate method to login to Humble Bundle
This commit is contained in:
parent
c82d6eb5af
commit
12ec851f5c
|
@ -137,4 +137,4 @@ class RunnerBox(Gtk.Box):
|
|||
"""Called after the runner is removed"""
|
||||
self.runner_label_box.set_sensitive(False)
|
||||
self.action_alignment.get_children()[0].destroy()
|
||||
self.action_alignment.add(self.get_action_button())
|
||||
self.action_alignment.add(self.get_action_button())
|
|
@ -563,3 +563,52 @@ class MoveDialog(ModelessDialog):
|
|||
ErrorDialog(str(error), parent=self)
|
||||
self.emit("game-moved")
|
||||
self.destroy()
|
||||
|
||||
|
||||
|
||||
|
||||
class HumbleBundleCookiesDialog(ModalDialog):
|
||||
def __init__(self, parent=None):
|
||||
super().__init__(_("Humble Bundle Cookie Authentication"), parent)
|
||||
self.cookies_content = None
|
||||
self.add_button(Gtk.STOCK_CANCEL, Gtk.ResponseType.CANCEL)
|
||||
self.add_default_button(Gtk.STOCK_OK, Gtk.ResponseType.OK)
|
||||
self.connect("response", self.on_response)
|
||||
|
||||
self.set_size_request(640, 512)
|
||||
|
||||
vbox = Gtk.Box.new(Gtk.Orientation.VERTICAL, 6)
|
||||
self.get_content_area().add(vbox)
|
||||
label = Gtk.Label()
|
||||
label.set_markup(_(
|
||||
"<b>Humble Bundle Authentication via cookie import</b>\n"
|
||||
"\n"
|
||||
"<b>In Firefox</b>\n"
|
||||
"- Install the folling extension: "
|
||||
"<a href='https://addons.mozilla.org/en-US/firefox/addon/export-cookies-txt/'>"
|
||||
"https://addons.mozilla.org/en-US/firefox/addon/export-cookies-txt/"
|
||||
"</a>\n"
|
||||
"- Open a tab to humblebundle.com and make sure you are logged in.\n"
|
||||
"- Click the cookie icon in the top right corner, next to the settings menu\n"
|
||||
"- Check 'Prefix HttpOnly cookies' and click 'humblebundle.com'\n"
|
||||
"- Open the generated file and paste the contents below."
|
||||
))
|
||||
vbox.pack_start(label, False, False, 24)
|
||||
self.textview = Gtk.TextView()
|
||||
self.textview.set_left_margin(12)
|
||||
self.textview.set_right_margin(12)
|
||||
scrolledwindow = Gtk.ScrolledWindow()
|
||||
scrolledwindow.set_hexpand(True)
|
||||
scrolledwindow.set_vexpand(True)
|
||||
scrolledwindow.add(self.textview)
|
||||
vbox.pack_start(scrolledwindow, True, True, 24)
|
||||
self.show_all()
|
||||
self.run()
|
||||
|
||||
def on_response(self, _widget, response):
|
||||
if response == Gtk.ResponseType.CANCEL:
|
||||
self.cookies_content = None
|
||||
else:
|
||||
buffer = self.textview.get_buffer()
|
||||
self.cookies_content = buffer.get_text(buffer.get_start_iter(), buffer.get_end_iter(), True)
|
||||
self.destroy()
|
||||
|
|
|
@ -4,10 +4,13 @@ import json
|
|||
import os
|
||||
from gettext import gettext as _
|
||||
|
||||
from gi.repository import Gtk
|
||||
|
||||
from lutris import settings
|
||||
from lutris.exceptions import UnavailableGameError
|
||||
from lutris.installer import AUTO_ELF_EXE, AUTO_WIN32_EXE
|
||||
from lutris.installer.installer_file import InstallerFile
|
||||
from lutris.gui.dialogs import QuestionDialog, HumbleBundleCookiesDialog
|
||||
from lutris.services.base import OnlineService
|
||||
from lutris.services.service_game import ServiceGame
|
||||
from lutris.services.service_media import ServiceMedia
|
||||
|
@ -77,6 +80,26 @@ class HumbleBundleService(OnlineService):
|
|||
supported_platforms = ("linux", "windows")
|
||||
is_loading = False
|
||||
|
||||
def login(self, parent=None):
|
||||
dialog = QuestionDialog({
|
||||
"title": _("Workaround for Humble Bundle authentication"),
|
||||
"question": _("Humble Bundle is restricting API calls from software like Lutris and GameHub.\n"
|
||||
"Authentication to the service will likely fail.\n"
|
||||
"There is a workaround involving copying cookies "
|
||||
"from Firefox, do you want to do this instead?"),
|
||||
"parent": parent
|
||||
})
|
||||
if dialog.result == Gtk.ResponseType.YES:
|
||||
dialog = HumbleBundleCookiesDialog()
|
||||
if dialog.cookies_content:
|
||||
with open(self.cookies_path, "w", encoding="utf-8") as cookies_file:
|
||||
cookies_file.write(dialog.cookies_content)
|
||||
self.login_callback(None)
|
||||
else:
|
||||
self.logout()
|
||||
else:
|
||||
return super().login(parent=parent)
|
||||
|
||||
def login_callback(self, url):
|
||||
"""Called after the user has logged in successfully"""
|
||||
self.emit("service-login")
|
||||
|
|
Loading…
Reference in a new issue