plex_playlist = plex_server.playlist(args.playlist[0]) if plex_playlist: all_items.extend(plex_playlist.items()) else: print(f"Could not find {args.playlist_name} playlist.") if all_items: if (args.interactive): answer = input( "Would you like to proceed with making the channel? (Y/N) ") else: answer = "Y" if type(answer) == str and answer.lower().startswith('y'): dtv = API(url=DIZQUETV_URL, verbose=args.verbose) new_channel_number = args.channel_number channel_name = args.channel_name final_programs = [] for item in all_items: if item.type == 'movie': final_programs.append(item) elif item.type == 'show': print(f"Grabbing episodes of {item.title}...") for episode in item.episodes(): if (hasattr(episode, "originallyAvailableAt") and episode.originallyAvailableAt) and \ (hasattr(episode, "duration") and episode.duration): final_programs.append(episode) new_channel = dtv.add_channel( programs=final_programs, plex_server=plex_server,
def get_library_sections(self) -> List[library.LibrarySection]: return self.server.library.sections() def get_all_section_items(self, section) -> List[media.Media]: return section.all() def get_plex_item(self, item, section_name=None) -> Union[media.Media, None]: if section_name: results = self.server.library.section(section_name).search( title=item.title) else: results = self.server.library.search(title=item.title) for media in results: if media.ratingKey and int(media.ratingKey) == int(item.ratingKey): return media return None dtv = API(url=DIZQUETV_URL) plex = Plex(url=PLEX_URL, token=PLEX_TOKEN) channel = dtv.get_channel(channel_number=args.channel_number) to_add = [] for program in channel.programs: plex_item = plex.get_plex_item(item=program) if plex_item: print(f"Adding {plex_item.title}...") to_add.append(plex_item) plex.reset_playlist(playlist_name=channel.name, items=to_add)
else: print("Getting random movie...") program = get_random_item_of_type( media_type='movie', program_list=channel_programs) else: raise Exception("Type is not 'show' or 'movie'.") if not program: print(f"Could not get a program to schedule for {start_time}.") else: print(f"Scheduling {program.showTitle} for {start_time}...") time_slots.append( make_time_slot_from_dizque_program(program=program, time=start_time, order=data.get( 'order', 'shuffle'))) return time_slots dtv = API(url=DIZQUETV_URL) channel = dtv.get_channel(channel_number=CHANNEL_NUMBER) if not channel: raise Exception(f"Could not find channel #{CHANNEL_NUMBER}") if channel.schedule: channel.delete_schedule() time_slots = create_time_slots(channel=channel) if channel.add_schedule(time_slots=time_slots, slots=[]): print(f"Created schedule for {channel.name}.") else: print(f"Could not create schedule for {channel.name}.")
section_name=None) -> Union[video.Show, None]: search_kwargs = {'title': show_name} if year: search_kwargs['year'] = year if section_name: results = self.server.library.section(section_name).search( **search_kwargs) else: results = self.server.library.search(**search_kwargs) for result in results: if type(result) == video.Show and result.title == show_name: return result return None dtv = API(url=DIZQUETV_URL) plex = Plex(url=PLEX_URL, token=PLEX_TOKEN) trakt = TraktConnection() this_channel = None # try to get channel by number first if args.channel_number: this_channel = dtv.get_channel(channel_number=args.channel_number) # if failed, get channel by name if not this_channel: for channel in dtv.channels: if channel.name == args.channel_name: this_channel = channel # if still failed, make new channel (try with number, but handle error if can't) if this_channel: print(
self.url = url self.token = token self.server = server.PlexServer(url, token) def get_playlists(self) -> List[playlist.Playlist]: return self.server.playlists() def get_playlist(self, playlist_name: str) -> Union[playlist.Playlist, None]: for playlist in self.get_playlists(): if playlist.title == playlist_name: return playlist return None dtv = API(url=DIZQUETV_URL, verbose=args.verbose) plex = Plex(url=PLEX_URL, token=PLEX_TOKEN) plex_playlist = plex.get_playlist(playlist_name=args.playlist_name) first_needed = False if args.channel_number: channel = dtv.get_channel(channel_number=args.channel_number) if not channel: print(f"Could not find channel #{args.channel_number}") exit(1) else: first_needed = True channel_numbers = dtv.channel_numbers if channel_numbers: new_channel_number = max(channel_numbers) + 1 else: new_channel_number = 1
plex_server = server.PlexServer(args.plex_url, args.plex_token) all_items = [] for studio in args.studio: print(f"Looking up content from {studio}...") studio_items = plex_server.library.search(studio=f"{quote(studio)}") if studio_items: print("Matching items:") for item in studio_items: if item.studio == studio: print(f"{item.studio} - {item.title}") all_items.append(item) if all_items: if not args.dry_run: dtv = API(url=args.dizquetv_url, verbose=args.verbose) if len(dtv.channel_numbers): new_channel_number = max(dtv.channel_numbers) + 1 else: new_channel_number = 1 final_programs = [] for item in all_items: if item.type == 'movie': final_programs.append(item) elif item.type == 'show': print(f"Grabbing episodes of {item.title}...") for episode in item.episodes(): if (hasattr(episode, "originallyAvailableAt") and episode.originallyAvailableAt) and \ (hasattr(episode, "duration") and episode.duration): final_programs.append(episode) new_channel = dtv.add_channel(programs=final_programs,
# COMPLETE THESE SETTINGS DIZQUETV_URL = "http://localhost:8000" parser = argparse.ArgumentParser() parser.add_argument('numbers', nargs="+", type=int, help="Channel number to start at, or a list of individual channel numbers.") parser.add_argument('-t', '--thru', type=int, default=None, help="Channel number to end at.") args = parser.parse_args() dtv = API(url=DIZQUETV_URL) channel_numbers = [] if args.thru: if len(args.numbers) > 1: print("Please provide only one start number if you are using --thru.") exit(1) else: for num in range(args.numbers[0], args.thru + 1): channel_numbers.append(num) else: channel_numbers = args.numbers print(f"The following channels will be deleted from dizqueTV:\n{', '.join(str(num) for num in channel_numbers)}") answer = input("Are you sure? (Y/N) ") if answer.lower()[0] != 'y':