Skip to content
This repository has been archived by the owner on Jan 10, 2025. It is now read-only.

Commit

Permalink
v0.3.2
Browse files Browse the repository at this point in the history
支持Alist 302,STRM内存放Alist链接(http://ip:port/d/115/xxxxx.mkv),配合emby2alist插件,客户端可播放115真实链接节省服务器流量(v0.3.2版本)
  • Loading branch information
qicfan committed Dec 16, 2024
1 parent e6c735c commit 3fabc7d
Show file tree
Hide file tree
Showing 8 changed files with 140 additions and 109 deletions.
4 changes: 3 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,9 @@
- [x] STRM生成
- [x] 元数据复制
- [x] 支持源文件不存在时删除目标文件
- [x] 支持webdav和本地挂载如CD2
- [x] 支持CD2本地挂载,STRM内存放媒体文件的本地路径
- [x] 支持WebDAV,STRM内存放WebDAV Url,可供播放器直接播放
- [x] 支持Alist 302,STRM内存放Alist链接(http://ip:port/d/115/xxxxx.mkv),配合emby2alist插件,客户端可播放115真实链接节省服务器流量(v0.3.2版本)
- [x] 元数据增加软链接处理方式
- [x] docker支持 + 简单的web ui (v0.2版本)
- [x] docker版本增加监控文件变更,自动生成STRM,CD2 only (v0.2版本)
Expand Down
19 changes: 16 additions & 3 deletions console.py
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ def readTmp():
rprint("[bold red]请输入正确的strm根目录[/]")
return
saveTmp()
lib.type = Prompt.ask("[green]type[/] 请选择STRM类型", choices=["本地路径", "WebDAV"], default=lib.type)
lib.type = Prompt.ask("[green]type[/] 请选择STRM类型", choices=["本地路径", "WebDAV", "alist302"], default=lib.type)
saveTmp()
lib.mount_path = Prompt.ask("[green]mount_path[/] 如果使用Alist请输入Alist创建存储时输入的根文件夹ID对应的路径", default=lib.mount_path)
lib.mount_path = lib.mount_path.strip('/')
Expand All @@ -133,11 +133,11 @@ def readTmp():
lib.copy_delay = FloatPrompt.ask("[green]copy_delay[/] 每个元数据复制的间隔秒数,支持两位小数如:0.01, 默认1秒?", default=float(lib.copy_delay))
saveTmp()
if lib.type == 'WebDAV':
lib.webdav_url = Prompt.ask("[green]path_of_115[/] 请输入webdav服务中的115挂载路径, 不要包含http[s]://,格式:ip:port/[dav/115]", default=lib.webdav_url)
lib.webdav_url = Prompt.ask("[green]webdav_url[/] 请输入webdav服务中的115挂载路径, 格式:http[s]//ip:port/[dav/115]", default=lib.webdav_url)
if (lib.webdav_url == ''):
rprint("[bold red]webdav服务的url必须输入[/]")
return
lib.webdav_url = lib.webdav_url.replace('http://', '').replace('https://', '').rstrip('/')
lib.webdav_url = lib.webdav_url.rstrip('/')
saveTmp()
lib.webdav_username = Prompt.ask("[green]webdav_username[/] 请输入webdav服务的登录用户名,只是用字母和数字不要包含特殊字符", default=lib.webdav_url)
if (lib.webdav_username == ''):
Expand All @@ -149,6 +149,19 @@ def readTmp():
rprint("[bold red]webdav服务的登录密码必须输入[/]")
return
saveTmp()
if lib.type == 'alist302':
lib.alist_server = Prompt.ask("[green]alist_server[/] 请输入alist地址, 格式:http[s]//ip:port", default=lib.alist_server)
if (lib.alist_server == ''):
rprint("[bold red]alist地址l必须输入[/]")
return
lib.alist_server = lib.alist_server.rstrip('/')
saveTmp()
lib.alist_115_path = Prompt.ask("[green]alist_115_path[/] 请输入alist存储中115的挂载路径", default=lib.alist_115_path)
if (lib.alist_115_path == ''):
rprint("[bold red]webdav服务的登录用户名必须输入[/]")
return
lib.alist_115_path = lib.alist_115_path.strip('/')
saveTmp()
strmExtStr = ';'.join(lib.strm_ext)
newStrmExtStr = Prompt.ask("[green]strm_ext[/] 请输入要生成STRM的文件扩展名,分号分隔,可以直接复制默认值来修改", default=strmExtStr)
strmExtList = newStrmExtStr.split(';')
Expand Down

Large diffs are not rendered by default.

99 changes: 99 additions & 0 deletions frontend/assets/index-DJ5OvMFn.js

Large diffs are not rendered by default.

99 changes: 0 additions & 99 deletions frontend/assets/index-hHmJwpJi.js

This file was deleted.

4 changes: 2 additions & 2 deletions frontend/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@
<link rel="icon" href="/favicon.ico">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Q115-STRM</title>
<script type="module" crossorigin src="/assets/index-hHmJwpJi.js"></script>
<link rel="stylesheet" crossorigin href="/assets/index-D3WJemj8.css">
<script type="module" crossorigin src="/assets/index-DJ5OvMFn.js"></script>
<link rel="stylesheet" crossorigin href="/assets/index-BhJhtUhE.css">
</head>
<body>
<div id="app"></div>
Expand Down
16 changes: 14 additions & 2 deletions job.py
Original file line number Diff line number Diff line change
Expand Up @@ -228,7 +228,6 @@ def strm(self, path: str):
if self.lib.type == '本地路径':
strm_content = os.path.join(self.lib.path_of_115, path)
else:
url = self.lib.webdav_url.replace('http://', '').replace('https://', '')
path = path.replace(os.sep, '/')
if self.lib.mount_path != '':
path.replace(self.lib.mount_path, '')
Expand All @@ -238,7 +237,20 @@ def strm(self, path: str):
newPath = []
for p in pathList:
newPath.append(urllib.parse.quote(p))
strm_content = 'http://{0}:{1}@{2}/{3}'.format(self.lib.webdav_username, self.lib.webdav_password, url, '/'.join(newPath))
if self.lib.type == 'WebDAV':
url = self.lib.webdav_url
if not url.startswith('http'):
url = "http://{0}".format(url)
url = self.lib.webdav_url.replace('//', '//{0}:{1}@'.format(self.lib.webdav_username, self.lib.webdav_password))
if url.endswith('/'):
url = url.rstrip('/')
strm_content = '{0}/{1}'.format(url, '/'.join(newPath))
else:
url = self.lib.alist_server
if url.endswith('/'):
url = url.rstrip('/')
alist_115_path = self.lib.alist_115_path.strip('/')
strm_content = '{0}/d/{1}/{2}'.format(url, alist_115_path, '/'.join(newPath))
with open(strm_real_file, 'w', encoding='utf-8') as f:
f.write(strm_content)
return ''
Expand Down
6 changes: 5 additions & 1 deletion lib.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,9 +37,11 @@ class LibBase:
key: str # 标识
name: str # 名称
path: str # 路径
type: str # strm类型,'本地路径' | 'WebDAV'
type: str # strm类型,'本地路径' | 'WebDAV' | 'alist302'
strm_root_path: str # strm根目录
mount_path: str # alist挂载根文件夹,cd2留空
alist_server: str # alist服务器地址,格式:http[s]://ip:port
alist_115_path: str # alist中115路径,一般都是:115
path_of_115: str # 115挂载根目录
copy_meta_file: int # 元数据选项:1-关闭,2-复制,3-软链接
copy_delay: int | float # 元数据复制间隔
Expand All @@ -61,6 +63,8 @@ def __init__(self, data: None | dict):
self.type = data.get('type') if data.get('type') is not None else '本地路径'
self.strm_root_path = data.get('strm_root_path') if data.get('strm_root_path') is not None else ''
self.mount_path = data.get('mount_path') if data.get('mount_path') is not None else ''
self.alist_server = data.get('alist_server') if data.get('alist_server') is not None else ''
self.alist_115_path = data.get('alist_115_path') if data.get('alist_115_path') is not None else ''
self.path_of_115 = data.get('path_of_115') if data.get('path_of_115') is not None else ''
self.copy_meta_file = data.get('copy_meta_file') if data.get('copy_meta_file') is not None else '关闭'
self.copy_delay = data.get('copy_delay') if data.get('copy_delay') is not None else 1
Expand Down

0 comments on commit 3fabc7d

Please sign in to comment.