Quantcast
Channel: configuration - Forum - FlexGet
Viewing all articles
Browse latest Browse all 716

Is there the proper way to manipulate titles of entries via series plugin list?

$
0
0

@gathermate wrote:

tasks:
  test-task:
    mock:
      - {title: 'Running Man.E114.190203.1080p.mp4'}
      - {title: 'Something Special Running Man.E116.190202.1080p.mp4'}
      - {title: 'Another Special Running Man.E115.190201.1080p.mp4'}
      - {title: 'Rebroadcasting Running Man.E114.190131.1080p.mp4'}
      - {title: 'Kingdom.S01E01.720p.HDTV.x264'}
      - {title: '[Ads] Kingdom.S01E02.720p.HDTV.x264'}
      - {title: 'Netflix Kingdom.S01E03.720p.HDTV.x264'}
      - {title: 'The Kingdom.S01E04.720p.HDTV.x264'}
      - {title: 'www.google.com Kingdom.S01E05.720p.HDTV.x264'}
    series:
      - Running Man
      - Kingdom
  • Running Man.E114.190203.1080p.mp4
  • Kingdom.S01E01.720p.HDTV.x264
  • [Ads] Kingdom.S01E02.720p.HDTV.x264

So 3 entries are accepted as I expected, but I want all them to be accepted.
I tried the 'manipulate' plugin first.

manipulate:
  - title:
      replace:
        regexp: '^.*(Running Man|Kingdom)'
        format: '\1'

Yes, they were all accepted. But what if I managed many series, it's too finger-breakable to add each series into 'regexp'.

Secondly, I decided to loop it with jinja. But as you know, 'regexp' doesn't interpret jinja expressions.

Thirdly, I found 'name_regexp' of 'series' plugin. I thought it would capture the series I wanted from various titles of entries. But it works only when the entry be captured as series also it is still finger-breakable too.

Finally, I looked in the source code, and added some lines to 'series' module for my goal. I know it's not the proper way, but I wanted to demonstrate that how do I get the proper way that works like it.

This is my added lines ('FilterSeries.on_task_metainfo()' in 'series.py' module.)

# original source codes continued...
entries = set([entry for letter in letters for entry in entries_map.get(letter, [])])
if entries:
    self.parse_series(entries, series_name, series_config, db_identified_by)

# I added below lines...
entries = []
for entry_list in entries_map.itervalues():
    for entry in entry_list:
        regexp = '^.*' + series_name
        title = entry.get('title')
        match = re.search(regexp, title)
        if match:
            entry['title'] = re.sub(regexp, series_name, title)
            entries.append(entry)
entries = set(entries)
if entries:
    self.parse_series(entries, series_name, series_config, db_identified_by)

TL;DR:

It's too finger-painful to add each series into 'regexp' on 'manipulate' plugin.
Is there the proper way to manipulate titles of entries via series plugin list?

Posts: 1

Participants: 1

Read full topic


Viewing all articles
Browse latest Browse all 716

Trending Articles