Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Removed Podcast Session Info #52

Merged
merged 1 commit into from
Oct 27, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 5 additions & 3 deletions Scripts/audio.py
Original file line number Diff line number Diff line change
Expand Up @@ -685,12 +685,14 @@ async def search_media_auto_complete(self, ctx: AutocompleteContext):
formatted_sessions_string, data = await c.bookshelf_listening_stats()

for sessions in data['recentSessions']:
bookID = sessions['bookId']
mediaMetadata = sessions['mediaMetadata']
title = sessions.get('displayTitle')
subtitle = mediaMetadata.get('subtitle')
display_author = sessions.get('displayAuthor')
bookID = sessions.get('libraryItemId')
itemID = sessions.get('libraryItemId')
name = f"{title} | {display_author}"

if len(name) <= 100:
pass
elif len(title) <= 100:
Expand All @@ -704,9 +706,9 @@ async def search_media_auto_complete(self, ctx: AutocompleteContext):
else:
name = "Recent Book Title Too Long :("

formatted_item = {"name": name, "value": bookID}
formatted_item = {"name": name, "value": itemID}

if formatted_item not in choices:
if formatted_item not in choices and bookID is not None:
choices.append(formatted_item)

await ctx.send(choices=choices)
Expand Down
8 changes: 8 additions & 0 deletions Scripts/bookshelfAPI.py
Original file line number Diff line number Diff line change
Expand Up @@ -263,6 +263,10 @@ async def bookshelf_get_item_details(book_id) -> dict:


async def bookshelf_listening_stats():
"""
Gets the 10 most recent sessions for the logged in ABS user.
:return: formatted_session_info, data
"""
bookshelfToken = os.environ.get("bookshelfToken")
endpoint = "/me/listening-stats"
formatted_sessions = []
Expand Down Expand Up @@ -914,6 +918,10 @@ async def bookshelf_get_valid_books() -> list:
async def main():
if __name__ == '__main__':
print("TESTING COMMENCES")
response, data = await bookshelf_listening_stats()
count = 0
for items in data['recentSessions']:
print(items.get('bookId'))


asyncio.run(main())
9 changes: 5 additions & 4 deletions Scripts/default_commands.py
Original file line number Diff line number Diff line change
Expand Up @@ -357,12 +357,12 @@ async def search_media_auto_complete(self, ctx: AutocompleteContext):
count = 0

for sessions in data['recentSessions']:
count += 1
bookID = sessions['bookId']
mediaMetadata = sessions['mediaMetadata']
title = sessions.get('displayTitle')
subtitle = mediaMetadata.get('subtitle')
display_author = sessions.get('displayAuthor')
bookID = sessions.get('libraryItemId')
itemID = sessions.get('libraryItemId')

name = f"{title} | {display_author}"

Expand All @@ -380,9 +380,10 @@ async def search_media_auto_complete(self, ctx: AutocompleteContext):
logger.debug("Recent Session {count}: Subtitle was too long, falling back to recent session")
name = f"Recent Session {count}"

formatted_item = {"name": name, "value": bookID}
formatted_item = {"name": name, "value": itemID}

if formatted_item not in choices:
if formatted_item not in choices and bookID is not None:
count += 1
choices.append(formatted_item)

await ctx.send(choices=choices)
Expand Down
Loading