kdschlosser / samsungctl

Remote control Samsung televisions via a TCP/IP connection
MIT License
148 stars 34 forks source link

ValueError: not enough values to unpack (expected 2, got 1) #87

Closed andreas-bulling closed 5 years ago

andreas-bulling commented 5 years ago
python3 -m samsungctl --host 192.168.178.60 --config-file "~/Desktop/config.cfg"                                                       (master✱)
['http://192.168.178.60:9197/dmr', 'http://192.168.178.60:7678/nservice/', 'http://192.168.178.60:7676/rcr/', 'http://192.168.178.60:7677/MainTVServer2/']
Traceback (most recent call last):
  File "/usr/local/Cellar/python/3.7.2_1/Frameworks/Python.framework/Versions/3.7/lib/python3.7/runpy.py", line 193, in _run_module_as_main
    "__main__", mod_spec)
  File "/usr/local/Cellar/python/3.7.2_1/Frameworks/Python.framework/Versions/3.7/lib/python3.7/runpy.py", line 85, in _run_code
    exec(code, run_globals)
  File "/Users/andreas/Desktop/samsungctl/samsungctl/__main__.py", line 426, in <module>
    main()
  File "/Users/andreas/Desktop/samsungctl/samsungctl/__main__.py", line 338, in main
    with Remote(config) as remote:
  File "/Users/andreas/Desktop/samsungctl/samsungctl/remote.py", line 84, in __call__
    return RemoteWrapper(conf)
  File "/Users/andreas/Desktop/samsungctl/samsungctl/remote.py", line 71, in __init__
    self
  File "/Users/andreas/Desktop/samsungctl/samsungctl/upnp/__init__.py", line 20, in __init__
    UPNPObject.__init__(self, ip, locations)
  File "/Users/andreas/Desktop/samsungctl/samsungctl/upnp/UPNP_Device/upnp_class.py", line 36, in __init__
    response = requests.get(location)
  File "/usr/local/lib/python3.7/site-packages/requests/api.py", line 75, in get
    return request('get', url, params=params, **kwargs)
  File "/usr/local/lib/python3.7/site-packages/requests/api.py", line 60, in request
    return session.request(method=method, url=url, **kwargs)
  File "/usr/local/lib/python3.7/site-packages/requests/sessions.py", line 519, in request
    prep = self.prepare_request(req)
  File "/usr/local/lib/python3.7/site-packages/requests/sessions.py", line 462, in prepare_request
    hooks=merge_hooks(request.hooks, self.hooks),
  File "/usr/local/lib/python3.7/site-packages/requests/models.py", line 313, in prepare
    self.prepare_url(url, params)
  File "/usr/local/lib/python3.7/site-packages/requests/models.py", line 379, in prepare_url
    scheme, auth, host, port, path, query, fragment = parse_url(url)
  File "/usr/local/lib/python3.7/site-packages/urllib3/util/url.py", line 185, in parse_url
    host, url = url.split(']', 1)
ValueError: not enough values to unpack (expected 2, got 1)
kdschlosser commented 5 years ago

I am not sure what that error is caused by.

here are the locations it is using

'http://192.168.178.60:9197/dmr', 'http://192.168.178.60:7678/nservice/', 'http://192.168.178.60:7676/rcr/', 'http://192.168.178.60:7677/MainTVServer2/'

do me a favor and manually edit your config file and change the upnp_locations to None. this way it will re-scan. I am curious to see if the values are the same.

also try loading each of the above URL's and see what you come up with.

kdschlosser commented 5 years ago

I just added a print statement to see what the location looks like that is getting passed to requests. so clone the repo again and run it.

twf75 commented 5 years ago

Just as a heads-up: The --config-file parameter, when first used, creates a file that is not JSON valid, unfortunately. So the config-file parser gets snippy about the contents of the file. When you modify the file itself according to the example (samsungctl.conf in the samsungctl directory), it'll read it just fine.

kdschlosser commented 5 years ago

I know it creates a non JSON file. it is supposed to. the example samsungctl.conf is strictly for the old style config file. the one where you do not specify anything in the command line except for the command. it would only load from a specific location and it had to have a specific name and it would only load the file if you were running Linux. That whole system is depreciated. if you read the docs you will see that. the new system uses a flat file to make things a whole bunch easier.

