Skip to content

[add] series CLI - manually add entities to series database#1856

Merged
liiight merged 5 commits intodevelopfrom
series-cli-add-command
Jun 1, 2017
Merged

[add] series CLI - manually add entities to series database#1856
liiight merged 5 commits intodevelopfrom
series-cli-add-command

Conversation

@tubedogg
Copy link
Copy Markdown
Contributor

@tubedogg tubedogg commented Jun 1, 2017

Motivation for changes:

Provide a better way to inject episodes and season packs into the series database.

Detailed changes:

Implements a new CLI subcommand:

series add "<series_name>" <entity_id> [<entity_id> ...] [--quality <quality_string>]
  • <entity_id>: One or more entity IDs recognized by FlexGet, either episodes or season packs.
  • --quality <quality_string>: Set quality for all entities (otherwise will be shown as 'None' in series show <series_name>). Accepts any string that the series parser will recognize as a quality string.

Implemented feature requests:

  • Feathub #16.

Implements a new CLI subcommand, `series add <entity_id> [<entity_id> ...] [--quality <quality_string>] [--not_downloaded]`. This can replace manual injection tasks.
Copy link
Copy Markdown
Member

@liiight liiight left a comment

Choose a reason for hiding this comment

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

Great stuff, this pr uses existing tools to solve an annoying issue. I like it

entity_ids = options.entity_id
quality = options.quality
downloaded = not options.not_downloaded
series_name = series_name.replace(r'\!', '!')
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.

Isn't this being done in series name normalizer?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Doesn't look like it, no.

TRANSLATE_MAP = {ord(u'&'): u' and '}
for char in u'\'\\':
    TRANSLATE_MAP[ord(char)] = u''
for char in u'_./-,[]():':
    TRANSLATE_MAP[ord(char)] = u' '


def normalize_series_name(name):
    """Returns a normalized version of the series name."""
    name = name.lower()
    name = name.replace('&amp;', ' and ')
    name = name.translate(TRANSLATE_MAP)  # Replaced some symbols with spaces
    name = u' '.join(name.split())
    return name

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 it should then, dunno. This doesn't feel right here

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

I dunno I just copied from begin :P

help='Episode or season entity ID(s) to add')
addshow_parser.add_argument('--quality', default=None, metavar='<quality>',
help='Quality string to be stored for all entity ID(s)')
addshow_parser.add_argument('--not-downloaded', action='store_true', dest='not_downloaded',
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.

What's the use case of adding a not downloaded entry?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Maybe if you're using it in a perverse way to track what you want to get by inputting undownloaded stuff? I know that sounds weird. I just figured since it was capable of displaying undownloaded releases, we should allow them to be added, but I don't have a solid use case in mind.

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.

YAGNI, best to drop it Imo.

"""
name_to_parse = '{} {}'.format(series.name, identifier)
if quality:
name_to_parse = '{} {} {}'.format(series.name, identifier, quality)
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.

Probably can depend on the previous formatting here, no biggie

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

You mean just pass quality straight to store_parser instead of appending it to the string to be parsed?

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.

I meant string concatenate quality to previously formatted name:

name_to_parse += ' {}'.format(quality) 

@liiight liiight merged commit 2db4358 into develop Jun 1, 2017
@tubedogg tubedogg deleted the series-cli-add-command branch June 2, 2017 03:11
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants