Exemplo n.º 1
0
 def updatePlaylist(self):
     try:
         data = requests.get(self.url)
         if data.status_code != 200:
             raise
     except:
         raise Exceptions.NetworkError
     self.readPlaylist(self.verifyPlaylist(data.text))
Exemplo n.º 2
0
 def updateConfig(self):
     try:
         response = requests.get(
             OSUtils.joinUrl(Config.SERVER_URL, "config.json"))
     except:
         raise Exceptions.ConnectionFailure
     if response.status_code == 200:
         try:
             from Core.Config import Config as CoreConfig
             from Services.Utils.Image.Config import Config as ImageLoaderConfig
             from Services.Account.Config import Config as AuthConfig
             from Services.Ad.Config import Config as AdConfig
             from Services.Translator.Config import Config as TranslatorConfig
             from Services.Temp.Config import Config as TempConfig
             from Services.Twitch.Gql.TwitchGqlConfig import Config as GqlConfig
             from Services.Twitch.Playback.TwitchPlaybackConfig import Config as PlaybackConfig
             from Search.Config import Config as SearchConfig
             from Search.Helper.Config import Config as SearchHelperConfig
             from Download.Downloader.Engine.Config import Config as DownloadEngineConfig
             from Download.Downloader.FFmpeg.Config import Config as FFmpegConfig
             from Download.Downloader.Task.Config import Config as TaskConfig
             CONFIG_FILES = {
                 "": CoreConfig,
                 "IMAGE_LOADER": ImageLoaderConfig,
                 "AUTH": AuthConfig,
                 "AD": AdConfig,
                 "TRANSLATOR": TranslatorConfig,
                 "TEMP": TempConfig,
                 "API": GqlConfig,
                 "PLAYBACK": PlaybackConfig,
                 "SEARCH": SearchConfig,
                 "SEARCH_HELPER": SearchHelperConfig,
                 "DOWNLOAD_ENGINE": DownloadEngineConfig,
                 "FFMPEG": FFmpegConfig,
                 "TASK": TaskConfig
             }
             data = response.json()
             configData = data.get("global")
             configData.update(
                 data.get("local").get(Translator.getLanguage()))
             for key, value in configData.items():
                 if ":" in key:
                     configTarget, configPath = key.split(":", 1)
                     configTarget = CONFIG_FILES[configTarget]
                 else:
                     configPath = key
                     configTarget = CONFIG_FILES[""]
                 configPath = configPath.split(".")
                 for target in configPath[:-1]:
                     configTarget = getattr(configTarget, target)
                 setattr(configTarget, configPath[-1], value)
         except:
             raise Exceptions.UpdateRequired
     else:
         raise Exceptions.ConnectionFailure
Exemplo n.º 3
0
 def load(self):
     try:
         data = requests.get(self._url)
         if data.status_code == 200:
             image = QtGui.QImage()
             image.loadFromData(data.content)
             return QtGui.QPixmap(image)
         else:
             raise
     except:
         raise Exceptions.NetworkError
Exemplo n.º 4
0
 def downloadFile(self, url):
     try:
         response = requests.get(url)
         if response.status_code != 200:
             raise
     except:
         raise Exceptions.NetworkError
     try:
         with open(self.saveAs, "wb") as file:
             file.write(response.content)
             return
     except:
         raise Exceptions.FileSystemError
Exemplo n.º 5
0
 def updateRestrictions(self):
     try:
         response = requests.get(
             OSUtils.joinUrl(Config.SERVER_URL, "restrictions.json"))
     except:
         raise Exceptions.ConnectionFailure
     if response.status_code == 200:
         try:
             data = response.json()
             ContentManager.setRestrictions(data)
         except:
             raise Exceptions.UpdateRequired
     else:
         raise Exceptions.ConnectionFailure
Exemplo n.º 6
0
 def checkUrl(self):
     try:
         if not self.url.split("?")[0].endswith(".m3u8"):
             raise
         if not (self.url.startswith("http://")
                 or self.url.startswith("https://")):
             self.url = "http://{}".format(self.url)
         response = requests.get(self.url)
         if response.status_code != 200:
             raise
         self.checkPlaylist(response.text)
         self.resolutions = {"unknown": self.PlaylistUrl(self.url)}
         self.found = True
     except:
         self.found = False
 def getStreamPlaylist(self):
     try:
         response = requests.get("{}/{}.m3u8".format(
             Config.HLS_SERVER, self.CHANNEL_NAME),
                                 params={
                                     "allow_source": True,
                                     "allow_audio_only": True,
                                     "sig": self.sig,
                                     "token": self.token
                                 })
     except:
         raise Exceptions.TwitchApiError
     if response.status_code == 200:
         self.playList = response.text
     elif response.status_code == 404:
         raise Exceptions.ChannelIsOffline(self.CHANNEL_NAME)
     else:
         raise Exceptions.TwitchApiError(response)
 def getVideoPlaylist(self):
     try:
         response = requests.get("{}/{}.m3u8".format(
             Config.VOD_SERVER, self.VIDEO_ID),
                                 params={
                                     "allow_source": True,
                                     "allow_audio_only": True,
                                     "sig": self.sig,
                                     "token": self.token
                                 })
     except:
         raise Exceptions.TwitchApiError
     if response.status_code == 200:
         self.playList = response.text
     elif response.status_code == 403:
         raise Exceptions.VideoRestricted(self.VIDEO_ID)
     elif response.status_code == 404:
         raise Exceptions.VideoNotFound(self.VIDEO_ID)
     else:
         raise Exceptions.TwitchApiError(response)
Exemplo n.º 9
0
 def updateStatus(self):
     try:
         response = requests.get(
             OSUtils.joinUrl(Config.SERVER_URL, "status.json"))
     except:
         raise Exceptions.ConnectionFailure
     if response.status_code == 200:
         try:
             data = response.json()
             self.status.syncData(data)
         except:
             raise Exceptions.UpdateRequired
         if self.status.operational:
             if self.status.version.latestVersion != Config.VERSION:
                 if self.status.version.updateRequired:
                     raise Exceptions.UpdateRequired
                 else:
                     raise Exceptions.UpdateFound
         else:
             raise Exceptions.Unavailable
     else:
         raise Exceptions.ConnectionFailure