Removed libMal reffeences (and little formating)

This commit is contained in:
Uriziel 2014-03-27 00:01:50 +01:00
parent 6c4e2fa402
commit da17982866
4 changed files with 351 additions and 452 deletions

View File

@ -11,14 +11,6 @@ import threading
from syncplay.constants import PRIVACY_SENDHASHED_MODE, PRIVACY_DONTSEND_MODE, \
PRIVACY_HIDDENFILENAME, FILENAME_STRIP_REGEX
import collections
# <MAL DISABLE>
libMal = None
'''try:
import libMal
except ImportError:
libMal = None
'''
# </MAL DISABLE>
class SyncClientFactory(ClientFactory):
def __init__(self, client, retry=constants.RECONNECT_RETRIES):
@ -67,7 +59,6 @@ class SyncplayClient(object):
self.userlist = SyncplayUserlist(self.ui, self)
self._protocol = None
self._player = None
self.givenmalprivacywarning = False
if(config['room'] == None or config['room'] == ''):
config['room'] = config['name'] # ticket #58
self.defaultRoom = config['room']
@ -98,7 +89,6 @@ class SyncplayClient(object):
self._speedChanged = False
self._warnings = self._WarningManager(self._player, self.userlist, self.ui)
self._malUpdater = MalUpdater(config["malUsername"], config["malPassword"], self.ui)
def initProtocol(self, protocol):
self._protocol = protocol
@ -233,7 +223,6 @@ class SyncplayClient(object):
if(self.userlist.hasRoomStateChanged() and not paused):
self._warnings.checkWarnings()
self.userlist.roomStateConfirmed()
self._malUpdater.playingHook(position, paused)
def updateGlobalState(self, position, paused, doSeek, setBy, messageAge):
if(self.__getUserlistOnLogon):
@ -309,12 +298,6 @@ class SyncplayClient(object):
filename, size = self.__executePrivacySettings(filename, size)
self.userlist.currentUser.setFile(filename, duration, size)
self.sendFile()
self._malUpdater.fileChangeHook(rawfilename, duration)
if libMal and filename <> rawfilename and self.givenmalprivacywarning == False:
message = getMessage("en", "mal-noprivacy-notification")
self.ui.showErrorMessage(message)
self.givenmalprivacywarning = True
def __executePrivacySettings(self, filename, size):
if (self._config['filenamePrivacyMode'] == PRIVACY_SENDHASHED_MODE):
@ -475,53 +458,6 @@ class SyncplayUser(object):
else:
return "{}".format(self.username)
class MalUpdater(object):
def __init__(self, username, password, ui):
self._filePlayingFor = 0.0
self._lastHookUpdate = None
self._fileDuration = 0
self._filename = ""
self.__username = username
self.__password = password
self._ui = ui
def _updatePlayingTime(self, paused):
if (not self._lastHookUpdate):
self._lastHookUpdate = time.time()
if (not paused):
self._filePlayingFor += time.time() - self._lastHookUpdate
self._lastHookUpdate = time.time()
def playingHook(self, position, paused):
if(self._fileDuration == 0):
return
self._updatePlayingTime(paused)
pastMark = position / self._fileDuration > 0.4
if self._filePlayingFor > 30 and pastMark:
threading.Thread(target=self._updateMal).start()
def fileChangeHook(self, filename, duration):
self._fileDuration = duration
self._filename = filename
self._filePlayingFor = 0.0
self._lastHookUpdate = None
def _updateMal(self):
try:
self._fileDuration = 0 # Disable playingHook
if(libMal and self._filename and self.__username and self.__password):
manager = libMal.Manager(self.__username, self.__password)
results = manager.findEntriesOnMal(self._filename)
if(len(results) > 0):
result = results[0]
message = "Updating MAL with: \"{}\", episode: {}".format(result.mainTitle, result.episodeBeingWatched)
reactor.callFromThread(self._ui.showMessage, (message),)
options = {"tags": ["syncplay"]}
manager.updateEntryOnMal(result, options)
self._filename = "" # Make sure no updates will be performed until switch
except:
reactor.callFromThread(self._ui.showMessage, ("MAL Update failure"),)
class SyncplayUserlist(object):
def __init__(self, ui, client):
self.currentUser = SyncplayUser()

View File

