Skip to content

Commit

Permalink
add LiveRenderer mpv play state and change live config path
Browse files Browse the repository at this point in the history
  • Loading branch information
dushan555 committed Jan 23, 2022
1 parent 5aadf0b commit 63eb1d0
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 13 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -127,3 +127,4 @@ dmypy.json

# Pyre type checker
.pyre/
.idea/
4 changes: 0 additions & 4 deletions live/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,3 @@ Live support for Macast,It developed based on MPVRenderer,Can be used to watch l

<h3>help:</h3>
Macast Settings have a 'live' list below to select item to play later

<h3>author:</h3>
<li>github: [dushan555](https://github.com/dushan555) </li>
<li>mail: 767488371@qq.com </li>
28 changes: 19 additions & 9 deletions live/live.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,20 +15,19 @@
import requests
from macast import Setting, MenuItem, gui
from macast_renderer.mpv import MPVRenderer, MPVRendererSetting
from macast.utils import SETTING_DIR, RENDERER_DIR

logger = logging.getLogger("LiveRenderer")
logger.setLevel(logging.INFO)

live_text = None
LIVE_PATH = 'macast_live.m3u8'
RENDERER_PATH = os.path.join(SETTING_DIR, RENDERER_DIR)
LIVE_PATH = os.path.join(RENDERER_PATH, 'macast_live.m3u8')

if not os.path.exists(LIVE_PATH):
try:
r = requests.get('http://notag.cn/live/macast_live.m3u8')
with open(LIVE_PATH, 'wb') as f:
f.write(r.content)
finally:
if f:
f.close()
r = requests.get('http://notag.cn/live/macast_live.m3u8')
with open(LIVE_PATH, 'wb') as f:
f.write(r.content)

if os.path.exists(LIVE_PATH):
try:
Expand Down Expand Up @@ -76,12 +75,23 @@ def renderer(self):
return None
return renderers.pop()

@property
def protocol(self):
protocols = cherrypy.engine.publish('get_protocol')
if len(protocols) > 0:
return protocols.pop()

def on_start_click(self, item):
if self.lastItem and self.lastItem.data == item.data:
return
logger.info(f'text: {item.text} data: {item.data}')
self.renderer.set_media_title(item.text)
self.renderer.set_media_url(item.data)
item.checked = True
self.protocol.set_state_url(item.data)

if self.lastItem:
self.lastItem.checked = False
item.checked = True
self.lastItem = item


Expand Down

0 comments on commit 63eb1d0

Please sign in to comment.