Untitled

mail@pastecode.io avatar
unknown
plain_text
2 years ago
2.8 kB
5
Indexable
Never
### error

Traceback (most recent call last):
  File "C:\Users\rzadd\Desktop\przejrzenie_mixdropa\URL_checker_selenium__v2.py", line 269, in <module>
    main()
  File "C:\Users\rzadd\Desktop\przejrzenie_mixdropa\URL_checker_selenium__v2.py", line 245, in main
    processing = recognize_a_website(
  File "C:\Users\rzadd\Desktop\przejrzenie_mixdropa\URL_checker_selenium__v2.py", line 30, in recognize_a_website
    return website_params['function_to_perform'](
  File "C:\Users\rzadd\Desktop\przejrzenie_mixdropa\URL_checker_selenium__v2.py", line 83, in mixdrop_phrases
    print(tuple(val for val in phrase_info['function_args'].values()))
KeyError: 'function_args'


known_phrases = {
        # video not found; placeholder will be opened on that tab
        "<p>We can't find the video you are looking for.</p>": {
            'additional_check': ["<h2>WE ARE SORRY</h2>", '<div class="tb error">'],
            'function_to_perform': mark_deleted_url,
        },
        # download not found; placeholder will be opened on that tab
        "<p>We can't find the file you are looking for.</p>": {
            'additional_check': ["<h2>WE ARE SORRY</h2>", '<div class="panel download error">'],
            'function_to_perform': mark_deleted_url,
        },
        # movie title found; attempt to recognize will be performed
        '<div class="title"': {
            'additional_check': ['<a href="/f/'],
            'function_to_perform': check_for_video_title_with_hover,
            'function_args': {
                'driver':driver, 'page_html':page_html,
                'cell_containing_url':cell_containing_url, 
                'cell_containing_title': cell_containing_title,
                'hover_location':(By.CLASS_NAME, 'player'), 
                'title_location':(By.XPATH, '//div[contains(@class, "title")]/a'),
            },
        },
        '<title>MixDrop': {
            'additional_check': ['<meta property="og:title" '],
            'function_to_perform': get_video_title_from_page_source,
            'function_args': {
                'driver':driver, 
                'page_html':page_html,
                'cell_containing_url':cell_containing_url, 
                'cell_containing_title': cell_containing_title,
                'left_title_delimeter': 'pass', 
                'right_title_delimeter': 'pass',
            },
        },
    }
    for phrase, phrase_info in known_phrases.items():
        if phrase in page_html:
            if all(additional_phrase in page_html for additional_phrase in phrase_info['additional_check']):
                print('func params')
                print(tuple(val for val in phrase_info['function_args'].values()))
                return phrase_info['function_to_perform'](**phrase_info['function_args'])