Interact with a dizqueTV instance's API
Project description
dizqueTV-python
A Python library to interact with a dizqueTV instance
Installation
From GitHub
- Clone repository with
git clone https://github.com/nwithan8/dizqueTV-python.git
- Enter project folder with
cd dizqueTV-python
- Install requirements with
pip install -r requirements.txt
From PyPi
Run pip install dizqueTV
Setup
Import the API
class from the dizqueTV
module
Ex.
from dizqueTV import API
dtv = API(url="http://localhost:8000")
Enable verbose logging by passing verbose=True
into the API
object declaration
Usage
Methods
Channels
- Get all channels:
channels = dtv.channels
-> list ofChannel
objects - Get all channel numbers:
channel_numbers = dtv.channel_numbers
-> list of ints - Get a specific channel:
channel = dtv.get_channel(channel_number: int)
->Channel
object - Get brief info on a specific channel:
channel_info = dtv.get_channel_info(channel_number: int)
->{"name": str, "number": int, "icon": str}
- Add a channel:
new_channel = dtv.add_channel(programs: [Program, PlexAPI Video, ...], plex_server: PlexAPI Server [Optional], handle_errors: bool, **kwargs)
->Channel
object - Update a channel:
updated = dtv.update_channel(channel_number: int, **kwargs)
orChannel.update(**kwargs)
-> True/False - Delete a channel:
deleted = dtv.delete_channel(channel_number: int)
orChannel.delete()
-> True/False - Refresh a channel:
Channel.refresh()
-> None (reloadsChannel
object in-place) - Edit channel's watermark:
edited = Watermark.update(**kwargs)
-> True/False - Edit channel's FFMPEG settings:
edited = ChannelFFMPEGSettings.update(**kwargs)
-> True/False
Programs
- Get a channel's programs:
programs = Channel.programs
-> list ofMediaItem
objects - Add program (or PlexAPI Video) to a channel:
added = Channel.add_program(plex_item: PlexAPI Video, plex_server: PlexAPI Server, program: Program, **kwargs)
-> True/False - Add multiple programs (or PlexAPI Video) to a channel:
added = Channel.add_fillers(programs: [Program, PlexAPI Video, ...], plex_server: PlexAPI Server)
-> True/False - Add multiple programs to multiple channels:
added = dtv.add_programs_to_channels(programs: [Program], channels: [Channel], channel_numbers: [int])
-> True/False - Add X number of show episodes:
added = Channel.add_x_number_of_show_episodes(number_of_episodes: int, list_of_episodes: [Program, Episode, ...], plex_server: PServer (Optional))
-> True/False - Add X duration of show episodes:
added = Channel.add_x_duration_of_show_episodes(duration_in_milliseconds: int, list_of_episodes: [Program, Episode, ...], plex_server: PServer (Optional), allow_overtime: bool)
-> True/False - Delete a program:
deleted = Channel.delete_program(program: Program)
-> True/False - Delete all programs:
deleted = Channel.delete_all_programs()
-> True/False - Delete all episodes of a show (or of a season):
deleted = Channel.delete_show(show_name: str, season_number: int (Optional))
-> True/False - Sort programs by release date:
sorted = Channel.sort_programs_by_release_date()
-> True/False - Sort programs by season order:
sorted = Channel.sort_programs_by_season_order()
-> True/False - Sort programs alphabetically:
sorted = Channel.sort_programs_alphabetically()
-> True/False - Sort programs by duration:
sorted = Channel.sort_programs_by_duration()
-> True/False - Sort programs randomly:
sorted = Channel.sort_programs_randomly()
-> True/False - Sort programs cylically:
sorted = Channel.cyclical_shuffle()
-> True/False - Sort programs by block shuffle:
sorted = Channel.block_shuffle(block_length: int, randomize: bool)
-> True/False - Repeat programs:
repeated = Channel.replicate(how_many_times: int)
-> True/False - Repeat and shuffle programs
repeated = Channel.replicate_and_shuffle(how_many_times: int)
-> True/False - Remove duplicate programs:
sorted = Channel.remove_duplicate_programs()
-> True/False - Remove specials:
sorted = Channel.remove_specials()
-> True/False - Remove redirects:
sorted = Channel.remove_redirects()
-> True/False - Balance shows:
balanced = Channel.balance_programs(margin_of_error: float)
-> True/False - Add pad times:
added = Channel.pad_times(start_every_x_minutes: int)
-> True/False - Add reruns:
added = Channel.add_reruns(start_time: datetime.datetime, length_hours: int, times_to_repeat: int)
-> True/False - Add "Channel at Night":
added = Channel.add_channel_at_night(night_channel_number: int, start_hour: int (24-hour time), end_hour: int (24-hour time))
-> True/False - Fast forward:
success = Channel.fast_forward(seconds: int, minutes: int, hours: int, days: int, months: int, years: int)
-> True/False - Rewind:
success = Channel.rewind(seconds: int, minutes: int, hours: int, days: int, months: int, years: int)
-> True/False
Filler (Flex)
- Get a filler list:
filler_list = dtv.get_filler_list(filler_list_id: str)
->FillerList
object - Get all filler lists:
filler_lists = dtv.filler_lists
-> List ofFillerList
objects - Get a filler list info:
filler_list_info = dtv.get_filler_list_info(filler_list_id: str)
orFillerList.details
-> JSON - Get a filler list's channels:
filler_list_channels = dtv.get_filler_list_channels(filler_list_id: str)
orFillerList.channels
-> List ofChannel
objects - Get a filler list's content:
filler_list_contents = FillerList.contents
-> List ofFillerItem
objects - Add a filler list:
new_filler_list = dtv.add_filler_list(content: [Program, Video, Movie, Episode, ...], plex_server: PlexAPI Server, handle_errors: bool, **kwargs)
->FillerList
object - Update a filler list:
updated = dtv.update_filler_list(filler_list_id: str, **kwargs)
orFillerList.update(**kwargs)
-> True/False - Delete a filler list:
deleted = dtv.delete_filler_list(filler_list_id: str)
orFillerList.delete()
-> True/False - Refresh a filler list:
FillerList.refresh()
-> None (reloadsFillerList
object in-place) - Add a filler list to a channel:
added = Channel.add_filler_list(filler_list: FillerList, filler_list_id: str, weight: int, cooldown: int)
-> True/False - Add multiple filler lists to multiple channels:
added = dtv.add_filler_lists_to_channels(filler_lists: [FillerList, ...], channels: [Channel, ...], channel_numbers: [int, ...])
-> True/False - Delete a filler list from a channel:
deleted = Channel.delete_filler_list(filler_list: FillerList, filler_list_id: str)
-> True/False - Delete all filler lists from a channel:
deleted = Channel.delete_all_filler_lists()
-> True/False - Add a filler item (or PlexAPI Video) to a filler list:
added = FillerList.add_filler(plex_item: plexapi.media.Video/Movie/Episode, plex_server: PlexAPI Server, filler: FillerItem, **kwargs)
-> True/False - Add multiple filler items (or PlexAPI Video) to a filler list:
added = FillerList.add_fillers(fillers: [FillerItem, plexapi.media.Video/Movie/Episode, ...], plex_server: PlexAPI Server)
-> True/False - Delete a filler item:
deleted = FillerList.delete_filler(filler: FillerItem)
-> True/False - Delete all filler items:
deleted = FillerList.delete_all_fillers()
-> True/False - Sort filler items by duration:
sorted = FillerList.sort_filler_by_duration()
-> True/False - Sort filler items randomly:
sorted = FillerList.sort_filler_randomly()
-> True/False - Remove duplicate filler items:
sorted = FillerList.remove_duplicate_fillers()
-> True/False
Scheduling
- Get a channel's schedule:
schedule = Channel.schedule
->Schedule
object - Add a schedule to a channel:
added = Channel.add_schedule(time_slots: [TimeSlot, ...], **kwargs)
-> True/False - Update a channel's schedule:
updated = Channel.update_schedule(**kwargs)
orSchedule.update(**kwargs)
-> True/False - Delete a channel's schedule:
deleted = Channel.delete_schedule()
orSchedule.delete()
-> True/False - Add a time slot to a schedule:
added = Schedule.add_time_slot(time_slot: TimeSlot, time_string: str, **kwargs)
-> True/False - Edit a time slot on a schedule:
edited = Schedule.edit_time_slot(time_slot: TimeSlot, time_string: str, **kwargs)
orTimeSlot.edit(time_string: str, **kwargs)
-> True/False - Delete a time slot on a schedule:
deleted = Schedule.delete_time_slot(time_slot: TimeSlot)
orTimeSlot.delete()
-> True/False
Plex
- Get all Plex Media Servers:
servers = dtv.plex_servers
-> list ofPlexServer
objects - Get a specific Plex Media Server:
server = dtv.get_plex_server(server_name: str)
->PlexServer
object - Get a specific Plex Media Server status:
status = dtv.plex_server_status(server_name: str)
orPlexServer.status
-> True/False - Get a specific Plex Media Server foreign status:
status = dtv.plex_server_foreign_status(server_name: str)
orPlexServer.foreign_status
-> True/False - Add a Plex Media Server:
new_server = dtv.add_plex_server(**kwargs)
->PlexServer
object - Update a Plex Media Server:
updated = dtv.update_plex_server(server_name: str, **kwargs)
orPlexServer.update(**kwargs)
-> True/False - Delete a Plex Media Server:
deleted = dtv.delete_plex_server(server_name: str)
orPlexServer.delete()
-> True/False - Refresh a Plex Media Server:
PlexServer.refresh()
-> None (reloadsPlexServer
object in-place)
Settings
- Get FFMPEG settings:
settings = dtv.ffmpeg_settings
->FFMPEGSettings
object - Update FFMPEG settings:
updated = dtv.update_ffmpeg_settings(**kwargs)
orFFMPEGSettings.update(**kwargs)
-> True/False - Refresh FFMPEG settings:
FFMPEGSettings.refresh()
-> None (reloadsFFMPEGSettings
object in-place) - Reset FFMPEG settings:
reset = dtv.reset_ffmpeg_settings()
-> True/False - Get Plex settings:
settings = dtv.plex_settings
->PlexSettings
object - Update Plex settings:
updated = dtv.update_plex_settings(**kwargs)
orPlexSettings.update(**kwargs)
-> True/False - Refresh Plex settings:
PlexSettings.refresh()
-> None (reloadsPlexSettings
object in-place) - Reset Plex settings:
reset = dtv.reset_plex_settings()
-> True/False - Get XMLTV settings:
settings = dtv.xmltv_settings
->XMLTVSettings
object - Update XMLTV settings:
updated = dtv.update_xmltv_settings(**kwargs)
orXMLTVSettings.update(**kwargs)
-> True/False - Refresh XMLTV settings:
XMLTVSettings.reload()
-> None (reloadsXMLTVSettings
object in-place) - Reset XMLTV settings:
reset = dtv.reset_xmltv_settings()
-> True/False - Get HDHomeRun settings:
settings = dtv.hdhr_settings
->HDHomeRunSettings
object - Update HDHomeRun settings:
updated = dtv.update_hdhr_settings(**kwargs)
orHDHomeRunSettings.update(**kwargs)
-> True/False - Refresh HDHomeRun settings:
HDHomeRunSettings.refresh()
-> None (reloadsHDHomeRunSettings
object in-place) - Reset HDHomeRun settings:
reset = dtv.reset_hdhr_settings()
-> True/False
Information
- Get dizqueTV version:
version = dtv.dizquetv_version
-> str - Get FFMPEG version:
version = dtv.ffmpeg_version
-> str - Get XMLTV XML file:
xml = dtv.xmltv_xml
->xml.etree.ElementTree.Element
object - Refresh XMLTV XML file server-side:
refreshed = dtv.refresh_xml()
-> True/False - Get M3U playlist:
m3u = dtv.channels_m3u
->m3u8
object - Get HLS playlist:
hls = dtv.hls_m3u
->m3u8
object - Get last time XMLTV was refreshed:
last_time = dtv.last_xmltv_refresh
-> str
Guide
- Get dizqueTV guide:
guide = dtv.guide
->Guide
object - Get last guide update time:
update_time = dtv.last_guide_update
orGuide.last_update
->datetime.datetime
object - Get guide channel numbers:
guide_numbers = dtv.guide_channel_numbers
-> List of strings (not ints) - Get guide channels:
guide_channels = Guide.channels
-> List ofGuideChannel
objects - Get guide lineup data (JSON):
guide_lineup = dtv.guide_lineup_json
-> JSON - Get guide channel lineup (
GuideProgram
objects):guide_lineup = GuideChannel.get_lineup(from_date: datetime.datetime, to_date: datetime.datetime)
-> List ofGuideProgram
objects
Helper
- Convert a Python PlexAPI Video to a Program:
program = dtv.convert_plex_item_to_program(plex_item: PlexAPI Video, plex_server: PlexAPI Server)
orprogram = Channel.convert_plex_item_to_program(plex_item: PlexAPI Video, plex_server: PlexAPI Server)
-> Program - Convert a Python PlexAPI Video to a Filler:
filler = dtv.convert_plex_item_to_filler(plex_item: PlexAPI Video, plex_server: PlexAPI Server)
orfiller = Channel.convert_plex_item_to_filler(plex_item: PlexAPI Video, plex_server: PlexAPI Server)
-> Program - Convert a Python PlexAPI Server to a PlexServer:
server = dtv.convert_plex_server_to_dizque_plex_server(plex_server: PlexAPI Server)
-> PlexServer - Convert a DizqueTV Program or Redirect to a TimeSlot:
time_slot = dtv.make_time_slot_from_dizque_program(program: Union[Program, Redirect], time: str, order: str)
->TimeSlot
object - Repeat a list:
repeated_list = dtv.repeat_list(items: List, how_many_times: int)
-> List - Repeat and shuffle a list:
repeated_list = dtv.repeate_and_shuffle_list(items: List, how_many_times: int)
-> List
Classes
API
url
: dizqueTV API base urlverbose
: use verbose logging (default: False)dizquetv_version
: strffmpeg_version
: strplex_servers
: list ofPlexServer
objectschannels
: list ofChannel
objectschannel_numbers
: list of intschannel_count
: intffmpeg_settings
:FFMPEGSettings
objectplex_settings
:PlexSettings
objectxmltv_settings
:XMLTVSettings
objecthdhr_settings
:HDHomeRunSettings
objectlast_xmltv_refresh
: strxmltv_xml
:xml.etree.ElementTree.Element
objectm3u
:m3u8
object
Channel
programs
: list ofProgram
objectsfiller_lists
: List ofFillerList
objectsfillerRepeatCooldown
: intfallback
: List ofFillerItem
objectsicon
: str(url)disableFillerOverlay
: boolstartTime
: str(datetime)offlinePicture
: str(url)offlineSoundtrack
: str(url)offlineMode
: strnumber
: intname
: strduration
: intwatermark
:Watermark
objecttranscoding
:ChannelFFMPEGSettings
objectschedule
:Schedule
objectschedulableItems
: List ofTimeSlotItem
objectsstealth
: booljson
: JSON
Watermark
enabled
: boolwidth
: floatverticalMargin
: floathorizontalMargin
: floatduration
: intfixedSize
: boolposition
: strurl
: stranimated
: booljson
: JSON
Schedule
lateness
: intmaxDays
: intslots
: List ofTimeSlot
objectspad
: inttimeZoneOffset
: int
TimeSlot
time
: intshowId
: strorder
: str
TimeSlotItem
showId
: str
Program
title
: strkey
: strratingKey
: str(int)icon
: str(url)type
: strduration
: intsummary
: strrating
: strdate
: stryear
: intplexFile
: strfile
: strshowTitle
: strepisode
: intseason
: intshowIcon
: str(url)episodeIcon
: str(url)seasonIcon
: str(url)serverKey
: strisOffline
: false
FillerList
id
: strname
: strcount
: intdetails
: JSONcontent
: List ofFillerItem
objectschannels
: List ofChannel
objects
FillerItem
title
: strkey
: strratingKey
: str(int)icon
: str(url)type
: strduration
: intsummary
: strdate
: stryear
: intplexFile
: strfile
: strshowTitle
: strepisode
: intseason
: intshowIcon
: str(url)episodeIcon
: str(url)seasonIcon
: str(url)serverKey
: strisOffline
: false
Redirect
type
: "redirect"duration
: intchannel
: intisOffline
: true
PlexServer
name
: struri
: str(url)accessToken
: strindex
: intarChannels
: boolarGuide
: bool
XMLTVSettings
cache
: intrefresh
: intfile
: str
PlexSettings
streamPath
: strdebugLogging
: booldirectStreamBitrate
: str(int)transcodeBitrate
: str(int)mediaBufferSize
: inttranscodeMediaBufferSize
: intmaxPlayableResolution
: strmaxTranscodeResolution
: strvideoCodecs
: straudioCodecs
: strmaxAudioChannels
: str(int)audioBoost
: str(int)enableSubtitles
: boolsubtitleSize
: str(int)updatePlayStatus
: boolstreamProtocol
: strforceDirectPlay
: boolpathReplace
: strpathReplaceWith
: str
FFMPEGSettings
configVersion
: intffmpegPath
: strthreads
: intconcatMuxDelay
: str(int)logFfmpeg
: boolenableFFMPEGTranscoding
: boolaudioVolumePercent
: intvideoEncoder
: straudioEncoder
: strtargetResolution
: strvideoBitrate
: intvideoBufSize
: intaudioBitrate
: intaudioBufSize
: intaudioSampleRate
: intaudioChannels
: interrorScreen
: strerrorAudio
: strnormalizeVideoCodec
: boolnormalizeAudioCodec
: boolnormalizeResolution
: boolnormalizeAudio
: boolmaxFPS
: int
ChannelFFMPEGSettings
targetResolution
: strvideoBitrate
: intvideoBufSize
: intjson
: JSON
HDHomeRunSettings
tunerCount
: intautoDiscovery
: bool
Exceptions
MissingSettingsError
: The kwargs you have provided to create a new object (ex.Channel
orPlexServer
) are incompleteMissingParametersError
: You did not provide a required parameter in your function call (ex. provide a PlexAPI Server when adding PlexAPI Video to a channel)NotRemoteObjectError
: The object you are calling this method on is a locally-created object that does not exist on the dizqueTV serverChannelCreationError
: An error occurred when creating a Channel object
Contact
Please leave a pull request if you would like to contribute.
Join the dizqueTV Discord server (link on project page). My Discord username is nwithan8#8438
Follow me on Twitter: @nwithan8
Also feel free to check out my other projects here on GitHub or join the #developer channel in my Discord server below.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
dizqueTV-1.2.0.2.tar.gz
(39.7 kB
view hashes)
Built Distribution
dizqueTV-1.2.0.2-py3-none-any.whl
(49.8 kB
view hashes)
Close
Hashes for dizqueTV-1.2.0.2-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 2721ec0ec07a4811c2f856ccbd3c223757865089de0ab668bc7310d62634e366 |
|
MD5 | cdcf605ebdda99d53d4752a56be884db |
|
BLAKE2b-256 | 9d66731c732dfa89163a363ac69b5f2997b7a1d353db3dba7e4251a31f088c8e |