def __init__(self, size=0, modified=None, path=None, json_value=None):
     if json_value:
         self.size = get_attr(json_value, 'size')
         self.modified = get_attr(json_value, 'modified')
         self.path = get_attr(json_value, 'path')
     else:
         self.size = size
         self.modified = modified
         self.path = path
Beispiel #2
0
 def get_duration(cls, source):
     source = get_attr(source, '1_2')
     if source:
         source = source if source and isinstance(source, list) else [source]
         for response in source:
             content = json.loads(response.body)['content']
             keys = content.keys()
             if len(keys) == 0:
                 return None
             elif len(keys) == 1:
                 duration=0
                 childSection = content[keys[0]]['childSection']
                 for data in childSection:
                     duration += data['seconds']
                 return duration
             elif len(keys) > 1:
                 duration=0
                 all_key = content.keys()
                 for key in all_key:
                     childSection = content[key]['childSection']
                     for data in childSection:
                         duration += data['seconds']
                     return duration
             else:
                 return None
Beispiel #3
0
 def __init__(self, config):
     self.sleep = get_attr(config, 'sleep', 1)
     self.timeout = get_attr(config, 'timeout', 100)
     self.xpath = get_attr(config, 'xpath', None)
     self.python = get_attr(config, 'python', [])
     self.python = self.python if not isinstance(self.python, list) else self.python
     self.repeat = get_attr(config, 'repeat', None)
     self.wait_after_available = get_attr(config, 'wait_after_available', 0)
     self.retry_after_failed = get_attr(config, 'retry_after_failed', 3)
     self.elements_click = get_attr(config, 'elements_click', [])
     self.wait_until_present = get_attr(config, 'wait_until_present', [])
     self.schroll_down_start_coefficient = get_attr(config, 'schroll_down_start_coefficient', 0.7)
     if self.repeat == -1:
         self.repeat = 100
     else:
         self.repeat = 1 if self.repeat is None else self.repeat
Beispiel #4
0
 def toc_field(cls, source):
     toc = []
     source = get_attr(source, '1_1')
     if source:
         source = source if source and isinstance(source,list) else [source]
         for response in source:
             content = json.loads(response.body)['html']
             if content:
                 toc = content
             else:
                 None
     return toc
Beispiel #5
0
 def product_rating(cls, source):
     ratings = []
     source = get_attr(source,'1_1')
     if source:
         source = source if source and isinstance(source,list) else [source]
         for response in source:
             rating_list = json.loads(response.body)
             for data in rating_list:
                 rating = ProductRating()
                 rating['username'] = data['personName']
                 rating['review'] = data['content']
                 rating['overall_rating'] = data['rating']
                 ratings.append(rating)
     return ratings