Skip to content

Commit

Permalink
Fit for Macast v0.7
Browse files Browse the repository at this point in the history
  • Loading branch information
xfangfang committed Jan 13, 2022
1 parent 22e7d09 commit 56b1ae6
Show file tree
Hide file tree
Showing 6 changed files with 42 additions and 41 deletions.
11 changes: 6 additions & 5 deletions iina/iina.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
# <macast.renderer>IINARenderer</macast.renderer>
# <macast.platform>darwin</macast.platform>
# <macast.version>0.3</macast.version>
# <macast.host_version>0.65</macast.host_version>
# <macast.host_version>0.7</macast.host_version>
# <macast.author>xfangfang</macast.author>
# <macast.desc>IINA support for Macast. Because iina is developed based on MPV, this plugin experience is similar to the built-in MPV renderer.</macast.desc>

Expand Down Expand Up @@ -82,16 +82,16 @@ def set_media_stop(self):
self.ipc_thread = None
cherrypy.engine.publish('renderer_av_stop')

def set_media_url(self, data):
def set_media_url(self, data, start=0):
""" data : string
"""
if not self.is_iina_start:
self.set_media_stop()
self.start_iina(data)
self.start_iina(data, start=0)
self.ipc_thread = threading.Thread(target=self.start_ipc, name="IINA_IPC_THREAD")
self.ipc_thread.start()
else:
self.send_command(['loadfile', data, 'replace'])
self.send_command(['loadfile', data, 'replace', f'start={start}'])
cherrypy.engine.publish('renderer_av_uri', data)

def send_command(self, command):
Expand All @@ -105,14 +105,15 @@ def set_observe(self):
super(IINARenderer, self).set_observe()
self.set_media_volume(100)

