'Like all media ID that have self.media_by_tag'

def like_all_exist_media(self, media_size=(-1), delay=True):

    if self.login_status:
        if (self.media_by_tag != 0):
            i = 0
            for d in self.media_by_tag:
                if ((media_size > 0) or (media_size < 0)):
                    media_size -= 1
                    l_c = self.media_by_tag[i]['likes']['count']
                    if (((l_c <= self.media_max_like) and (l_c >= self.media_min_like)) or ((self.media_max_like == 0) and (l_c >= self.media_min_like)) or ((self.media_min_like == 0) and (l_c <= self.media_max_like)) or ((self.media_min_like == 0) and (self.media_max_like == 0))):
                        for (blacklisted_user_name, blacklisted_user_id) in self.user_blacklist.items():
                            if (self.media_by_tag[i]['owner']['id'] == blacklisted_user_id):
                                self.write_log(('Not    liking    media    owned    by    blacklisted    user:    ' + blacklisted_user_name))
                                return False
                        if (self.media_by_tag[i]['owner']['id'] == self.user_id):
                            self.write_log("Keep    calm    -    It's    your    own    media    ;)")
                            return False
                        try:
                            caption = self.media_by_tag[i]['caption'].encode('ascii', errors='ignore')
                            tag_blacklist = set(self.tag_blacklist)
                            if (sys.version_info[0] == 3):
                                tags = {str.lower(tag.decode('ASCII').strip('#')) for tag in caption.split() if tag.decode('ASCII').startswith('#')}
                            else:
                                tags = {unicode.lower(tag.decode('ASCII').strip('#')) for tag in caption.split() if tag.decode('ASCII').startswith('#')}
                            if tags.intersection(tag_blacklist):
                                matching_tags = ',    '.join(tags.intersection(tag_blacklist))
                                self.write_log(('Not    liking    media    with    blacklisted    tag(s):    ' + matching_tags))
                                return False
                        except:
                            self.write_log("Couldn't    find    caption    -    not    liking")
                            return False
                        log_string = ('Trying    to    like    media:    %s' % self.media_by_tag[i]['id'])
                        self.write_log(log_string)
                        like = self.like(self.media_by_tag[i]['id'])
                        if (like != 0):
                            if (like.status_code == 200):
                                self.error_400 = 0
                                self.like_counter += 1
                                log_string = ('Liked:    %s.    Like    #%i.' % (self.media_by_tag[i]['id'], self.like_counter))
                                self.write_log(log_string)
                            elif (like.status_code == 400):
                                log_string = ('Not    liked:    %i' % like.status_code)
                                self.write_log(log_string)
                                if (self.error_400 >= self.error_400_to_ban):
                                    time.sleep(self.ban_sleep_time)
                                else:
                                    self.error_400 += 1
                            else:
                                log_string = ('Not    liked:    %i' % like.status_code)
                                self.write_log(log_string)
                                return False
                            i += 1
                            if delay:
                                time.sleep(((self.like_delay * 0.9) + ((self.like_delay * 0.2) * random.random())))
                            else:
                                return True
                        else:
                            return False
                    else:
                        return False
                else:
                    return False
        else:
            self.write_log('No    media    to    like!')
