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
Show file tree
Hide file tree
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
Added pyxtream choice
  • Loading branch information
superolmo committed Jun 5, 2021
commit b97598a6235b734b7ec3d6100a3cbe6dd8362c7b
74 changes: 55 additions & 19 deletions usr/lib/hypnotix/hypnotix.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
import gettext
import gi
import locale
import os
from os import path as osp
import re
import setproctitle
import shutil
Expand Down Expand Up @@ -37,6 +37,13 @@
gettext.textdomain(APP)
_ = gettext.gettext

HYPNOTIX_HOME_PATH= osp.abspath(
osp.join(
osp.dirname(osp.realpath(__file__)),
"../../../"
)
)

PROVIDER_OBJ, PROVIDER_NAME = range(2)
PROVIDER_TYPE_ID, PROVIDER_TYPE_NAME = range(2)

Expand Down Expand Up @@ -107,10 +114,7 @@ def __init__(self, application):
# Used for redownloading timer
self.reload_timeout_sec = 60*5
self._timerid = -1

# Set the Glade file
gladefile = "/usr/share/hypnotix/hypnotix.ui"

gladefile = osp.join(HYPNOTIX_HOME_PATH,"usr/share/hypnotix/hypnotix.ui")
self.builder = Gtk.Builder()
self.builder.set_translation_domain(APP)
self.builder.add_from_file(gladefile)
Expand All @@ -122,7 +126,7 @@ def __init__(self, application):
self.info_window = self.builder.get_object("stream_info_window")

provider = Gtk.CssProvider()
provider.load_from_path("/usr/share/hypnotix/hypnotix.css")
provider.load_from_path(osp.join(HYPNOTIX_HOME_PATH,"usr/share/hypnotix/hypnotix.css"))

screen = Gdk.Display.get_default_screen(Gdk.Display.get_default())
# I was unable to found instrospected version of this
Expand All @@ -136,7 +140,11 @@ def __init__(self, application):
self.edit_mode = False

# Create variables to quickly access dynamic widgets
self.generic_channel_pixbuf = GdkPixbuf.Pixbuf.new_from_file_at_size("/usr/share/hypnotix/generic_tv_logo.png", 22, 22)
self.generic_channel_pixbuf = GdkPixbuf.Pixbuf.new_from_file_at_size(
osp.join(HYPNOTIX_HOME_PATH,"usr/share/hypnotix/generic_tv_logo.png"),
22,
22
)

