# Buggy code
def _create_recommended_show(self, show_obj):
    """Create the RecommendedShow object from the returned showobj."""
    rec_show = RecommendedShow(
        self,
        show_obj["show"]["ids"],
        show_obj["show"]["title"],
        INDEXER_TVDBV2,  # indexer
        show_obj["show"]["ids"]["tvdb"],
        **{
            "rating": show_obj["show"]["rating"],
            "votes": try_int(show_obj["show"]["votes"], "0"),
            "image_href": "http://www.trakt.tv/shows/{0}".format(
                show_obj["show"]["ids"]["slug"]
            ),
            # Adds like: {'tmdb': 62126, 'tvdb': 304219, 'trakt': 79382, 'imdb': 'tt3322314',
            # 'tvrage': None, 'slug': 'marvel-s-luke-cage'}
            "ids": show_obj["show"]["ids"],
        },
    )

    use_default = None
    image = None
    try:
        image = (
            tvdb_api_v2.series_id_images_query_get(
                show_obj["show"]["ids"]["tvdb"], key_type="poster"
            )
            .data[0]
            .file_name
        )
    except Exception:
        use_default = self.default_img_src
        logger.log(
            "Missing poster on TheTVDB for show %s" % (show_obj["show"]["title"]),
            logger.DEBUG,
        )

    rec_show.cache_image(
        "http://thetvdb.com/banners/{0}".format(image), default=use_default
    )
    # As the method below requires allot of resources, i've only enabled it when
    # the shows language or country is 'jp' (japanese). Looks a litle bit akward,
    # but alternative is allot of resource used
    if "jp" in [show_obj["show"]["country"], show_obj["show"]["language"]]:
        rec_show.check_if_anime(self.anidb, show_obj["show"]["ids"]["tvdb"])

    return rec_show


# Traceback (TypeError)
python ~/.sickrage/SickBeard.py -d -p 10101
Traceback (most recent call last):
File "/media/sdq1/home/whipcracker/.sickrage/SickBeard.py", line 9, in <module>
from start import Application
File "/media/sdq1/home/whipcracker/.sickrage/start.py", line 104, in <module>
from medusa.server.core import AppWebServer
File "/media/sdq1/home/whipcracker/.sickrage/medusa/server/core.py", line 17, in <module>
from .web import CalendarHandler, KeyHandler, LoginHandler, LogoutHandler
File "/media/sdq1/home/whipcracker/.sickrage/medusa/server/web/__init__.py", line 7, in <module>
from .home import Home, HomeAddShows, HomeChangeLog, HomeIRC, HomeNews, HomePostProcess
File "/media/sdq1/home/whipcracker/.sickrage/medusa/server/web/home/__init__.py", line 4, in <module>
from .add_shows import HomeAddShows
File "/media/sdq1/home/whipcracker/.sickrage/medusa/server/web/home/add_shows.py", line 29, in <module>
from ....show.recommendations.trakt import TraktPopular
File "/media/sdq1/home/whipcracker/.sickrage/medusa/show/recommendations/trakt.py", line 170, in <module>
tvdb_api_v2 = get_tvdbv2_api()
File "/media/sdq1/home/whipcracker/.sickrage/medusa/show/recommendations/trakt.py", line 41, in get_tvdbv2_api
access_token = auth_api.login_post(authentication_string)
File "/media/sdq1/home/whipcracker/.sickrage/lib/tvdbapiv2/apis/authentication_api.py", line 124, in login_post
callback=params.get('callback'))
File "/media/sdq1/home/whipcracker/.sickrage/lib/tvdbapiv2/api_client.py", line 324, in call_api
response_type, auth_settings, callback)
File "/media/sdq1/home/whipcracker/.sickrage/lib/tvdbapiv2/api_client.py", line 150, in __call_api
post_params=post_params, body=body)
File "/media/sdq1/home/whipcracker/.sickrage/lib/tvdbapiv2/api_client.py", line 360, in request
body=body)
File "/media/sdq1/home/whipcracker/.sickrage/lib/tvdbapiv2/rest.py", line 208, in POST
body=body)
File "/media/sdq1/home/whipcracker/.sickrage/lib/tvdbapiv2/rest.py", line 143, in request
headers=headers)
File "/media/sdq1/home/whipcracker/.sickrage/lib/requests/packages/urllib3/request.py", line 73, in request
**urlopen_kw)
File "/media/sdq1/home/whipcracker/.sickrage/lib/requests/packages/urllib3/request.py", line 151, in request_encode_body
return self.urlopen(method, url, **extra_kw)
File "/media/sdq1/home/whipcracker/.sickrage/lib/requests/packages/urllib3/poolmanager.py", line 165, in urlopen
response = conn.urlopen(method, u.request_uri, **kw)
File "/media/sdq1/home/whipcracker/.sickrage/lib/requests/packages/urllib3/connectionpool.py", line 578, in urlopen
chunked=chunked)
File "/media/sdq1/home/whipcracker/.sickrage/lib/requests/packages/urllib3/connectionpool.py", line 351, in _make_request
self._validate_conn(conn)
File "/media/sdq1/home/whipcracker/.sickrage/lib/requests/packages/urllib3/connectionpool.py", line 814, in _validate_conn
conn.connect()
File "/media/sdq1/home/whipcracker/.sickrage/lib/requests/packages/urllib3/connection.py", line 289, in connect
ssl_version=resolved_ssl_version)
File "/media/sdq1/home/whipcracker/.sickrage/lib/requests/packages/urllib3/contrib/pyopenssl.py", line 328, in ssl_wrap_socket
ctx.load_verify_locations(ca_certs, ca_cert_dir)
File "/usr/lib/python2.7/dist-packages/OpenSSL/SSL.py", line 303, in load_verify_locations
raise TypeError("cafile must be None or a byte string")
TypeError: cafile must be None or a byte string

# Fixed code
def _create_recommended_show(self, show_obj):
    """Create the RecommendedShow object from the returned showobj."""
    rec_show = RecommendedShow(
        self,
        show_obj["show"]["ids"],
        show_obj["show"]["title"],
        INDEXER_TVDBV2,  # indexer
        show_obj["show"]["ids"]["tvdb"],
        **{
            "rating": show_obj["show"]["rating"],
            "votes": try_int(show_obj["show"]["votes"], "0"),
            "image_href": "http://www.trakt.tv/shows/{0}".format(
                show_obj["show"]["ids"]["slug"]
            ),
            # Adds like: {'tmdb': 62126, 'tvdb': 304219, 'trakt': 79382, 'imdb': 'tt3322314',
            # 'tvrage': None, 'slug': 'marvel-s-luke-cage'}
            "ids": show_obj["show"]["ids"],
        },
    )

    use_default = None
    image = None
    try:
        image = (
            self.tvdb_api_v2.series_id_images_query_get(
                show_obj["show"]["ids"]["tvdb"], key_type="poster"
            )
            .data[0]
            .file_name
        )
    except Exception:
        use_default = self.default_img_src
        logger.log(
            "Missing poster on TheTVDB for show %s" % (show_obj["show"]["title"]),
            logger.DEBUG,
        )

    rec_show.cache_image(
        "http://thetvdb.com/banners/{0}".format(image), default=use_default
    )
    # As the method below requires allot of resources, i've only enabled it when
    # the shows language or country is 'jp' (japanese). Looks a litle bit akward,
    # but alternative is allot of resource used
    if "jp" in [show_obj["show"]["country"], show_obj["show"]["language"]]:
        rec_show.check_if_anime(self.anidb, show_obj["show"]["ids"]["tvdb"])

    return rec_show