leopheard
leopheard

Reputation: 101

Unicode/decode error with 'ascii' python output

I'm having an issue with the following, error - think it's a case of the text containing ascii instead of utf-8 or something similar, but I'm not sure how to convert it in order to pass on to the rest of the code. Please also note that I'm limited to the python addons I can use so I have listed the imported ones at the top of the code. The error itself is here and any advice anyone could offer is very much appreciated:

Error Type: <type 'exceptions.UnicodeDecodeError'>
Error Contents: 'ascii' codec can't decode byte 0xc3 in position 986: ordinal not in range(128)
File ".../mainaddon.py", line 56, in get_playable_podcast1
if link.endswith("ttag=season:{}".format(soup1)):
UnicodeDecodeError: 'ascii' codec can't decode byte 0xc3 in position 986: ordinal not in range(128)
-->End of Python script error report<--

The entirety of the code I've been using is as follows:

import requests
import re
from bs4 import BeautifulSoup

def get_playable_podcast1(soup1):
    subjects = []
    for content in soup1.find_all('item'):
        try:
            title = content.find('title')
            title = title.get_text()
            link = content.find('enclosure')
            link = link.get('url')
            if link.endswith("ttag=season:{}".format(soup1)):
                urls.append(link) 
        except AttributeError:
            continue
        return subjects
        continue
        item = {
                    'url': link,
                    'title': title,
                    'thumbnail': "..imagehere",
            }
        subjects.append(item)
        return subjects
def compile_playable_podcast1(playable_podcast1):
    items = []
    for podcast in playable_podcast1:
        items.append({
            'label': podcast['title'],
            'thumbnail': podcast['thumbnail'],
            'path': podcast['url'],
            'is_playable': True,
    })
    return items

Upvotes: 0

Views: 116

Answers (0)

Related Questions