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

Metadata syncing rework #349

Merged
merged 9 commits into from Aug 3, 2020

Conversation

mcarlton00
Copy link
Member

Started as just polishing music syncing, but ... the codebase forced more changes. Massively increases music sync speed.

Using a library of 9300 songs:

  • 0.5.8: 17.5 minutes
  • Post changes: 2.5 minutes

Fixes #347 and fixes #122

Side effect is that each object type now inherits library as an attribute instead of being passed in during each function call.

Example:

obj = Movies(self.server, jellyfindb, videodb, self.direct_path, library)
obj.movie(movie)

Also gets rid of the library_check wrapper. This gives some improvement to initial sync times for all media types, but it's not super significant. Most of the speed improvements come from music syncing only using 3 api calls instead of potentially several thousand depending on library size.



def find_library(server, item):
from database import get_sync
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Need to move import to top of file instead of in function

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It doesn't work. No, I don't know why, but it throws import errors in the database init. Mystery for another day, imo.

@TrueTechy
Copy link
Contributor

I got the "error with sync" dialog come up doing a sync of all the libraries.

2020-08-03 19:59:41.585 T:139694725646080  NOTICE: JELLYFIN.full_sync -> ERROR::jellyfin_kodi/full_sync.py:256 full sync exited unexpectedly
2020-08-03 19:59:41.588 T:139694725646080  NOTICE: JELLYFIN.full_sync -> ERROR::jellyfin_kodi/full_sync.py:257 local variable 'boxset_library' referenced before assignment
                                            Traceback (most recent call last):
                                              File "jellyfin_kodi/full_sync.py", line 223, in process_library
                                                if boxset_library:
                                            UnboundLocalError: local variable 'boxset_library' referenced before assignment
2020-08-03 19:59:41.595 T:139694725646080  NOTICE: JELLYFIN.full_sync -> INFO::jellyfin_kodi/full_sync.py:579 --<[ fullsync ]
2020-08-03 19:59:41.598 T:139694725646080  NOTICE: JELLYFIN.library -> ERROR::jellyfin_kodi/library.py:367 local variable 'boxset_library' referenced before assignment
                                            Traceback (most recent call last):
                                              File "jellyfin_kodi/library.py", line 324, in startup
                                                sync.libraries()
                                              File "jellyfin_kodi/full_sync.py", line 101, in libraries
                                                self.start()
                                              File "jellyfin_kodi/full_sync.py", line 186, in start
                                                self.process_library(library)
                                              File "jellyfin_kodi/full_sync.py", line 223, in process_library
                                                if boxset_library:
                                            UnboundLocalError: local variable 'boxset_library' referenced before assignment

Looks like that section of code might just need indented one more level

if library_id.startswith('Boxsets:'):

                libraries = self.get_libraries(library_id.split('Boxsets:')[1] if len(library_id) > len('Boxsets:') else None)
                for entry in libraries:
                    if entry[2] == 'boxsets':
                        boxset_library = {'Id': entry[0], 'Name': entry[1]}
                        break

                if boxset_library:
                    if library_id.endswith('Refresh'):
                        self.refresh_boxsets(boxset_library)
                    else:
                        self.boxsets(boxset_library)

                return

@sonarcloud
Copy link

sonarcloud bot commented Aug 3, 2020

Kudos, SonarCloud Quality Gate passed!

Bug A 0 Bugs
Vulnerability A 0 Vulnerabilities (and Security Hotspot 0 Security Hotspots to review)
Code Smell A 1 Code Smell

No Coverage information No Coverage information
0.0% 0.0% Duplication

@mcarlton00
Copy link
Member Author

It was throwing errors if a server doesn't have any collections defined. good catch

Copy link
Contributor

@TrueTechy TrueTechy left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

All looks good now. Music sync is significantly faster. Great work

@TrueTechy TrueTechy merged commit 128e636 into jellyfin:master Aug 3, 2020
@mcarlton00 mcarlton00 deleted the why-is-everything-awful branch August 3, 2020 19:54
@oddstr13 oddstr13 mentioned this pull request Aug 25, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Music sync is unacceptably slow Music content is synced to Kodi from deselected libraries
2 participants