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

LiveTV support (both DVR and free Plex streaming/IPTV) - Requesting code review #543

Draft
wants to merge 23 commits into
base: master
Choose a base branch
from

Conversation

nwithan8
Copy link
Contributor

@nwithan8 nwithan8 commented Aug 7, 2020

First time working with XML data. Seems rather straightforward once I understood how you handled parsing.
Have not written test files yet, waiting for feedback if you could give any.

plexapi/base.py Outdated Show resolved Hide resolved
plexapi/livetv.py Outdated Show resolved Hide resolved
plexapi/livetv.py Outdated Show resolved Hide resolved
plexapi/livetv.py Outdated Show resolved Hide resolved
plexapi/livetv.py Outdated Show resolved Hide resolved
plexapi/myplex.py Outdated Show resolved Hide resolved
plexapi/video.py Outdated
@@ -32,6 +33,8 @@ def _loadData(self, data):
""" Load attribute values from Plex XML response. """
self._data = data
self.listType = 'video'
self.guid = data.attrib.get('guid')
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Im not sold on the changed to the video class. This is getting reusing many places. Would it be better for subclass used own class for live tv/recordings) ? Im not sure.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hasn't given me an issue, but I can subclass it just to make sure

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Strike that, the TAG and type are the same for Live videos and non-live videos, so I can't register a new Plex object. Plex doesn't make a distinction between them, so I think it's safe to just add the guid and live attributes, and the record method (checks if video is live first)

@Hellowlol
Copy link
Collaborator

Nice work. Livetv etc support has been non existent because no contributer have used it. :)

@nwithan8
Copy link
Contributor Author

Thanks for the feedback. I will make the necessary changes.

@blacktwin
Copy link
Collaborator

@nwithan8 any updates? I have a tuner setup and am willing to test.

@nwithan8
Copy link
Contributor Author

@blacktwin been meaning to get back to this, got sidetracked with other projects. If you want to have a look over, be my guest.

@rockstar2020
Copy link

Has there been any progress with this feature addition?
It'll be a great addition to already awesome work!
Cheers

@nwithan8
Copy link
Contributor Author

nwithan8 commented Mar 6, 2021

Waiting on @pkkid or @Hellowlol

@jjlawren
Copy link
Collaborator

jjlawren commented Mar 6, 2021

The PR has merge conflicts. Those will need to be addressed first.

@rockstar2020
Copy link

Is anybody working on fixing the conflicts?
I have a HD HomeRun tuner on my plex and am ready to test the codes if it helps.

Many thanks in advance

@nwithan8
Copy link
Contributor Author

The PR has merge conflicts. Those will need to be addressed first.

Addressed

@rockstar2020
Copy link

Thanks @nwithan8,
This is great but while waiting for these changes turn into a new release I'd like to make manual changes in my instance and give these new features a try.
Can you give me a python command example on how I can retrive and then tune into a specific live TV channel?

Much appreciate it!

@nwithan8
Copy link
Contributor Author

nwithan8 commented Mar 16, 2021

Thanks @nwithan8,
This is great but while waiting for these changes turn into a new release I'd like to make manual changes in my instance and give these new features a try.
Can you give me a python command example on how I can retrive and then tune into a specific live TV channel?

Much appreciate it!

Here's a code snippet that I was using to test:

from plexapi import myplex, server

mypx = myplex.MyPlexAccount(username="username", password="password")
pxserver = server.PlexServer(baseurl="http://localhost:32400", token="aplextoken")
print(mypx.iptv)
live = pxserver.livetv
print(live.dvrs[0].title)

@rockstar2020
Copy link

Thanks again @nwithan8,
I was able to get the title of my DVR but after that I'd like to list all available channels and play one of the channels on my plex device.
Currently I have a script to search for shows, movies and playlists and play the selected content on my plex media player, but don't know how it should work for live tv.
Can you give me a hint?

Much appreciate your help.

@rockstar2020
Copy link

By the way, after making the changes manually, if I run a simple script to list all movies in my library I get the following message for each item found in the search:
INFO:plexapi:Failed to parse 2015-05-06 to datetime, defaulting to None

Here is my code to do the search:
for video in plex.library.section('Movies').all():
print(video.title)

Please note that if I use original files, the same simple search script runs flawlessly.
Hoping it could help troubleshooting it.

Cheers

@blacktwin
Copy link
Collaborator

blacktwin commented Mar 17, 2021

@nwithan8 Maybe it's me but is how you'd get to the guide?

plex = PlexServer(PLEX_URL, PLEX_TOKEN)
live = plex.livetv
dvr = live.dvrs[0]
print(live.guide())

I'm getting AttributeError: 'LiveTV' object has no attribute 'cloud_key'

I'm thinking that you LiveTV isn't pulling the cloud_key, In fact the LiveTV _loaddata isn't hit at all. How the cloud_key get loaded in order to interact with the guide?

@rockstar2020
Copy link

@nwithan8 Maybe it's me but is how you'd get to the guide?

plex = PlexServer(PLEX_URL, PLEX_TOKEN)
live = plex.livetv
dvr = live.dvrs[0]
print(live.guide())

I'm getting AttributeError: 'LiveTV' object has no attribute 'cloud_key'

I'm thinking that you LiveTV isn't pulling the cloud_key, In fact the LiveTV _loaddata isn't hit at all. How the cloud_key get loaded in order to interact with the guide?

I also got the same error when I tried to load the guide.

@nwithan8
Copy link
Contributor Author

It seems some things have changed with Plex since I started this, so I'm working on updating it. Turns out the "cloud key" is different if you're using the ZIP Code guide versus the local XMLTV path guide, so I'm having to account for that.

The code for this PR is still in progress. Should I/How do I retract/remove this PR request in the meantime?

@JonnyWong16
Copy link
Collaborator

Change the PR to a draft. The link is beneath the reviewers at the top right.

@nwithan8 nwithan8 marked this pull request as draft March 20, 2021 04:56
@rockstar2020
Copy link

Hi @nwithan8,
Any progress?

Thanks

class Setting(PlexObject):
""" Represents a single DVRDevice Setting."""

TAG = 'Setting'
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This conflicts with Setting(PlexObject) in settings.py

self.channelTitle = data.attrib.get('channelTitle')
self.beginsAt = utils.toDatetime(data.attrib.get('beginsAt'))
self.endsAt = utils.toDatetime(data.attrib.get('endsAt'))
self.onAir = cast(int, data.attrib.get('onAir'))
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

self.onAir = **utils.**cast(int, data.attrib.get('onAir'))

@iophobia
Copy link

Hi @nwithan8, Any progress?

Thanks

Seconding @rockstar2020: Any news on this draft, @nwithan8?

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

Successfully merging this pull request may close these issues.

8 participants