Skip to content

Commit

Permalink
Feature/remove warning plexmatch (#10510)
Browse files Browse the repository at this point in the history
* Remove warning plexmatch.

* Rename flexmatch -> plexmatch
  • Loading branch information
p0psicles authored Apr 19, 2022
1 parent b77f31f commit de1e6d0
Showing 1 changed file with 32 additions and 28 deletions.
60 changes: 32 additions & 28 deletions medusa/metadata/plex.py
Original file line number Diff line number Diff line change
Expand Up @@ -114,31 +114,31 @@ def write_show_file(self, show_obj):
if not data:
return False

flexmatch_file_path = self.get_show_file_path(show_obj)
flexmatch_file_dir = os.path.dirname(flexmatch_file_path)
plexmatch_file_path = self.get_show_file_path(show_obj)
plexmatch_file_dir = os.path.dirname(plexmatch_file_path)

try:
if not os.path.isdir(flexmatch_file_dir):
if not os.path.isdir(plexmatch_file_dir):
log.debug(
'Metadata directory did not exist, creating it at {location}',
{'location': flexmatch_file_dir}
{'location': plexmatch_file_dir}
)
os.makedirs(flexmatch_file_dir)
helpers.chmod_as_parent(flexmatch_file_dir)
os.makedirs(plexmatch_file_dir)
helpers.chmod_as_parent(plexmatch_file_dir)

log.debug(
'Writing show flexmatch file to {location}',
{'location': flexmatch_file_dir}
'Writing show plexmatch file to {location}',
{'location': plexmatch_file_dir}
)

flexmatch_file = io.open(flexmatch_file_path, 'wb')
flexmatch_file.write(data.encode('utf-8'))
flexmatch_file.close()
helpers.chmod_as_parent(flexmatch_file_path)
plexmatch_file = io.open(plexmatch_file_path, 'wb')
plexmatch_file.write(data.encode('utf-8'))
plexmatch_file.close()
helpers.chmod_as_parent(plexmatch_file_path)
except IOError as error:
log.error(
'Unable to write file to {location} - are you sure the folder is writable? {error}',
{'location': flexmatch_file_path, 'error': error}
{'location': plexmatch_file_path, 'error': error}
)
return False

Expand Down Expand Up @@ -190,38 +190,38 @@ def write_ep_file(self, ep_obj):
:param ep_obj: Episode object for which to create the metadata
"""
# Parse existing .flexmatch data
flexmatch_file_path = self.get_show_file_path(ep_obj.series)
flexmatch_file_dir = os.path.dirname(flexmatch_file_path)
# Parse existing .plexmatch data
plexmatch_file_path = self.get_show_file_path(ep_obj.series)
plexmatch_file_dir = os.path.dirname(plexmatch_file_path)

with open(flexmatch_file_path) as f:
with open(plexmatch_file_path) as f:
current_content = f.readlines()

data = self._ep_data(current_content, ep_obj)

if not data:
return False

if not (flexmatch_file_path and flexmatch_file_dir):
log.debug('Unable to write episode flexmatch file because episode location is missing.')
if not (plexmatch_file_path and plexmatch_file_dir):
log.debug('Unable to write episode plexmatch file because episode location is missing.')
return False

try:
if not os.path.isdir(flexmatch_file_dir):
if not os.path.isdir(plexmatch_file_dir):
log.debug('Metadata directory missing, creating it at {location}',
{'location': flexmatch_file_dir})
os.makedirs(flexmatch_file_dir)
helpers.chmod_as_parent(flexmatch_file_dir)
{'location': plexmatch_file_dir})
os.makedirs(plexmatch_file_dir)
helpers.chmod_as_parent(plexmatch_file_dir)

log.debug('Writing episode flexmatch file to {location}',
{'location': flexmatch_file_path})
log.debug('Writing episode plexmatch file to {location}',
{'location': plexmatch_file_path})

with open(flexmatch_file_path, 'w') as outfile:
with open(plexmatch_file_path, 'w') as outfile:
outfile.write('\n'.join(data))

helpers.chmod_as_parent(flexmatch_file_path)
helpers.chmod_as_parent(plexmatch_file_path)
except IOError:
log.error('Unable to write file to {location}', {'location': flexmatch_file_path})
log.error('Unable to write file to {location}', {'location': plexmatch_file_path})
return False

return True
Expand Down Expand Up @@ -253,6 +253,10 @@ def retrieveShowMetadata(self, folder):
"""Disable retrieve show by metadata."""
return None, None, None

def update_show_indexer_metadata(self, show_obj):
"""Disable update show metadata."""
return


# present a standard "interface" from the module
metadata_class = PlexMetadata

0 comments on commit de1e6d0

Please sign in to comment.