@ -57,8 +57,6 @@ en = {
"vlc-interface-oldversion-ignored": "Warning: Syncplay detected that an old version version of the Syncplay interface module for VLC was installed in the VLC directory. As such, if you are running VLC 2.0 then it will be ignored in favour of the syncplay.lua module contained within the Syncplay directory, but this will mean that other custom interface scripts and extensions will not work. Please refer to the Syncplay User Guide at http://syncplay.pl/guide/ for instructions on how to install syncplay.lua.",
"vlc-interface-not-installed": "Warning: The Syncplay interface module for VLC was not found in the VLC directory. As such, if you are running VLC 2.0 then VLC will use the syncplay.lua module contained within the Syncplay directory, but this will mean that other custom interface scripts and extensions will not work. Please refer to the Syncplay User Guide at http://syncplay.pl/guide/ for instructions on how to install syncplay.lua.",
"mal-noprivacy-notification": "Warning: The MyAnimeList updater does not support Syncplay's filename privacy settings. Filename information sent to Google.com, MAL-API.com and MyAnimeList.net will not be encrypted, masked or hashed. See http://syncplay.pl/tech/ for more details on MyAnimeList/libMal behaviour.",
# Client prompts
"enter-to-exit-prompt" : "Press enter to exit\n",
@ -117,8 +115,6 @@ en = {
"browse-label" : "Browse",
"more-title" : "Show more settings",
"mal-username-label" : "MAL username:",
"mal-password-label" : "MAL password:",
"privacy-sendraw-option" : "Send raw",
"privacy-sendhashed-option" : "Send hashed",
"privacy-dontsend-option" : "Don't send",
@ -148,8 +144,6 @@ en = {
"media-path-tooltip" : "Location of video or stream to be opened. Necessary for mpv and mplayer2.",
"more-tooltip" : "Display less frequently used settings.",
"mal-username-tooltip" : "Your MyAnimeList username. Note: MAL support is experimental!",
"mal-password-tooltip" : "Your MyAnimeList password. Note: This is not encrypted!",
"filename-privacy-tooltip" : "Privacy mode for sending currently playing filename to server.",
"filesize-privacy-tooltip" : "Privacy mode for sending size of currently playing file to server.",
"privacy-sendraw-tooltip" : "Send this information without obfuscation. This is the default option with most functionality.",

View File

@ -35,9 +35,6 @@ class ConfigurationGetter(object):
"playerClass": None,
"slowOnDesync": True,
"rewindOnDesync": True,
"malUsername": "",
"malPassword": "",
"malPassword": "",
"filenamePrivacyMode": constants.PRIVACY_SENDRAW_MODE,
"filesizePrivacyMode": constants.PRIVACY_SENDRAW_MODE,
"pauseOnLeave": False,
@ -70,7 +67,6 @@ class ConfigurationGetter(object):
self._iniStructure = {
"server_data": ["host", "port", "password"],
"client_settings": ["name", "room", "playerPath", "slowOnDesync", "rewindOnDesync", "forceGuiPrompt", "filenamePrivacyMode", "filesizePrivacyMode", "pauseOnLeave"],
"mal": ["malPassword", "malUsername"]
}
#

View File

@ -212,8 +212,6 @@ class ConfigDialog(QtGui.QDialog):
self.config['rewindOnDesync'] = True
else:
self.config['rewindOnDesync'] = False
self.config['malUsername'] = self.malusernameTextbox.text()
self.config['malPassword'] = self.malpasswordTextbox.text()
if self.filenameprivacySendRawOption.isChecked() == True:
self.config['filenamePrivacyMode'] = constants.PRIVACY_SENDRAW_MODE
@ -368,21 +366,6 @@ class ConfigDialog(QtGui.QDialog):
self.moreSettingsGroup = QtGui.QGroupBox(getMessage("en", "more-title"))
self.moreSettingsGroup.setCheckable(True)
self.malSettingsSplit = QtGui.QSplitter(self)
self.malusernameTextbox = QLineEdit(config['malUsername'],self)
self.malusernameTextbox.setMaximumWidth(115)
self.malusernameLabel = QLabel(getMessage("en", "mal-username-label"), self)
self.malpasswordTextbox = QLineEdit(config['malPassword'],self)
self.malpasswordTextbox.setEchoMode(QtGui.QLineEdit.Password)
self.malpasswordLabel = QLabel(getMessage("en", "mal-password-label"), self)
### <MAL DISABLE>
self.malpasswordTextbox.hide()
self.malpasswordLabel.hide()
self.malusernameTextbox.hide()
self.malusernameLabel.hide()
### </MAL DISABLE>
self.filenameprivacyLabel = QLabel(getMessage("en", "filename-privacy-label"), self)
self.filenameprivacyButtonGroup = QButtonGroup()
@ -431,11 +414,6 @@ class ConfigDialog(QtGui.QDialog):
self.pauseonleaveCheckbox.setChecked(True)
if (constants.SHOW_TOOLTIPS == True):
self.malusernameLabel.setToolTip(getMessage("en", "mal-username-tooltip"))
self.malusernameTextbox.setToolTip(getMessage("en", "mal-username-tooltip"))
self.malpasswordLabel.setToolTip(getMessage("en", "mal-password-tooltip"))
self.malpasswordTextbox.setToolTip(getMessage("en", "mal-password-tooltip"))
self.filenameprivacyLabel.setToolTip(getMessage("en", "filename-privacy-tooltip"))
self.filenameprivacySendRawOption.setToolTip(getMessage("en", "privacy-sendraw-tooltip"))
self.filenameprivacySendHashedOption.setToolTip(getMessage("en", "privacy-sendhashed-tooltip"))
@ -470,11 +448,6 @@ class ConfigDialog(QtGui.QDialog):
self.moreSettingsLayout.addWidget(self.privacyFrame, 0, 0, 1, 4)
self.moreSettingsLayout.addWidget(self.malusernameLabel , 1, 0)
self.moreSettingsLayout.addWidget(self.malusernameTextbox, 1, 1)
self.moreSettingsLayout.addWidget(self.malpasswordLabel , 1, 2)
self.moreSettingsLayout.addWidget(self.malpasswordTextbox, 1, 3)
self.moreSettingsLayout.addWidget(self.slowdownCheckbox, 2, 0, 1, 4)
if constants.SHOW_REWIND_ON_DESYNC_CHECKBOX == True:
self.moreSettingsLayout.addWidget(self.rewindCheckbox, 3, 0, 1, 4)