def start_iina(self, url):
def start_iina(self, url, start=0):
"""Start iina thread
"""
self.is_iina_start = True
params = [
self.path,
'--keep-running',
'--mpv-input-ipc-server={}'.format(self.mpv_sock),
f'--mpv-start={start}',
url
]
# start iina
Expand Down
16 changes: 8 additions & 8 deletions info.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
{
"author": "xfangfang",
"desc": "IINA support for Macast. Because iina is developed based on MPV, this plugin experience is similar to the built-in MPV renderer.",
"host_version": "0.65",
"host_version": "0.7",
"platform": "darwin",
"renderer": "IINARenderer",
"title": "IINA Renderer",
Expand All @@ -14,35 +14,35 @@
{
"author": "xfangfang",
"desc": "PIFMRDS support for Macast. Only for raspberry pi, visit the plugin repository for more information.",
"host_version": "0.65",
"host_version": "0.7",
"platform": "linux",
"renderer": "PIFMRenderer",
"title": "PIFMRDS Renderer",
"type": "renderer",
"url": "https://raw.githubusercontent.com/xfangfang/Macast-plugins/main/pi-fm-rds/pi_fm.py",
"version": "0.1"
"version": "0.2"
},
{
"author": "xfangfang",
"desc": "Using web browser as DLNA media renderer, This plugin can be used to download media files or get some m3u8 played.",
"host_version": "0.65",
"host_version": "0.7",
"platform": "darwin,linux,win32",
"renderer": "WebRenderer",
"title": "Web Renderer",
"type": "renderer",
"url": "https://raw.githubusercontent.com/xfangfang/Macast-plugins/main/web/web.py",
"version": "0.1"
"version": "0.2"
},
{
"author": "xfangfang",
"desc": "PotPlayer support for Macast, this is a simple plugin that only supports play and stop.",
"host_version": "0.65",
"host_version": "0.7",
"platform": "win32",
"renderer": "PotplayerRenderer",
"title": "PotPlayer Renderer",
"type": "renderer",
"url": "https://raw.githubusercontent.com/xfangfang/Macast-plugins/main/potplayer/potplayer.py",
"version": "0.3"
"version": "0.4"
},
{
"author": "xfangfang",
Expand All @@ -53,7 +53,7 @@
"title": "NVA Protocol",
"type": "protocol",
"url": "https://raw.githubusercontent.com/xfangfang/Macast-plugins/main/nirvana/nirvana.py",
"version": "0.1"
"version": "0.2"
}
],
"repo_url": "https://github.com/xfangfang/Macast-plugins"
Expand Down
32 changes: 16 additions & 16 deletions nirvana/nirvana.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
# <macast.title>NVA Protocol</macast.title>
# <macast.protocol>NVAProtocol</macast.protocol>
# <macast.platform>darwin,win32,linux</macast.platform>
# <macast.version>0.1</macast.version>
# <macast.version>0.2</macast.version>
# <macast.host_version>0.7</macast.host_version>
# <macast.author>xfangfang</macast.author>
# <macast.desc>NVA protocol support for Macast.</macast.desc>
Expand Down Expand Up @@ -369,9 +369,9 @@ def read_request_line(self):
# invalid URIs without raising errors
# https://tools.ietf.org/html/rfc7230#section-5.3.3
invalid_path = (
_authority != uri
or not _port
or any((_scheme, _path, _qs, _fragment))
_authority != uri
or not _port
or any((_scheme, _path, _qs, _fragment))
)
if invalid_path:
self.simple_response(
Expand All @@ -385,9 +385,9 @@ def read_request_line(self):
scheme = qs = fragment = EMPTY
else:
disallowed_absolute = (
self.strict_mode
and not self.proxy_mode
and uri_is_absolute_form
self.strict_mode
and not self.proxy_mode
and uri_is_absolute_form
)
if disallowed_absolute:
# https://tools.ietf.org/html/rfc7230#section-5.3.2
Expand All @@ -400,9 +400,9 @@ def read_request_line(self):
return False

invalid_path = (
self.strict_mode
and not uri.startswith(FORWARD_SLASH)
and not uri_is_absolute_form
self.strict_mode
and not uri.startswith(FORWARD_SLASH)
and not uri_is_absolute_form
)
if invalid_path:
# https://tools.ietf.org/html/rfc7230#section-5.3.1
Expand Down Expand Up @@ -511,8 +511,8 @@ def send_headers(self): # noqa: C901 # FIXME
pass
else:
needs_chunked = (
self.response_protocol == 'HTTP/1.1'
and self.method != b'HEAD'
self.response_protocol == 'HTTP/1.1'
and self.method != b'HEAD'
)
if needs_chunked:
# Use the chunked transfer-coding
Expand Down Expand Up @@ -542,8 +542,8 @@ def send_headers(self): # noqa: C901 # FIXME
self.outheaders.append((
b'Keep-Alive',
u'timeout={connection_timeout}'.
format(connection_timeout=self.server.timeout).
encode('ISO-8859-1'),
format(connection_timeout=self.server.timeout).
encode('ISO-8859-1'),
))

if (not self.close_connection) and (not self.chunked_read):
Expand Down Expand Up @@ -1189,7 +1189,7 @@ def cmd_from_client(self, method, counter, params=None):
self.season_id = int(params['seasonId'])
self.playurl_type = 1
self.danmaku_switch_save = params.get('danmakuSwitchSave', True)
self.desire_speed = float(params['userDesireSpeed'])
self.desire_speed = float(params.get('userDesireSpeed', 1))
self.title = ''
if int(params['epId']) != 0:
# 番剧
Expand Down Expand Up @@ -1232,7 +1232,7 @@ def cmd_from_client(self, method, counter, params=None):
self.content_type = params['contentType']
self.playurl_type = 1
self.season_id = int(params['seasonId'])
self.desire_speed = float(params['userDesireSpeed'])
self.desire_speed = float(params.get('userDesireSpeed', 1))
# todo danmuku switch save
self.danmaku_switch_save = params.get('danmakuSwitchSave', True)
if int(params['epId']) != 0:
Expand Down
6 changes: 3 additions & 3 deletions pi-fm-rds/pi_fm.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@
# <macast.title>PIFMRDS Renderer</macast.title>
# <macast.renderer>PIFMRenderer</macast.renderer>
# <macast.platform>linux</macast.platform>
# <macast.version>0.1</macast.version>
# <macast.host_version>0.65</macast.host_version>
# <macast.version>0.2</macast.version>
# <macast.host_version>0.7</macast.host_version>
# <macast.author>xfangfang</macast.author>
# <macast.desc>PIFMRDS support for Macast. Only for raspberry pi, visit the plugin repository for more information.</macast.desc>

Expand Down Expand Up @@ -46,7 +46,7 @@ def set_media_stop(self):
os.waitpid(-1, 1)
self.set_state_transport('STOPPED')

def set_media_url(self, data):
def set_media_url(self, data, start=0):
self.start_position = 0
self.sox = subprocess.Popen(['sox', '-t', 'mp3', data, '-t', 'wav', '-'],
stdout=self.fm.stdin)
Expand Down
12 changes: 6 additions & 6 deletions potplayer/potplayer.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@
# <macast.title>PotPlayer Renderer</macast.title>
# <macast.renderer>PotplayerRenderer</macast.title>
# <macast.platform>win32</macast.title>
# <macast.version>0.3</macast.version>
# <macast.host_version>0.65</macast.host_version>
# <macast.version>0.4</macast.version>
# <macast.host_version>0.7</macast.host_version>
# <macast.author>xfangfang</macast.author>
# <macast.desc>PotPlayer support for Macast, this is a simple plugin that only supports play and stop.</macast.desc>

Expand All @@ -20,7 +20,7 @@
from macast import cli, gui
from macast.renderer import Renderer

POTPLAYER_PATH = '"C:\\Program Files\\PotPlayer64\\PotPlayermini64.exe"'
POTPLAYER_PATH = r'"C:\Program Files\PotPlayer64\PotPlayermini64.exe"'


class PotplayerRenderer(Renderer):
Expand Down Expand Up @@ -53,11 +53,11 @@ def start_player(self, url):
print(e)
self.set_media_stop()
cherrypy.engine.publish('app_notify', "Error", str(e))
def set_media_url(self, url):

def set_media_url(self, url, start=0):
self.set_media_stop()
self.start_position = 0
threading.Thread(target=self.start_player, daemon=True, kwargs={'url': url}).start()
threading.Thread(target=self.start_player, daemon=True, kwargs={'url': url}).start()
self.set_state_transport("PLAYING")
cherrypy.engine.publish('renderer_av_uri', url)

Expand Down
6 changes: 3 additions & 3 deletions web/web.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@
# <macast.title>Web Renderer</macast.title>
# <macast.renderer>WebRenderer</macast.renderer>
# <macast.platform>darwin,linux,win32</macast.platform>
# <macast.version>0.1</macast.version>
# <macast.host_version>0.65</macast.host_version>
# <macast.version>0.2</macast.version>
# <macast.host_version>0.7</macast.host_version>
# <macast.author>xfangfang</macast.author>
# <macast.desc>Using web browser as DLNA media renderer, This plugin can be used to download media files or get some m3u8 played.</macast.desc>

Expand Down Expand Up @@ -48,7 +48,7 @@ def set_media_stop(self):
self.set_state_transport('STOPPED')
cherrypy.engine.publish('renderer_av_stop')

def set_media_url(self, url):
def set_media_url(self, url, start=0):
self.set_media_stop()
self.start_position = 0
self.open_browser(url)
Expand Down

0 comments on commit 56b1ae6

Please sign in to comment.