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

Relaxing channel name check in Xtream API #178

Merged
merged 27 commits into from
Dec 8, 2021
Merged
Changes from 1 commit
Commits
Show all changes
27 commits
Select commit Hold shift + click to select a range
293963b
Added Initial XTream
superolmo May 28, 2021
a1dca48
Added XTream Series
superolmo Jun 2, 2021
d0be0a5
Added check for local logo_path
superolmo Jun 4, 2021
a84f7ce
Back to fixed path
superolmo Jun 4, 2021
b97598a
Added pyxtream choice
superolmo Jun 5, 2021
0530fc9
Replaced the test server
superolmo Jun 6, 2021
b56a6fb
Replaced the test server
superolmo Jun 6, 2021
ab11dfd
Fixed cache-path and added regex search
superolmo Jun 7, 2021
5d4a971
Merge branch 'master' of github.com:superolmo/hypnotix
superolmo Jun 7, 2021
2b8d127
Merge branch 'master' of https://github.com/linuxmint/hypnotix into l…
superolmo Jun 7, 2021
b38d61e
Changed osp back to os.path
superolmo Jun 7, 2021
7db1d62
Changed osp back to os.path
superolmo Jun 7, 2021
06517d6
Merge branch 'linuxmin-master'
superolmo Jun 7, 2021
2a45eb1
Fixed bug in the way it reload from cache
superolmo Jun 12, 2021
e79a848
Fixed missing provider when it doesn't load
superolmo Jun 18, 2021
dcbb6a1
Improved handling of missing keys
superolmo Jun 18, 2021
97b9e73
Fixed Categories and cleaned up the code
superolmo Jun 18, 2021
32af21f
Updated function names to follow PEP8
superolmo Jun 28, 2021
51e6d1d
Added check before authorizing
superolmo Sep 27, 2021
e6390d9
Merge remote-tracking branch 'upstream/master'
superolmo Sep 27, 2021
fca44f2
Scale down changes
superolmo Sep 27, 2021
0b41feb
Revert some more changes
superolmo Sep 27, 2021
215e191
Revert last changes
superolmo Sep 27, 2021
76bd0f2
Revert flag name
superolmo Sep 27, 2021
211db79
Discard streams w/o name, change live radio type to live stream
superolmo Nov 5, 2021
c8577a2
Rebase to upstream master
superolmo Nov 28, 2021
a7d447c
Fix subgroup name check
superolmo Dec 1, 2021
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Improved handling of missing keys
  • Loading branch information
superolmo committed Jun 18, 2021
commit dcbb6a1a35b0c8353079068a854e3dcc04a865d3
136 changes: 104 additions & 32 deletions usr/lib/hypnotix/xtream.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,24 +32,25 @@
import re

class Channel():
stream_type = ""
logo_path = ""
logo = ""
info = ""
# Required by Hypnotix
id = ""
url = ""

# What is the difference between the below name and title?
name = ""
name = "" # What is the difference between the below name and title?
logo = ""
logo_path = ""
group_title = ""
title = ""
url = ""

# Group info
group_title = ""
# XTream
stream_type = ""
group_id = ""

is_adult = ""
added = ""
epg_channel_id = ""
added = ""

# This contains the raw JSON data
raw = ""

def __init__(self, xtream: object, group_title, stream_info):
stream_type = stream_info['stream_type']
Expand All @@ -66,26 +67,38 @@ def __init__(self, xtream: object, group_title, stream_info):
self.raw = stream_info

stream_name = stream_info['name']

# Required by Hypnotix
self.id = stream_info['stream_id']
self.name = stream_name
self.logo = stream_info['stream_icon']
self.logo_path = xtream.getLogoLocalPath(self.logo)

self.group_id = stream_info['category_id']

self.group_title = group_title
self.title = stream_name

# Check if category_id key is available
if "category_id" in stream_info.keys():
self.group_id = stream_info['category_id']

if stream_type == "live":
stream_extension = "ts"

