Skip to content

medusa plugin#2282

Merged
liiight merged 3 commits intoFlexget:developfrom
Marquez96:develop
Dec 26, 2018
Merged

medusa plugin#2282
liiight merged 3 commits intoFlexget:developfrom
Marquez96:develop

Conversation

@Marquez96
Copy link
Copy Markdown
Contributor

@Marquez96 Marquez96 commented Dec 21, 2018

Motivation for changes:

I was updating myinfrastructure with medusa, and i tried to connect with flexget via sickbear plugin, but the api of sickbear of medusa was outdated and i create a new plugin specific for medusa

Detailed changes:

I created the plugin based on old sickbear plugin, i reformat and created all the rest requests of that

Implemented feature requests:

Config usage if relevant (new plugin or updated schema):


templates:
  medusa:
    configure_series:
      from:
        medusa:
          base_url: http://127.0.0.1
          port: 8081
          username: username
          password: password
          only_monitored: True

# ---------- General config
    configure_series:
      from:
        medusa:
          base_url: string
          port: string default 8081
          username: string
          password: string
          only_monitored: boolean default False
          included_ended: boolean default False

Log and/or tests output (preferably both):

DEBUG MODE 
2018-12-21 23:24 DEBUG    medusa        updating_series processing show: {'title': 'Westworld', 'airs': 'Sunday 0:00AM', 'showType': 'series', 'rating': {'imdb': {'votes': 317083, 'rating': '8.8'}}, 'nextAirDate': None, 'cache': {'banner': '/opt/medusa/cache/images/tmdb/63247.poster.jpg', 'poster': '/opt/medusa/cache/images/tmdb/63247.poster.jpg'}, 'language': 'es', 'genres': ['Drama', 'Mystery', 'Western', 'Ciencia ficción', 'Science-Fiction'], 'id': {'slug': 'tmdb63247', 'tmdb': 63247, 'imdb': 'tt0475784', 'trakt': None}, 'classification': '', 'config': {'dvdOrder': False, 'sports': False, 'airByDate': False, 'qualities': {'allowed': [2, 4, 8, 32, 64, 128, 256, 512, 1024, 2048, 4096, 8192, 16384, 32768], 'preferred': []}, 'paused': False, 'defaultEpisodeStatus': 'Wanted', 'anime': False, 'release': {'requiredWords': [], 'ignoredWords': []}, 'aliases': [], 'subtitlesEnabled': False, 'location': '/mnt/media/series/westworld', 'seasonFolders': False, 'scene': False}, 'network': 'HBO', 'year': {'start': 2016}, 'countries': ['UNITED STATES'], 'type': 'Scripted', 'runtime': 62, 'akas': {}, 'plot': 'Westworld ...', 'country_codes': ['us'], 'status': 'Continuing', 'indexer': 'tmdb'}

INFO MODE - Silence
2018-12-20 20:04 VERBOSE  details       updating_series Produced 16 entries.


To Do:

It's recomendable to detect qualities in medusa, now i only can choose for only_monitories and ended series

)

try:
api_key = json.loads(task.requests.post(
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

you can use native requests formatting here:

Suggested change
api_key = json.loads(task.requests.post(
api_key = task.requests.post('{}/authenticate'.format(base_url), json=body_auth, headers=self.headers).json()

authorization='Bearer ' + api_key
)

series = json.loads(task.requests.get(
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

look above for optimal request syntax. Also, ideally pass url param via its own dict:

Suggested change
series = json.loads(task.requests.get(
params = {
'limit': 1000
}
series = task.requests.get('{}/series'.format(base_url), params=params).json()

schema = {
'type': 'object',
'properties': {
'base_url': {'type': 'string'},
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

you can set expected format to uri:

Suggested change
'base_url': {'type': 'string'},
'base_url': {'type': 'string', 'format': 'uri'},


entries = []
for show in series:
log.debug('processing show: {}'.format(show))
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

let logger do its own string interpolation:

Suggested change
log.debug('processing show: {}'.format(show))
log.debug('processing show: %s', show)

@Marquez96
Copy link
Copy Markdown
Contributor Author

The requested changes have been made,

Thank you for those observations

'additionalProperties': False
}

headers = {
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

this is redundant, as it is implicitly added when you use the json keyword when sending requests

log.debug('processing show: %s', show)
if (show['config']['paused'] and config.get('only_monitored')) or \
show['status'] == 'Ended' and not config.get('include_ended'):
continue
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

maybe add a debug message here?

@Marquez96
Copy link
Copy Markdown
Contributor Author

Debug message added and remove the default headers

@liiight liiight merged commit 1dab338 into Flexget:develop Dec 26, 2018
@liiight
Copy link
Copy Markdown
Member

liiight commented Dec 26, 2018

Thanks! Can you please update the wiki?

@Marquez96
Copy link
Copy Markdown
Contributor Author

Yes, of course,
https://flexget.com/Plugins/Medusa

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.

2 participants