Merge pull request #1988 from zhu0823/main
This commit is contained in:
commit
e7174b402c
@ -616,9 +616,8 @@ class Plex:
|
|||||||
return []
|
return []
|
||||||
# 媒体库白名单
|
# 媒体库白名单
|
||||||
allow_library = ",".join([lib.id for lib in self.get_librarys()])
|
allow_library = ",".join([lib.id for lib in self.get_librarys()])
|
||||||
query = {'contentDirectoryID': allow_library}
|
params = {'contentDirectoryID': allow_library}
|
||||||
path = '/hubs/continueWatching/items' + utils.joinArgs(query)
|
items = self._plex.fetchItems("/hubs/continueWatching/items", container_start=0, container_size=num, params=params)
|
||||||
items = self._plex.fetchItems(path, container_start=0, container_size=num)
|
|
||||||
ret_resume = []
|
ret_resume = []
|
||||||
for item in items:
|
for item in items:
|
||||||
item_type = MediaType.MOVIE.value if item.TYPE == "movie" else MediaType.TV.value
|
item_type = MediaType.MOVIE.value if item.TYPE == "movie" else MediaType.TV.value
|
||||||
@ -647,20 +646,61 @@ class Plex:
|
|||||||
"""
|
"""
|
||||||
if not self._plex:
|
if not self._plex:
|
||||||
return None
|
return None
|
||||||
items = self._plex.fetchItems('/library/recentlyAdded', container_start=0, container_size=num)
|
# 请求参数(除黑名单)
|
||||||
|
allow_library = ",".join([lib.id for lib in self.get_librarys()])
|
||||||
|
params = {
|
||||||
|
"contentDirectoryID": allow_library,
|
||||||
|
"count": num,
|
||||||
|
"excludeContinueWatching": 1
|
||||||
|
}
|
||||||
ret_resume = []
|
ret_resume = []
|
||||||
for item in items:
|
sub_result = []
|
||||||
item_type = MediaType.MOVIE.value if item.TYPE == "movie" else MediaType.TV.value
|
offset = 0
|
||||||
link = self.get_play_url(item.key)
|
while True:
|
||||||
title = item.title if item_type == MediaType.MOVIE.value else \
|
if len(ret_resume) >= num:
|
||||||
"%s 第%s季" % (item.parentTitle, item.index)
|
break
|
||||||
image = item.posterUrl
|
# 获取所有资料库
|
||||||
ret_resume.append(schemas.MediaServerPlayItem(
|
hubs = self._plex.fetchItems(
|
||||||
id=item.key,
|
'/hubs/promoted',
|
||||||
title=title,
|
container_start=offset,
|
||||||
subtitle=item.year,
|
container_size=num,
|
||||||
type=item_type,
|
maxresults=num,
|
||||||
image=image,
|
params=params
|
||||||
link=link
|
)
|
||||||
))
|
if len(hubs) == 0:
|
||||||
|
break
|
||||||
|
|
||||||
|
# 合并排序
|
||||||
|
for hub in hubs:
|
||||||
|
for item in hub.items:
|
||||||
|
sub_result.append(item)
|
||||||
|
sub_result.sort(key=lambda x: x.addedAt, reverse=True)
|
||||||
|
|
||||||
|
for item in sub_result:
|
||||||
|
if len(ret_resume) >= num:
|
||||||
|
break
|
||||||
|
item_type = ""
|
||||||
|
title = ""
|
||||||
|
if item.TYPE == "movie":
|
||||||
|
item_type = MediaType.MOVIE.value
|
||||||
|
title = item.title
|
||||||
|
elif item.TYPE == "season":
|
||||||
|
item_type = MediaType.TV.value
|
||||||
|
title = "%s 第%s季" % (item.parentTitle, item.index)
|
||||||
|
elif item.TYPE == "episode":
|
||||||
|
item_type = MediaType.TV.value
|
||||||
|
title = "%s 第%s季 第%s集" % (item.grandparentTitle, item.parentIndex, item.index)
|
||||||
|
link = self.get_play_url(item.key).rstrip('/children')
|
||||||
|
image = item.posterUrl
|
||||||
|
ret_resume.append(schemas.MediaServerPlayItem(
|
||||||
|
id=item.key,
|
||||||
|
title=title,
|
||||||
|
subtitle=item.year,
|
||||||
|
type=item_type,
|
||||||
|
image=image,
|
||||||
|
link=link
|
||||||
|
))
|
||||||
|
|
||||||
|
offset += num
|
||||||
|
|
||||||
return ret_resume[:num]
|
return ret_resume[:num]
|
||||||
|
@ -24,7 +24,7 @@ cryptography~=41.0.1
|
|||||||
pytz~=2023.3
|
pytz~=2023.3
|
||||||
pycryptodome~=3.18.0
|
pycryptodome~=3.18.0
|
||||||
qbittorrent-api==2023.5.48
|
qbittorrent-api==2023.5.48
|
||||||
plexapi~=4.14.0
|
plexapi~=4.15.12
|
||||||
transmission-rpc~=4.3.0
|
transmission-rpc~=4.3.0
|
||||||
Jinja2~=3.1.2
|
Jinja2~=3.1.2
|
||||||
pyparsing~=3.0.9
|
pyparsing~=3.0.9
|
||||||
|
Loading…
x
Reference in New Issue
Block a user