self.is_adult = stream_info['is_adult']
self.epg_channel_id = stream_info['epg_channel_id']
# Default to 0
self.is_adult = 0
# Check if is_adult key is available
if "is_adult" in stream_info.keys():
self.is_adult = stream_info['is_adult']

# Check if epg_channel_id key is available
if "epg_channel_id" in stream_info.keys():
self.epg_channel_id = stream_info['epg_channel_id']

self.added = stream_info['added']

elif stream_type == "movie":
stream_extension = stream_info['container_extension']

# Required by Hypnotix
self.url = "{}/{}/{}/{}/{}.{}".format(
xtream.server,
stream_info['stream_type'],
Expand All @@ -109,6 +122,18 @@ def export_json(self):
return jsondata

class Group():
# Required by Hypnotix
name = ""
group_type = ""
channels = []
series = []

# XTream
group_id = ""

# This contains the raw JSON data
raw = ""

def __init__(self, group_info: dict, stream_type: str):
# Raw JSON Group
self.raw = group_info
Expand All @@ -125,12 +150,24 @@ def __init__(self, group_info: dict, stream_type: str):
print("Unrecognized stream type `{}` for `{}`".format(
stream_type, group_info
))

self.name = group_info['category_name']
self.group_id = group_info['category_id']
self.channels = []
self.series = []

# Check if category_id key is available
if "category_id" in group_info.keys():
self.group_id = group_info['category_id']

class Episode():
# Required by Hypnotix
title = ""
name = ""


# XTream

# This contains the raw JSON data
raw = ""

def __init__(self, xtream: object, series_info, group_title, episode_info) -> None:
# Raw JSON Episode
self.raw = episode_info
Expand Down Expand Up @@ -160,26 +197,54 @@ def __init__(self, xtream: object, series_info, group_title, episode_info) -> No
print("{} - Bad URL? `{}`".format(self.name, self.url))

class Serie():
# Required by Hypnotix
name = ""
logo = ""
logo_path = ""
seasons = []
episodes = []

# XTream
series_id = ""
plot = ""
youtube_trailer = ""
genre = ""

# This contains the raw JSON data
raw = ""

def __init__(self, xtream: object, series_info):
# Raw JSON Series
self.raw = series_info

# Required by Hypnotix
self.name = series_info['name']
self.series_id = series_info['series_id']
self.logo = series_info['cover']
self.logo_path = xtream.getLogoLocalPath(self.logo)

self.seasons = {}
self.episodes = {}

self.plot = series_info['plot']
self.youtube_trailer = series_info['youtube_trailer']
self.genre = series_info['genre']
# Check if category_id key is available
if "series_id" in series_info.keys():
self.series_id = series_info['series_id']

# Check if plot key is available
if "plot" in series_info.keys():
self.plot = series_info['plot']

# Check if youtube_trailer key is available
if "youtube_trailer" in series_info.keys():
self.youtube_trailer = series_info['youtube_trailer']

# Check if genre key is available
if "genre" in series_info.keys():
self.genre = series_info['genre']

class Season():
# Required by Hypnotix
name = ""
episodes = {}

def __init__(self, name):
self.name = name
self.episodes = {}

class XTream():

Expand Down Expand Up @@ -367,12 +432,19 @@ def getLogoLocalPath(self, logoURL: str) -> str:

# Authentication returns information about the account and server:
def authenticate(self):
r = requests.get(self.get_authenticate_URL())
self.authData = r.json()
self.authorization = {
"username": self.authData["user_info"]["username"],
"password": self.authData["user_info"]["password"]
self.authData = {}
try:
r = requests.get(
self.get_authenticate_URL()
)
self.authData = r.json()
self.authorization = {
"username": self.authData["user_info"]["username"],
"password": self.authData["user_info"]["password"]
}
except requests.exceptions.ConnectionError:
# If connection refused
print("{} - Connection refused URL: {}".format(self.name, self.server))

def loadFromFile(self, filename) -> dict:
"""Try to load the distionary from file
Expand Down