11from pytz import timezone
22from xml .etree import ElementTree
33import requests
4+ from urllib3 .exceptions import InsecureRequestWarning
45
56from homeassistant .core import HomeAssistant
67from .const import DEFAULT_PARSE_DICT , USER_AGENT , ACCEPTS
@@ -23,7 +24,7 @@ def __init__(
2324 section_types : list ,
2425 section_libraries : list ,
2526 exclude_keywords : list ,
26- is_local : bool
27+ verify_ssl : bool
2728 ):
2829 self ._hass = hass
2930 self ._ssl = 's' if ssl else ''
@@ -35,28 +36,26 @@ def __init__(
3536 self ._section_types = section_types
3637 self ._section_libraries = section_libraries
3738 self ._exclude_keywords = exclude_keywords
38- self ._is_local = is_local
39+ self ._verify_ssl = verify_ssl
3940
4041 def update (self ):
41- if self ._is_local :
42- info_url = 'http{0}://{1}:{2}' .format (
43- self ._ssl ,
44- self ._host ,
45- self ._port
46- )
47- else :
48- info_url = 'http{0}://{1}' .format (
49- self ._ssl ,
50- self ._host ,
51- )
42+ info_url = 'http{0}://{1}:{2}' .format (
43+ self ._ssl ,
44+ self ._host ,
45+ self ._port
46+ )
5247
5348 """ Getting the server identifier """
49+ if not self ._verify_ssl :
50+ requests .packages .urllib3 .disable_warnings (category = InsecureRequestWarning )
5451 try :
5552 info_res = requests .get (info_url + "/" , headers = {
5653 "X-Plex-Token" : self ._token ,
5754 "User-agent" : USER_AGENT ,
5855 "Accepts" : ACCEPTS ,
59- }, timeout = 10 )
56+ },
57+ verify = self ._verify_ssl ,
58+ timeout = 10 )
6059 try :
6160 root = ElementTree .fromstring (info_res .text )
6261 except :
@@ -79,7 +78,9 @@ def update(self):
7978 "X-Plex-Token" : self ._token ,
8079 "User-agent" : USER_AGENT ,
8180 "Accepts" : ACCEPTS ,
82- }, timeout = 10 )
81+ },
82+ verify = self ._verify_ssl ,
83+ timeout = 10 )
8384 try :
8485 root = ElementTree .fromstring (libraries .text )
8586 except :
@@ -100,7 +101,9 @@ def update(self):
100101 "X-Plex-Token" : self ._token ,
101102 "User-agent" : USER_AGENT ,
102103 "Accepts" : ACCEPTS ,
103- }, timeout = 10 )
104+ },
105+ verify = self ._verify_ssl ,
106+ timeout = 10 )
104107 try :
105108 root = ElementTree .fromstring (sub_sec .text )
106109 except :
0 commit comments