From fecd35844f7251b4a79f193061d10681d2210a3c Mon Sep 17 00:00:00 2001
From: Jerry Yan <792602257@qq.com>
Date: Fri, 17 May 2019 21:35:48 +0800
Subject: [PATCH] Fix Bug

---
 Common.py         | 17 +++++------------
 WebMain.py        |  2 --
 liveDownloader.py |  2 +-
 3 files changed, 6 insertions(+), 15 deletions(-)

diff --git a/Common.py b/Common.py
index 20cfc94..86c3ed8 100644
--- a/Common.py
+++ b/Common.py
@@ -258,7 +258,7 @@ class downloader(XiGuaLiveApi):
     playlist = None
 
     def _updateRoomOnly(self):
-        global broadcaster, isBroadcasting, updateTime, forceNotBroadcasting, forceNotDownload
+        global broadcaster, isBroadcasting, updateTime
         super(downloader, self)._updateRoomOnly()
         updateTime = datetime.strftime(datetime.now(), dt_format)
         broadcaster = self.roomLiver
@@ -266,21 +266,14 @@ class downloader(XiGuaLiveApi):
         if self.isLive:
             self.updPlayList()
         else:
-            forceNotDownload = False
-            forceNotBroadcasting = False
             self.playlist = False
 
     def updPlayList(self):
         global streamUrl
-        if self.isLive:
-            if "stream_url" in self._rawRoomInfo:
-                if self.playlist is None:
-                    self.playlist = None
-                    streamUrl = None
-                else:
-                    self.playlist = self._rawRoomInfo["stream_url"]["flv_pull_url"]
-                    self.playlist = self.playlist.replace("_uhd", "").replace("_sd", "").replace("_ld", "")
-                    streamUrl = self.playlist
+        if self.isLive and "stream_url" in self._rawRoomInfo:
+            self.playlist = self._rawRoomInfo["stream_url"]["flv_pull_url"]
+            self.playlist = self.playlist.replace("_uhd", "").replace("_sd", "").replace("_ld", "")
+            streamUrl = self.playlist
         else:
             streamUrl = None
             self.playlist = None
diff --git a/WebMain.py b/WebMain.py
index 70b9481..0c624e3 100644
--- a/WebMain.py
+++ b/WebMain.py
@@ -10,8 +10,6 @@ from liveDownloader import run as RUN
 app = Flask(__name__)
 app.config['JSON_AS_ASCII'] = False
 CORS(app, supports_credentials=True)
-# url_for('static', filename='index.html')
-# url_for('static', filename='index.js')
 
 
 @app.route("/")
diff --git a/liveDownloader.py b/liveDownloader.py
index 13de5d1..b0dc625 100644
--- a/liveDownloader.py
+++ b/liveDownloader.py
@@ -26,8 +26,8 @@ def download():
         isDownload = True
         Common.appendDownloadStatus("Download >{}< Start".format(path))
         f = open(path, "wb")
+        _size = 0
         try:
-            _size = 0
             for t in p.iter_content(chunk_size=64 * 1024):
                 if Common.forceNotDownload:
                     Common.modifyLastDownloadStatus("Force Stop Download".format(path))