Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Further work needed for this to work using Python3 #3

Open
dhdurgee opened this issue Apr 18, 2022 · 5 comments
Open

Further work needed for this to work using Python3 #3

dhdurgee opened this issue Apr 18, 2022 · 5 comments

Comments

@dhdurgee
Copy link

dhdurgee commented Apr 18, 2022

I was glad to see this package available as I had used the Python 2.7 version in the past. Unfortunately it is far from functional at this time. I am a novice at best working in Python, so while I made some progress I finally decided to simply use the 2.7 version instead as it still works.

In addition to the change of a "+" to a "," noted in the other issue I had to modify line 1 to add a "3" to "python" to get it to run here. Once I had this done I was able to get the "usage" displayed but attempts to use the package ran into numerous TypeErrors here.

Using pdb for the first time I was able to correct the problems in cc_device_finder.py such that I was able to use the "-devicelist" command. Attempting to go further ran into errors in cc_message.py that would require more experience than I have to remedy as I don't know enough about python3 or the protocol being implemented.

I have attached my modified cc_device_finder.py for your use. Only four lines required changes to get this working, all to resolve "str" versus "byte" TypeErrors.

Hopefully someone else can pick up from here and make the necessary changes to cc_message.py to make this functional. Until that point I will continue to work with the 2.7 version here.

cc_device_finder.zip

@dohliam
Copy link
Owner

dohliam commented Apr 18, 2022

Thanks for looking into this and sharing your work! I wonder if it might make sense to create a separate python3 branch and start merging the changes you and others have made, even if it doesn't actually work with Python 3 yet. That would make it a bit easier for others to contribute their fixes and expertise.

I note that there are a number of forks, some with additional features added. It would probably be good to merge those as well, though I don't think any of them has converted this to Python 3 yet.

Another thing to consider is referring to the other Chromecast libraries that already exist, like catt, which uses Python 3 and is based on the pychromecast library. Using an existing library for the basic functionality might save a lot of work.

@dhdurgee
Copy link
Author

Interesting, I had not know there were others taking an interest in this. The one feature I was thinking about taking a stab at adding was support for streaming internet radio. Most of what I listen to provides an online .pls playlist file, which can be parsed for the actual streaming files. The exception to this is that iHeart supplies a URL for the stream that is then redirected to the actual stream.

I have previously parsed the first stream URL out of an internet.pls file and passed that to stream2chromecast to play the stream successfully. I have not managed to do so yet with an iHeart stream, but it should be possible.

Has anyone already done work on this? If so, I want to take a look at it.

@dohliam
Copy link
Owner

dohliam commented Apr 19, 2022

That sounds like a really cool application for stream2chromecast! 👍 I've tagged this issue so that others can pitch in if they are able to help out.

@dhdurgee
Copy link
Author

dhdurgee commented Apr 21, 2022

I have done some work on stream2chromecast.py and now have the internet playlist support working. I have added a -pls option on the command line that expects the URL of an internet playlist for an internet radio station. The first functional stream in the playlist file will be passed to -playurl and streamed.

I worked on getting the iHeart streams to work but have run into a problem. First, the iHeart URL does not support HEAD and I had to add a conditional GET retrieval. Second, the response to a GET is a redirect. I find that curl can successfully handle the redirects as in:

curl --trace kcsjtrace.log -L -m 3 http://stream.revma.ihrhls.com/zc4814 >kcsj.out 2>kcsjerr.log

But thus far I have been unable to get this to work. My attempted redirect is redirected yet again until we hit the limit. If you have sufficient python http experience to tell me what I missed I would appreciate it, as that will get this working for just about all internet radio stations.

stream2chromecast.zip

@dhdurgee
Copy link
Author

I have done a bit more work on this and finally sorted out the iHeart issue, at least preliminarily. It appears that iHeart does not accept "HEAD" requiring "GET" instead. That combined with the redirection being a one-use only resulted in the loop. I also added some undocumented command line options that can be used for testing purposes. Finally, I did some tweaking of the device search to generalize it so that cast supporting devices other than actual Chromecast will be detected and supported.

stream2chromecast.zip

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants