Skip to content

Commit

Permalink
Revert "limit_scope can now accept blank config with no 'element_name…
Browse files Browse the repository at this point in the history
…' specified."

This reverts commit f55e6bb.
  • Loading branch information
metaMMA committed Feb 22, 2020
1 parent ed95e9c commit e4aefc9
Showing 1 changed file with 9 additions and 15 deletions.
24 changes: 9 additions & 15 deletions flexget/plugins/input/html.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,19 +56,13 @@ class InputHtml(object):
'additionalProperties': {
'type': 'object',
'properties': {
'element_name': {'type': 'string'},
'attribute_name': {'type': 'string'}, # ADD LIMIT OF ONE PER 'SCOPE'?
'attribute_name': {'type': 'string'},
'attribute_value': {'type': 'string'},
'start': {'type': 'integer', 'default': 1, 'minimum': 1},
'end': {'type': 'integer', 'default': 31415, 'minimum': 1},
},
'additionalProperties': False,
'anyOf': [
{'required': ['element_name']},
{'required': ['attribute_name']},
{'required': ['attribute_value']},
],
'dependencies': {'attribute_value': ['attribute_name']},
'additionalProperties': False,
},
},
]
Expand Down Expand Up @@ -254,19 +248,18 @@ def _limit_scope(self, soup, config):
scope_list = config.get('limit_scope')

for element in scope_list:
element_name = next(iter(element))
if isinstance(element, str):
element_name = re.compile(f"^{element}$")
refine_dict = {}
start = "0"
end = f"len(result_set)"
else:
scope_name = next(iter(element))
scope_info = element[scope_name]
element_name = re.compile(f"^{scope_info.get('element_name')}$")
start = str(scope_info.get('start') - 1)
end = scope_info.get('end')
attribute_name = scope_info.get('attribute_name')
attribute_value = scope_info.get('attribute_value')
element_name = next(iter(element))
start = str(element[f"{element_name}"].get('start') - 1)
end = element[f"{element_name}"].get('end')
attribute_name = element[f"{element_name}"].get('attribute_name')
attribute_value = element[f"{element_name}"].get('attribute_value')
if not attribute_name and not attribute_value:
refine_dict = {}
else:
Expand All @@ -278,6 +271,7 @@ def _limit_scope(self, soup, config):
end = f"len(result_set)"
else:
end = str(end)
element_name = re.compile(f"^{next(iter(element))}$")

search_terms.append([element_name, refine_dict, start, end])
return self._get_anchor_list([[soup]], 0, search_terms, [])
Expand Down

0 comments on commit e4aefc9

Please sign in to comment.