widget_names = ["headerbar", "status_label", "status_bar", "sidebar", "go_back_button", "channels_box", \
"provider_button", "preferences_button", \
Expand Down Expand Up @@ -270,9 +278,24 @@ def __init__(self, application):
self.provider_type_combo.set_active(0) # Select 1st type
self.provider_type_combo.connect("changed", self.on_provider_type_combo_changed)

self.tv_logo.set_from_pixbuf(GdkPixbuf.Pixbuf.new_from_file_at_size("/usr/share/hypnotix/pictures/tv.svg", 258, 258))
self.movies_logo.set_from_pixbuf(GdkPixbuf.Pixbuf.new_from_file_at_size("/usr/share/hypnotix/pictures/movies.svg", 258, 258))
self.series_logo.set_from_pixbuf(GdkPixbuf.Pixbuf.new_from_file_at_size("/usr/share/hypnotix/pictures/series.svg", 258, 258))
self.tv_logo.set_from_pixbuf(GdkPixbuf.Pixbuf.new_from_file_at_size(
osp.join(HYPNOTIX_HOME_PATH,"usr/share/hypnotix/pictures/tv.svg"),
258,
258
)
)
self.movies_logo.set_from_pixbuf(GdkPixbuf.Pixbuf.new_from_file_at_size(
osp.join(HYPNOTIX_HOME_PATH,"usr/share/hypnotix/pictures/movies.svg"),
258,
258
)
)
self.series_logo.set_from_pixbuf(GdkPixbuf.Pixbuf.new_from_file_at_size(
osp.join(HYPNOTIX_HOME_PATH,"usr/share/hypnotix/pictures/series.svg"),
258,
258
)
)

self.reload(page="landing_page")

Expand Down Expand Up @@ -310,8 +333,8 @@ def show_groups(self, widget, content_type):
box = Gtk.Box()
for word in group.name.split():
word = word.lower()
badge = "/usr/share/hypnotix/pictures/badges/%s.png" % word
if os.path.exists(badge):
badge = osp.join(HYPNOTIX_HOME_PATH,"usr/share/hypnotix/pictures/badges/%s.png" % word)
if osp.exists(badge):
try:
pixbuf = GdkPixbuf.Pixbuf.new_from_file_at_size(badge, -1, 16)
surface = Gdk.cairo_surface_create_from_pixbuf(pixbuf, self.window.get_scale_factor())
Expand All @@ -320,7 +343,7 @@ def show_groups(self, widget, content_type):
except:
print("Could not load badge", badge)
elif word in BADGES.keys():
badge = "/usr/share/hypnotix/pictures/badges/%s.png" % BADGES[word]
badge = osp.join(HYPNOTIX_HOME_PATH,"usr/share/hypnotix/pictures/badges/%s.png" % BADGES[word])
try:
pixbuf = GdkPixbuf.Pixbuf.new_from_file_at_size(badge, -1, 16)
surface = Gdk.cairo_surface_create_from_pixbuf(pixbuf, self.window.get_scale_factor())
Expand Down Expand Up @@ -494,7 +517,7 @@ def download_channel_logos(self, logos_to_refresh):
for channel, image in logos_to_refresh:
if channel.logo_path == None:
continue
if os.path.isfile(channel.logo_path):
if osp.isfile(channel.logo_path):
continue
try:
response = requests.get(channel.logo, headers=headers, timeout=10, stream=True)
Expand Down Expand Up @@ -628,7 +651,7 @@ def navigate_to(self, page, name=""):
self.headerbar.set_subtitle(_("Reset providers"))

def open_keyboard_shortcuts(self, widget):
gladefile = "/usr/share/hypnotix/shortcuts.ui"
gladefile = osp.join(HYPNOTIX_HOME_PATH,"usr/share/hypnotix/shortcuts.ui")
builder = Gtk.Builder()
builder.set_translation_domain(APP)
builder.add_from_file(gladefile)
Expand Down Expand Up @@ -1153,7 +1176,10 @@ def open_about(self, widget):
dlg.set_program_name(_("Hypnotix"))
dlg.set_comments(_("Watch TV"))
try:
h = open('/usr/share/common-licenses/GPL', encoding="utf-8")
h = open(
osp.join(HYPNOTIX_HOME_PATH,'usr/share/common-licenses/GPL'),
encoding="utf-8"
)
s = h.readlines()
gpl = ""
for line in s:
Expand Down Expand Up @@ -1249,12 +1275,22 @@ def reload(self, page=None, refresh=False):

else:
# Load xtream class
from xtream import XTream
try:
# Try loading from pyxtream PYPI module
from pyxtream import XTream
except ModuleNotFoundError:
# If there was an error, load local copy
from xtream import XTream
# Download via Xtream
self.x = XTream(provider.url,provider.username,provider.password)
self.x = XTream(provider.name,provider.username,provider.password,provider.url,osp.expanduser("~/.hypnotix/providers"))
if self.x.authData != {}:
print("XTREAM Loading Channels")
self.x.load_iptv(provider)
self.x.load_iptv()
# Inform Provider of data
provider.channels = self.x.channels
provider.movies = self.x.movies
provider.series = self.x.series
provider.groups = self.x.groups

# Change redownload timeout
self.reload_timeout_sec = 60*60*2 # 2 hours
Expand Down
Loading