Comments (6)
Yes, it's possible to make it cross-pythonic. Usually the six
package is used, but I think it's not even needed there.
urllib2
's just got refactored (or maybe just renamed) to urllib.request
in Python 3.
Since you mentioned generate_classes.py
, I'ma open an issue related to it that I've discovered while trying to use obs-websocket-py
for my needs.
from obs-websocket-py.
I'm no Python 3 expert yet, but I'll try to help out. Two issues so far: exceptions and password hashing, both in core.py
Syntax for exceptions changed from
except (ValueError, exceptions.ObjectError), e:
in Python 2 to
except (ValueError, exceptions.ObjectError) as e:
in Python 3.
With those changes the module works if the user doesn't use a password. With the password provided we have another problem - hashing. core.py at line 57 and 58 throws an exception:
secret = base64.b64encode(hashlib.sha256(password + result['salt']).digest())
TypeError: Unicode-objects must be encoded before hashing
as strings in Python 3 are now fully unicode from the start. I tried to fiddle with it yesterday but didn't find a solution yet. Encoding the password string beforehand does raise a string + bytes can't concat bytes to str type error, so... Little bit of magic is required somewhere. :)
from obs-websocket-py.
@JohnnyBlaze420
Here's what I made it look like in core.py (besides exception handling) to successfully connect to the secured OBS:
secret = base64.b64encode(hashlib.sha256((password + result['salt']).encode('utf-8')).digest())
auth = base64.b64encode(hashlib.sha256(secret + result['challenge'].encode('utf-8')).digest()).decode('utf-8')
auth
needs to be decoded from bytes because it will go to the JSONed dict, and JSON can only handle strings, not byte strings. So I decode the result from b64encode
as a UTF-8. Well, in fact, it can be decoded as an ASCII, because that's just base64 string.
EDIT:
Making it Python 3 compatible is not the same as making it Python 3 compatible while keeping Python 2 compatibility. That'd require a bit more work.
@Elektordi, do you want to keep Python 2 compatibility?
from obs-websocket-py.
I definitely need Py2 compatibility because I originally write this lib for a specific task which is running under Py2.7
But I just read https://wiki.python.org/moin/Python2orPython3#Supporting_Python_2_and_Python_3_in_a_common_code_base and there is some interesting advices to have a common Py2/Py3 code.
obs-websocket-py is a pretty simple project, it should be possible to make it work that way. You think so?
from obs-websocket-py.
I made some tests in python3 branch. Both samples seems to be working.
Have you got some other uses to test with?
(Only generate_classes.py
is still not working, urllib2 was not ported to Python3 yet. But it's not an important part of the project...)
from obs-websocket-py.
Ok, made some tests with the python3 branch, no problems so far, I'm merging with master and aim at release 0.3 to be advertised on PyPI as Py3 compliant... :)
from obs-websocket-py.
Related Issues (20)
- MessageTimeout HOT 3
- No support for calling Virtual Camera on and off? HOT 1
- Refresh browers source, Control media audio mute and unmute, control filter visible, hide or show HOT 1
- Not able to connect to the websocket HOT 2
- Request: ExecuteBatch
- Handling error when OBS closes before script HOT 4
- Not working with OBS 28.0.0 (obs-websocket v5) HOT 2
- How to add image source in scene? HOT 2
- Do merge and update to websocket 5.0 HOT 2
- Remote Python2 compatiblity
- Getting KeyError: 'status' while trying to connect to OBS studio HOT 2
- Switch Scene v4 Sample HOT 5
- KeyError: 'status' with OBS 29 and obs-websocket-py 0.5.3 HOT 4
- SetSourceSettings expects one argument but 3 were given HOT 4
- Error not understood on scene change. HOT 4
- ConnectionRefusedError: Unable to make OBS and obs-websocket-py cooperate HOT 1
- requests.SetRecordDirectory takes 1 positional argument but 2 were given HOT 6
- How I can get the value of an call request? HOT 3
- Adding timeout to obsws_python.EventClient() causes timeout even when connection is ok HOT 2
- GetStreamStatus Inputdata and outputdata mix up
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from obs-websocket-py.