Windows
from asyncio.windows_events import NULL
from email.mime import image
from multiprocessing.sharedctypes import Value
from operator import contains
from unittest import result, skip
from urllib import response
from wsgiref import headers
from re import search
import requests
from ipytv import playlist
from ipytv.channel import IPTVAttr, IPTVChannel
from ipytv.playlist import M3UPlaylist
from ipytv.doctor import M3UDoctor, M3UPlaylistDoctor
import os
import re
# variables
# Import TMDb from tmdbv3api module using the import keyword
from tmdbv3api import TMDb
# Import Movie from tmdbv3api module using the import keyword
from tmdbv3api import Movie
from tmdbv3api import TV
# Initialize the TMDb object and store it in a variable
tmdbobj=TMDb()
# Using the export command below, you may also export your API key as an environment variable.
# command:- export TMDb_API_KEY= 'XXX123ABC456XYZ789' << example obviously
# Apply language attribute to the above tmdb object to specify the
# language of the data must be get from TMDB. It is optional.
tmdbobj.language = 'en'
# Set debug to True to make it enable for debugging.
tmdbobj.debug = True
# Initialize the Movie object and store it in another variable
movieobj=Movie()
tvobj=TV()
if __name__ == "__main__":
############################################################
# ONLY CHANGE THESE USER DEFINED VARIABLES IN THIS SECTION #
############################################################
# your TMDB api key
TMDb.api_key= 'XXX123ABC456XYZ789'
# your .m3u url from provider. If using a file use the location
# where it is stored and change pl = playlist.loadu(M3Uurl) >> pl = playlist.loadf(filename)
M3Uurl = "https://XXXXX.com/iptv/123456/ab3m7j2g8x/YYY"
# location of .m3u file output on completion
file = "C:/Users/MyPC/Google Drive/MyVOD.m3u"
############################################################
########## ########## ########## ##########
############################################################
# open file and write #NEXTM3U on the first line and close it
file2 = open(file, "w+")
file2.write("#EXTM3U" + '\n')
file2.close
# load playlist and leverage m3u-ipytv, sort if Movie or TV VOD
pl = playlist.loadu(M3Uurl)
channel = IPTVChannel(pl)
for channel in pl:
type = channel.attributes
Mov = "{'group-title': 'Movie VOD'}"
Tv = "{'group-title': 'TV VOD'}"
# if Movie filter title
if str(Mov) == str(type):
title0 = channel.name
t1 = re.compile('(\s*)HD : (\s*)')
title1 = t1.sub(' ', title0)
t2 = re.compile("^\d+\s|\s\d+\s|\s\d+$")
title2 = t2.sub(' ', title1)
# for each movie title search for TMDB poster and rebuild .m3u and append
url = channel.url
search = movieobj.search(title2)
for index, res in enumerate(search):
if not index:
if res is not None:
Poster = "https://image.tmdb.org/t/p/w500" + str(res.poster_path)
reject = "https://image.tmdb.org/t/p/w500None"
# if poster found
if Poster != reject:
file3 = open(file, "a+")
file3.write("#EXTINF:0 " + str("tvg-logo=" + '"' + Poster + '",' + " group-title=" + '"' + "Movie VOD" + '", ' + channel.name) + '\n')
file3.write("#EXTGRP:Movie VOD" '\n')
file3.write(url + '\n')
file3.close
# poster not found
else:
file3 = open(file, "a+")
file3.write("#EXTINF:0 " + str(" group-title=" + '"' + "Movie VOD" + '", ' + channel.name) + '\n')
file3.write("#EXTGRP:Movie VOD" '\n')
file3.write(url + '\n')
file3.close
# if TV filter title
elif str(Tv) == str(type):
title0 = channel.name
t1 = re.compile('(\s*)HD : | AU | NZ(\s*)')
title1 = t1.sub(' ', title0)
t2 = re.compile('(\s*)[S]+[0-9]+[0-9](\s*)')
title2 = t2.sub(' ', title1)
t3 = re.compile('(\s*)[E]+[0-9]+[0-9](\s*)')
title3 = t3.sub(' ', title2)
t4 = re.compile("^\d+\s|\s\d+\s|\s\d+$")
title4 = t4.sub(' ', title3)
title5 = title4.lstrip(' ')
x = len(title5)
if x == 0:
title6 = title3
else:
title6 = title5
if title6.startswith("Jimmy Fallon"):
title7 = "Jimmy Fallon"
elif title6.startswith("Jimmy Kimmel"):
title7 = "Jimmy Kimmel"
elif title6.startswith("Stephen Colbert"):
title7 = "Stephen Colbert"
elif title6.startswith("1923"):
title7 = "1923"
elif title6.startswith("Seth Meyers"):
title7 = "Seth Meyers"
elif title6.startswith("The Daily Show"):
title7 = "The Daily Show"
else:
title7 = title6
# for each tv title search TMDB for poster and rebuild .m3u and append
url = channel.url
search = tvobj.search(title7)
for index, res in enumerate(search):
if not index:
if res is not None:
Poster = "https://image.tmdb.org/t/p/w500" + str(res.poster_path)
reject = "https://image.tmdb.org/t/p/w500None"
# if poster found
if Poster != reject:
file3 = open(file, "a+")
file3.write("#EXTINF:0 " + str("tvg-logo=" + '"' + Poster + '",' + " group-title=" + '"' + "TV VOD" + '", ' + channel.name) + '\n')
file3.write("#EXTGRP:TV VOD" '\n')
file3.write(url + '\n')
file3.close
# poster not found
else:
file3 = open(file, "a+")
file3.write("#EXTINF:0 " + str(" group-title=" + '"' + "TV VOD" + '", ' + channel.name) + '\n')
file3.write("#EXTGRP:TV VOD" '\n')
file3.write(url + '\n')
file3.close
Linux
#!/usr/bin/env python3
#-*- coding: utf-8 -*-
from email.mime import image
from multiprocessing.sharedctypes import Value
from operator import contains
from unittest import result, skip
from urllib import response
from wsgiref import headers
from re import search
import requests
from ipytv import playlist
from ipytv.channel import IPTVAttr, IPTVChannel
from ipytv.playlist import M3UPlaylist
from ipytv.doctor import M3UDoctor, M3UPlaylistDoctor
import os
import re
# variables
# Import TMDb from tmdbv3api module using the import keyword
from tmdbv3api import TMDb
# Import Movie from tmdbv3api module using the import keyword
from tmdbv3api import Movie
from tmdbv3api import TV
# Initialize the TMDb object and store it in a variable
tmdbobj=TMDb()
# Using the export command below, you may also export your API key as an environment variable.
# command:- export TMDb_API_KEY= 'XXX123ABC456XYZ789' << example obviously
# Apply language attribute to the above tmdb object to specify the
# language of the data must be get from TMDB. It is optional.
tmdbobj.language = 'en'
# Set debug to True to make it enable for debugging.
tmdbobj.debug = True
# Initialize the Movie object and store it in another variable
movieobj=Movie()
tvobj=TV()
if __name__ == "__main__":
############################################################
# ONLY CHANGE THESE USER DEFINED VARIABLES IN THIS SECTION #
############################################################
# your TMDB api key
TMDb.api_key= 'XXX123ABC456XYZ789'
# your .m3u url from provider. If using a file use the location
# where it is stored and change pl = playlist.loadu(M3Uurl) >> pl = playlist.loadf(filename)
M3Uurl = "https://ccc.com/iptv/1234567/3Ui458Bn/XXX"
# location of .m3u file output on completion
file = '/mnt/Google/MyVOD.m3u'
############################################################
########## ########## ########## ##########
############################################################
# check if file exists and remove if it does
#if os.path.exists(file):
# os.remove(file)
# open file and write #NEXTM3U on the first line and close it
file2 = open(file, "w+")
file2.write("#EXTM3U" + '\n')
file2.close
# load playlist and leverage m3u-ipytv, sort if Movie or TV VOD
pl = playlist.loadu(M3Uurl)
channel = IPTVChannel(pl)
for channel in pl:
type = channel.attributes
Mov = "{'group-title': 'Movie VOD'}"
Tv = "{'group-title': 'TV VOD'}"
# if Movie filter title
if str(Mov) == str(type):
title0 = channel.name
t1 = re.compile('(\s*)HD : (\s*)')
title1 = t1.sub(' ', title0)
t2 = re.compile("^\d+\s|\s\d+\s|\s\d+$")
title2 = t2.sub(' ', title1)
# for each movie title search for TMDB poster and rebuild .m3u and append
url = channel.url
search = movieobj.search(title2)
for index, res in enumerate(search):
if not index:
if res is not None:
Poster = "https://image.tmdb.org/t/p/w500" + str(res.poster_path)
reject = "https://image.tmdb.org/t/p/w500None"
# if poster found
if Poster != reject:
file3 = open(file, "a+")
file3.write("#EXTINF:0 " + str("tvg-logo=" + '"' + Poster + '",' + " group-title=" + '"' + "Movie VOD" + '", ' + channel.name) + '\n')
file3.write("#EXTGRP:Movie VOD" '\n')
file3.write(url + '\n')
file3.close
# poster not found
else:
file3 = open(file, "a+")
file3.write("#EXTINF:0 " + str(" group-title=" + '"' + "Movie VOD" + '", ' + channel.name) + '\n')
file3.write("#EXTGRP:Movie VOD" '\n')
file3.write(url + '\n')
file3.close
# if TV filter title
elif str(Tv) == str(type):
title0 = channel.name
t1 = re.compile('(\s*)HD : | AU | NZ(\s*)')
title1 = t1.sub(' ', title0)
t2 = re.compile('(\s*)[S]+[0-9]+[0-9](\s*)')
title2 = t2.sub(' ', title1)
t3 = re.compile('(\s*)[E]+[0-9]+[0-9](\s*)')
title3 = t3.sub(' ', title2)
t4 = re.compile("^\d+\s|\s\d+\s|\s\d+$")
title4 = t4.sub(' ', title3)
title5 = title4.lstrip(' ')
x = len(title5)
if x == 0:
title6 = title3
else:
title6 = title5
if title6.startswith("Jimmy Fallon"):
title7 = "Jimmy Fallon"
elif title6.startswith("Jimmy Kimmel"):
title7 = "Jimmy Kimmel"
elif title6.startswith("Stephen Colbert"):
title7 = "Stephen Colbert"
elif title6.startswith("1923"):
title7 = "1923"
elif title6.startswith("Seth Meyers"):
title7 = "Seth Meyers"
elif title6.startswith("The Daily Show"):
title7 = "The Daily Show"
else:
title7 = title6
# for each tv title search TMDB for poster and rebuild .m3u and append
url = channel.url
search = tvobj.search(title7)
for index, res in enumerate(search):
if not index:
if res is not None:
Poster = "https://image.tmdb.org/t/p/w500" + str(res.poster_path)
reject = "https://image.tmdb.org/t/p/w500None"
# if poster found
if Poster != reject:
file3 = open(file, "a+")
file3.write("#EXTINF:0 " + str("tvg-logo=" + '"' + Poster + '",' " group-title=" + '"' + "TV VOD" + '", ' + channel.name) + '\n')
file3.write("#EXTGRP:TV VOD" '\n')
file3.write(url + '\n')
file3.close
# poster not found
else:
file3 = open(file, "a+")
file3.write("#EXTINF:0 " + str(" group-title=" + '"' + "TV VOD" + '", ' + channel.name) + '\n')
file3.write("#EXTGRP:TV VOD" '\n')
file3.write(url + '\n')
file3.close
Total 0 Votes
0
0