mirror of
https://github.com/FakeTV/pseudo-channel.git
synced 2025-12-22 03:03:33 +00:00
Random TV Series episode capabilities added
Now, there is the ability to run random episodes in a TV series, without ruining your place in the series designation. To do so, simply edit your xml file so the lines title=<<name of show as usual>>, and the line's type=random.
This commit is contained in:
@@ -312,7 +312,7 @@ class PseudoChannel():
|
|||||||
"everyday"
|
"everyday"
|
||||||
]
|
]
|
||||||
section_dict = {
|
section_dict = {
|
||||||
"TV Shows" : ["series", "shows", "tv", "episodes", "tv shows", "show"],
|
"TV Shows" : ["series", "shows", "tv", "episodes", "tv shows", "show","random"],
|
||||||
"Movies" : ["movie", "movies", "films", "film"],
|
"Movies" : ["movie", "movies", "films", "film"],
|
||||||
"Videos" : ["video", "videos", "vid"],
|
"Videos" : ["video", "videos", "vid"],
|
||||||
"Music" : ["music", "songs", "song", "tune", "tunes"]
|
"Music" : ["music", "songs", "song", "tune", "tunes"]
|
||||||
@@ -328,6 +328,10 @@ class PseudoChannel():
|
|||||||
natural_start_time = self.translate_time(time.text)
|
natural_start_time = self.translate_time(time.text)
|
||||||
natural_end_time = 0
|
natural_end_time = 0
|
||||||
section = key
|
section = key
|
||||||
|
if section == "TV Shows" and time.attrib['type'] == "random":
|
||||||
|
mediaID_place=9999
|
||||||
|
else:
|
||||||
|
mediaID_place=0
|
||||||
day_of_week = child.tag
|
day_of_week = child.tag
|
||||||
strict_time = time.attrib['strict-time'] if 'strict-time' in time.attrib else 'false'
|
strict_time = time.attrib['strict-time'] if 'strict-time' in time.attrib else 'false'
|
||||||
time_shift = time.attrib['time-shift'] if 'time-shift' in time.attrib else '1'
|
time_shift = time.attrib['time-shift'] if 'time-shift' in time.attrib else '1'
|
||||||
@@ -348,7 +352,7 @@ class PseudoChannel():
|
|||||||
|
|
||||||
print "Adding: ", time.tag, section, time.text, time.attrib['title']
|
print "Adding: ", time.tag, section, time.text, time.attrib['title']
|
||||||
self.db.add_schedule_to_db(
|
self.db.add_schedule_to_db(
|
||||||
0, # mediaID
|
mediaID_place, # mediaID
|
||||||
title, # title
|
title, # title
|
||||||
0, # duration
|
0, # duration
|
||||||
natural_start_time, # startTime
|
natural_start_time, # startTime
|
||||||
@@ -540,6 +544,8 @@ class PseudoChannel():
|
|||||||
if section == "TV Shows":
|
if section == "TV Shows":
|
||||||
if str(entry[3]).lower() == "random":
|
if str(entry[3]).lower() == "random":
|
||||||
next_episode = self.db.get_random_episode()
|
next_episode = self.db.get_random_episode()
|
||||||
|
elif entry[2] == 9999:
|
||||||
|
next_episode = self.db.get_random_episode_alternate(entry[3])
|
||||||
else:
|
else:
|
||||||
next_episode = self.db.get_next_episode(entry[3])
|
next_episode = self.db.get_next_episode(entry[3])
|
||||||
if next_episode != None:
|
if next_episode != None:
|
||||||
|
|||||||
@@ -514,6 +514,14 @@ class PseudoChannelDatabase():
|
|||||||
self.cursor.execute(sql)
|
self.cursor.execute(sql)
|
||||||
return self.cursor.fetchone()
|
return self.cursor.fetchone()
|
||||||
|
|
||||||
|
####mutto233 made this one####
|
||||||
|
def get_random_episode_alternate(self,series):
|
||||||
|
|
||||||
|
sql = "SELECT * FROM episodes WHERE (showTitle LIKE ? AND id IN (SELECT id FROM episodes ORDER BY RANDOM() LIMIT 1))"
|
||||||
|
self.cursor.execute(sql, (series, ))
|
||||||
|
return self.cursor.fetchone()
|
||||||
|
####mutto233 made this one####
|
||||||
|
|
||||||
def get_random_movie(self):
|
def get_random_movie(self):
|
||||||
|
|
||||||
sql = "SELECT * FROM movies WHERE id IN (SELECT id FROM movies ORDER BY RANDOM() LIMIT 1)"
|
sql = "SELECT * FROM movies WHERE id IN (SELECT id FROM movies ORDER BY RANDOM() LIMIT 1)"
|
||||||
|
|||||||
Reference in New Issue
Block a user