I feel it is a wee bit easier to understand (from a newbie standpoint) this kind of a config file

method = websocket
upnp_locations = http://192.168.1.2:5684/location1, http://192.168.1.2:5684/location2, http://192.168.1.2:5684/location3, http://192.168.1.2:5684/location4, 'http://192.168.1.2:5684/location5, http://192.168.1.2:5684/location6
device_id = 1239854
id = 123456789
host = 192.168.1.1
port = 8002
paired = True
token = 123456789:58469
mac = 00:00:00:00:00
timeout = 10
name = samsungctl
description = some_description

vs this kind of a config file

{
    "mac": "00:00:00:00:00",
    "token": "123456789:58469",
    "timeout": 10,
    "id": "123456789",
    "description": "some_description",
    "host": "192.168.1.1",
    "method": "websocket",
    "upnp_locations": [
        "http://192.168.1.2:5684/location1",
        "http://192.168.1.2:5684/location2",
        "http://192.168.1.2:5684/location3",
        "http://192.168.1.2:5684/location4",
        "http://192.168.1.2:5684/location5",
        "http://192.168.1.2:5684/location6"
    ],
    "port": 8002,
    "paired": true,
    "device_id": "1239854",
    "name": "samsungctl"
}

to much detail in the JSON file for such a small amount of data if so much as one punctuation mark is off it will kick out an error.

way to complex a data structure for what is being stored in the file.

kdschlosser commented 5 years ago

also I do know what the issue is with the UPNP.. I will have it fixed in a few minutes

twf75 commented 5 years ago

Agreed, the non-JSON variant is much more 'human readable'. And, from personal experience: Yes it's slightly too easy to forget a comma here and there :)

It should be noted though that the current version of samsungctl (which I'm eternally grateful for) does in fact not parse the easier version of the config file. Which was a great gotcha for me...

On Thu, Jan 31, 2019 at 11:37 AM Kevin Schlosser notifications@github.com wrote:

I know it creates a non JSON file. it is supposed to. the example samsungctl.conf is strictly for the old style config file. the one where you do not specify anything in the command line except for the command. it would only load from a specific location and it had to have a specific name and it would only load the file if you were running Linux. That whole system is depreciated. if you read the docs you will see that. the new system uses a flat file to make things a whole bunch easier.

I feel it is a wee bit easier to understand (from a newbie standpoint) this kind of a config file

method = websocket upnp_locations = http://192.168.1.2:5684/location1, http://192.168.1.2:5684/location2, http://192.168.1.2:5684/location3, http://192.168.1.2:5684/location4, 'http://192.168.1.2:5684/location5, http://192.168.1.2:5684/location6 device_id = 1239854id = 123456789 host = 192.168.1.1 port = 8002 paired = True token = 123456789:58469 mac = 00:00:00:00:00 timeout = 10 name = samsungctl description = some_description

vs this kind of a config file

{ "mac": "00:00:00:00:00", "token": "123456789:58469", "timeout": 10, "id": "123456789", "description": "some_description", "host": "192.168.1.1", "method": "websocket", "upnp_locations": [ "http://192.168.1.2:5684/location1", "http://192.168.1.2:5684/location2", "http://192.168.1.2:5684/location3", "http://192.168.1.2:5684/location4", "http://192.168.1.2:5684/location5", "http://192.168.1.2:5684/location6" ], "port": 8002, "paired": true, "device_id": "1239854", "name": "samsungctl" }

to much detail in the JSON file for such a small amount of data if so much as one punctuation mark is off it will kick out an error.

way to complex a data structure for what is being stored in the file.

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/kdschlosser/samsungctl/issues/87#issuecomment-459297238, or mute the thread https://github.com/notifications/unsubscribe-auth/AtBdlEHYZ8HwQeCdUn62PZ_LQxCPqDjoks5vIseHgaJpZM4abk5m .

twf75 commented 5 years ago

Thanks :) I'll try it tonight!

On Thu, Jan 31, 2019 at 11:38 AM Kevin Schlosser notifications@github.com wrote:

also I do know what the issue is with the UPNP.. I will have it fixed in a few minutes

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/kdschlosser/samsungctl/issues/87#issuecomment-459297440, or mute the thread https://github.com/notifications/unsubscribe-auth/AtBdlC1v_y19swLB13VBXMMRDR-qFvKPks5vIsezgaJpZM4abk5m .