Ejemplo n.º 1
0
def get_movie(slug):
    # find movie
    data = util.get_url_json(FILM_DETAILS_TEMPLATE.format(slug))[0]
    price_data = util.get_url_json(PRICE_TEMPLATE.format(slug))

    show = {}
    show["title"] = data["title"]
    show["type"] = "movie"
    show["image"] = data["image_urls"]["portrait"]
    show["year"] = data["release_date"][:4]

    # lowest price
    price = ""
    if price_data["prices"]:
        if price_data["prices"][0]["rent"]["hd"]:
            price = price_data["prices"][0]["rent"]["hd"]
        else:
            price = price_data["prices"][0]["buy"]["hd"]

    # every show has an episode even movies
    show["episodes"] = [{
        "show":
        data["title"],
        "uri":
        URI_TEMPLATE.format(slug, urllib.parse.quote_plus(data["title"])),
        "s":
        0,
        "e":
        0,
        "price":
        price
    }]
    return show
Ejemplo n.º 2
0
def get_tv(slug):
	show = {}

	# find seasons
	season = util.get_url_json(TV_SEASON_TEMPLATE.format(slug))["seasons"]
	if season:
		availabilities = util.get_url_json(AVAILABILITIES_URL.format(slug))
		data = season[0]

		show["title"] = data["show_info"]["title"]
		show["type"] = "tv"
		show["image"] = data["image_urls"]["portrait"]
		show["year"] = data["show_info"]["release_date"][:4]

		show["episodes"] = []
		for e in data["episodes"]:
			episode_slug = slug + "/episode/" + str(e["episode_number"])

			# Get the availability of the episode
			for a in availabilities:
				if a["slug"] == episode_slug:
					date_from = dateutil.parser.parse(a["from"]).replace(tzinfo=pytz.utc)
					date_to = dateutil.parser.parse(a["to"]).replace(tzinfo=pytz.utc)

			# Only include the episode if it's available now
			if datetime.now(pytz.utc) > date_from:
				if datetime.now(pytz.utc) < date_to:
					episode = {}
					episode["title"] = e["title"]
					episode["uri"] = URI_TEMPLATE.format(slug, urllib.parse.quote_plus(data["show_info"]["title"]))
					episode["s"] = data["season_num"]
					episode["e"] = e["episode_number"]
					show["episodes"].append(episode)

	return show
Ejemplo n.º 3
0
def get_tv(slug):
    # find seasons
    data = util.get_url_json(TV_SEASON_TEMPLATE.format(slug))["seasons"][0]
    price_data = util.get_url_json(PRICE_TEMPLATE.format(slug))

    show = {}
    show["title"] = data["show_info"]["title"]
    show["type"] = "tv"
    show["image"] = data["image_urls"]["portrait"]
    show["year"] = data["show_info"]["release_date"][:4]

    # Price is per season. No prices per episode
    # lowest price
    price = ""
    if price_data["prices"]:
        price = price_data["prices"][0]["rent"]["hd"]
    print("TV Price: " + price)

    show["episodes"] = []
    for e in data["episodes"]:
        episode = {}
        episode["title"] = e["title"]
        episode["uri"] = URI_TEMPLATE.format(
            slug, urllib.parse.quote_plus(data["show_info"]["title"]))
        episode["s"] = data["season_num"]
        episode["e"] = e["episode_number"]
        episode["price"] = price
        show["episodes"].append(episode)

    return show
Ejemplo n.º 4
0
def get_tv(slug):
	# find seasons
	data = util.get_url_json(TV_SEASON_TEMPLATE.format(slug))["seasons"][0]
	price_data = util.get_url_json(PRICE_TEMPLATE.format(slug))

	show = {}
	show["title"] = data["show_info"]["title"]
	show["type"] = "tv"
	show["image"] = data["image_urls"]["portrait"]
	show["year"] = data["show_info"]["release_date"][:4]

	# Price is per season. No prices per episode
	# lowest price
	price = ""
	if price_data["prices"]:
		price = price_data["prices"][0]["rent"]["hd"]
	print ("TV Price: " + price)

	show["episodes"] = []
	for e in data["episodes"]:
			episode = {}
			episode["title"] = e["title"]
			episode["uri"] = URI_TEMPLATE.format(slug, urllib.parse.quote_plus(data["show_info"]["title"]))
			episode["s"] = data["season_num"]
			episode["e"] = e["episode_number"]
			episode["price"] = price
			show["episodes"].append(episode)

	return show
Ejemplo n.º 5
0
def get_episodes(series_id):
    episodes = []

    # find seasons
    data = util.get_url_json(SERIES_TEMPLATE.format(series_id))

    for season in data["seasons"]:
        season_id = season["id"]

        print(SEASON_TEMPLATE.format(series_id, season_id))

        data = util.get_url_json(SEASON_TEMPLATE.format(series_id, season_id))

        for e in data["episodes"]:
            episode = {}
            print("s" + str(season["season_number"]) + "e" +
                  str(e["episode"]) + " - " + e["titles"]["default"])
            episode["title"] = e["titles"]["default"]
            episode["uri"] = EPISODE_TEMPLATE.format(series_id, season_id,
                                                     e["id"])
            episode["s"] = season["season_number"]
            episode["e"] = e["episode"]
            if "year" in e["details"]:
                episode["year"] = e["details"]["year"]
            episodes.append(episode)
    return episodes
Ejemplo n.º 6
0
def get_listings():
		
	limit = 50 # seems to be the limit
	count = 0
	shows = []
	while True:
	
		data = util.get_url_json(DATA_URL.format(limit, limit*count))

		if len(data["series"]) == 0:
			break

		for series in data["series"]:
			show = {}
			print(series["titles"]["default"])
			show["title"] = series["titles"]["default"]
			show["episodes"] = get_episodes(series["id"])
			show["type"] = "tv"
			
			# note tmdb images are  used on the site, but supply image if available
			if "Web_4_3_tv_thumb" in series["images"][0]["format"]:
				show["image"] = series["images"][0]["format"]["Web_4_3_tv_thumb"]["source"]
			shows.append(show)

		count = count + 1
	return shows
Ejemplo n.º 7
0
def get_listings():

    limit = 50  # seems to be the limit
    count = 0
    shows = []
    while True:

        data = util.get_url_json(DATA_URL.format(limit, limit * count))

        if len(data["series"]) == 0:
            break

        for series in data["series"]:
            show = {}
            print(series["titles"]["default"])
            show["title"] = series["titles"]["default"]
            show["episodes"] = get_episodes(series["id"])
            show["type"] = "tv"

            # note tmdb images are  used on the site, but supply image if available
            if "Web_4_3_tv_thumb" in series["images"][0]["format"]:
                show["image"] = series["images"][0]["format"][
                    "Web_4_3_tv_thumb"]["source"]
            shows.append(show)

        count = count + 1
    return shows
Ejemplo n.º 8
0
def get_listings(tvod="false"):
    url = DATA_URL % tvod
    data = util.get_url_json(url)
    shows = []
    count = 0
    for product in data["products"]:

        episodes, show_type = get_episodes(product)
        if episodes:
            title = product["productTitle"].replace(" (HD)", "").strip()
            title = re.sub(r' Season \d+[a-zA-Z]?\b', '', title).strip()
            title = re.sub(r' Episode \d+[a-zA-Z]?\b', '', title).strip()
            title = re.sub(r'\,+$', '', title)
            print(title)
            for x in shows:
                # merge seasons
                if x["title"] == title:
                    x["episodes"] = x["episodes"] + episodes
                    break
            else:
                # new show
                show = {}
                show["title"] = title
                show["episodes"] = episodes
                show["type"] = show_type
                show["image"] = "http://www.skygo.co.nz" + product["imageURL"]
                shows.append(show)

        count = count + 1
    return shows
Ejemplo n.º 9
0
def get_movie(slug):
	# find movie
	data = util.get_url_json(FILM_DETAILS_TEMPLATE.format(slug))[0]
	price_data = util.get_url_json(PRICE_TEMPLATE.format(slug))

	show = {}
	show["title"] = data["title"]
	show["type"] = "movie"
	show["image"] = data["image_urls"]["portrait"]
	show["year"] = data["release_date"][:4]

	# lowest price
	price = price_data["prices"][0]["rent"]["hd"]

	# every show has an episode even movies
	show["episodes"] = [{"show" : data["title"], "uri" : URI_TEMPLATE.format(slug, urllib.parse.quote_plus(data["title"])), "s" : 0, "e" : 0, "price" : price}]
	return show
Ejemplo n.º 10
0
def get_listings():
	shows = []
	data = util.get_url_json(DATA_URL)

	all = []
	for feature in data["features"]:
		if "/film/" in feature["item"]:
			shows.append(get_movie(feature["item"]))
		else:
			shows.append(get_tv(feature["item"]))

	return shows
Ejemplo n.º 11
0
def get_listings():
	shows = []
	data = util.get_url_json(DATA_URL)

	all = []
	for slug in data["items"]:
		if "/film/" in slug:
			shows.append(get_movie(slug))
		else:
			shows.append(get_tv(slug))

	return shows
Ejemplo n.º 12
0
def get_listings():
    shows = []
    data = util.get_url_json(DATA_URL)

    all = []
    for slug in data["items"]:
        if "/film/" in slug:
            shows.append(get_movie(slug))
        else:
            shows.append(get_tv(slug))

    return shows
Ejemplo n.º 13
0
def get_tv(slug):
    show = {}

    # find seasons
    season = util.get_url_json(TV_SEASON_TEMPLATE.format(slug))["seasons"]
    if season:
        availabilities = util.get_url_json(AVAILABILITIES_URL.format(slug))
        data = season[0]

        show["title"] = data["show_info"]["title"]
        show["type"] = "tv"
        show["image"] = data["image_urls"]["portrait"]
        show["year"] = data["show_info"]["release_date"][:4]

        show["episodes"] = []
        for e in data["episodes"]:
            episode_slug = slug + "/episode/" + str(e["episode_number"])

            # Get the availability of the episode
            for a in availabilities:
                if a["slug"] == episode_slug:
                    date_from = dateutil.parser.parse(
                        a["from"]).replace(tzinfo=pytz.utc)
                    date_to = dateutil.parser.parse(
                        a["to"]).replace(tzinfo=pytz.utc)

            # Only include the episode if it's available now
            if datetime.now(pytz.utc) > date_from:
                if datetime.now(pytz.utc) < date_to:
                    episode = {}
                    episode["title"] = e["title"]
                    episode["uri"] = URI_TEMPLATE.format(
                        slug,
                        urllib.parse.quote_plus(data["show_info"]["title"]))
                    episode["s"] = data["season_num"]
                    episode["e"] = e["episode_number"]
                    show["episodes"].append(episode)

    return show
Ejemplo n.º 14
0
def get_listings():
	shows = []

	# Get TV listings. Make sure the season is published
	tv_data = util.get_url_json(TV_DATA_URL)
	for show in tv_data:
		for season in show["seasons"]:
			if season["status_id"] == 2:
				print("Season: " + str(season["slug"]))
				shows.append(get_tv(season["slug"]))

	# Get Film listings. Make sure the film is currently published
	film_data = util.get_url_json(FILM_DATA_URL)
	for film in film_data:
		if film["status_id"] == 2:
			published_date = dateutil.parser.parse(film["published_date"]).replace(tzinfo=pytz.utc)
			if datetime.now(pytz.utc) > published_date:
				slug = "/film/" + str(film["id"])
				print("Film: " + slug)
				shows.append(get_movie(slug))

	return shows
Ejemplo n.º 15
0
def get_movie(slug):
	# find movie
	data = util.get_url_json(FILM_DETAILS_TEMPLATE.format(slug))[0]

	# TODO: Need to check availabilities
	show = {}
	show["title"] = data["title"]
	show["type"] = "movie"
	show["image"] = data["image_urls"]["portrait"]
	show["year"] = data["release_date"][:4]

	# every show has an episode even movies
	show["episodes"] = [{"show" : data["title"], "uri" : URI_TEMPLATE.format(slug, urllib.parse.quote_plus(data["title"])), "s" : 0, "e" : 0}]
	return show
Ejemplo n.º 16
0
def get_listings():
    shows = []

    # Get TV listings. Make sure the season is published
    tv_data = util.get_url_json(TV_DATA_URL)
    for show in tv_data:
        for season in show["seasons"]:
            if season["status_id"] == 2:
                print("Season: " + str(season["slug"]))
                shows.append(get_tv(season["slug"]))

    # Get Film listings. Make sure the film is currently published
    film_data = util.get_url_json(FILM_DATA_URL)
    for film in film_data:
        if film["status_id"] == 2:
            published_date = dateutil.parser.parse(
                film["published_date"]).replace(tzinfo=pytz.utc)
            if datetime.now(pytz.utc) > published_date:
                slug = "/film/" + str(film["id"])
                print("Film: " + slug)
                shows.append(get_movie(slug))

    return shows
Ejemplo n.º 17
0
def get_episodes(series_id):
	episodes = []

	# find seasons
	data = util.get_url_json(SERIES_TEMPLATE.format(series_id))

	for season in data["seasons"]:
		season_id = season["id"]
		
		print(SEASON_TEMPLATE.format(series_id, season_id))
		 
		data = util.get_url_json(SEASON_TEMPLATE.format(series_id, season_id))
		
		for e in data["episodes"]:
			episode = {}
			print("s" + str(season["season_number"]) + "e" + str(e["episode"]) + " - " + e["titles"]["default"])
			episode["title"] = e["titles"]["default"]
			episode["uri"] = EPISODE_TEMPLATE.format(series_id, season_id, e["id"])
			episode["s"] = season["season_number"]
			episode["e"] = e["episode"]
			if "year" in e["details"]:
				episode["year"] = e["details"]["year"]
			episodes.append(episode)
	return episodes
Ejemplo n.º 18
0
def get_recent():
	shows = []
	data = util.get_url_json("https://www.lightbox.co.nz/xstream/sections/lists/21/elements?limit=10&offset=0")
	
	for series in data["elements"]["series"]:
		show = {}
		print(series["titles"]["default"])
		show["title"] = series["titles"]["default"]
		show["episodes"] = get_episodes(series["id"])
		show["type"] = "tv"
		
		# note tmdb images are  used on the site, but supply image if available
		if "Web_4_3_tv_thumb" in series["images"][0]["format"]:
			show["image"] = series["images"][0]["format"]["Web_4_3_tv_thumb"]["source"]
		shows.append(show)

	return shows
Ejemplo n.º 19
0
def get_recent():
    shows = []
    data = util.get_url_json(
        "https://www.lightbox.co.nz/xstream/sections/lists/21/elements?limit=10&offset=0"
    )

    for series in data["elements"]["series"]:
        show = {}
        print(series["titles"]["default"])
        show["title"] = series["titles"]["default"]
        show["episodes"] = get_episodes(series["id"])
        show["type"] = "tv"

        # note tmdb images are  used on the site, but supply image if available
        if "Web_4_3_tv_thumb" in series["images"][0]["format"]:
            show["image"] = series["images"][0]["format"]["Web_4_3_tv_thumb"][
                "source"]
        shows.append(show)

    return shows
Ejemplo n.º 20
0
def get_movie(slug):
    # find movie
    data = util.get_url_json(FILM_DETAILS_TEMPLATE.format(slug))[0]

    # TODO: Need to check availabilities
    show = {}
    show["title"] = data["title"]
    show["type"] = "movie"
    show["image"] = data["image_urls"]["portrait"]
    show["year"] = data["release_date"][:4]

    # every show has an episode even movies
    show["episodes"] = [{
        "show":
        data["title"],
        "uri":
        URI_TEMPLATE.format(slug, urllib.parse.quote_plus(data["title"])),
        "s":
        0,
        "e":
        0
    }]
    return show
Ejemplo n.º 21
0
def get_listings():	
	shows = []
	for channel in CHANNELS:
		page = 0
		data = None
		while page == 0 or (data and len(data) > 0):
			
			page = page + 1

			url = DATA_URL % (channel, API_KEY, page)
			print(url)

			data = util.get_url_json(url)["channel_programmes"]["elements"]

			for show_entry in data:
		
				show_title = show_entry["title"]

				for entry in show_entry["initial_children"]:
				
					episode = {}
					episode["show"] = entry["title"]
					#episode["date"] = entry["release_date"]
					episode["uri"] = EPISODE_BASE % entry["id"]
					episode["s"] = 0
					episode["e"] = 0

					if "subtitle" in entry:

						
						sub_title = entry["subtitle"]
						episode["show"] = sub_title
						#episode["e"] = sub_title

						matches = re.search(r"Series (\d+)\: (\d+)", sub_title)
						if matches:
							episode["s"] = matches.group(1)
							episode["e"] = matches.group(2)

						else:
							matches = re.search(r"Series (\d+)", sub_title)
							if matches:
								episode["s"] = matches.group(1)

							else:
								matches = re.search(r"Episode (\d+)", sub_title)
								if matches:
									episode["s"] = 1
									episode["e"] = matches.group(1)


							matches = re.search(r"Episode (\d+)", sub_title)
							if matches:
								if episode["s"] == 0:
									episode["s"] = 1
								episode["e"] = matches.group(1)
				
							"""if episode["s"] != 0 and episode["e"] == 0:
								title2 = entry.xpath(".//link[contains(@rel, 'self')]")[0].get('title')
								matches = re.search(r"(\d+)", title2)
								if matches:
									episode["e"] = matches.group(1)
									print("Episode b : ", episode["e"])"""



					print (" - ", episode["s"], episode["e"], episode["show"]) 
					print ("   ", episode["uri"]) 

					# Add to parent show
					for x in shows:
						# merge shows
						if x["title"] == show_title:
							x["episodes"] = x["episodes"] + [episode]
							break
					else:
						# new show 
						show = {}
						show["title"] = show_title
						show["episodes"] = [episode]
						show["type"] = "tv"
						show["image"] = show_entry["images"]["standard"].replace("{recipe}","192x108")
						shows.append(show)

	return shows
Ejemplo n.º 22
0
def get_listings():
    shows = []
    for channel in CHANNELS:
        page = 0
        data = None
        while page == 0 or (data and len(data) > 0):

            page = page + 1

            url = DATA_URL % (channel, API_KEY, page)
            print(url)

            data = util.get_url_json(url)["channel_programmes"]["elements"]

            for show_entry in data:

                show_title = show_entry["title"]

                for entry in show_entry["initial_children"]:

                    episode = {}
                    episode["show"] = entry["title"]
                    #episode["date"] = entry["release_date"]
                    episode["uri"] = EPISODE_BASE % entry["id"]
                    episode["s"] = 0
                    episode["e"] = 0

                    if "subtitle" in entry:

                        sub_title = entry["subtitle"]
                        episode["show"] = sub_title
                        #episode["e"] = sub_title

                        matches = re.search(r"Series (\d+)\: (\d+)", sub_title)
                        if matches:
                            episode["s"] = matches.group(1)
                            episode["e"] = matches.group(2)

                        else:
                            matches = re.search(r"Series (\d+)", sub_title)
                            if matches:
                                episode["s"] = matches.group(1)

                            else:
                                matches = re.search(r"Episode (\d+)",
                                                    sub_title)
                                if matches:
                                    episode["s"] = 1
                                    episode["e"] = matches.group(1)

                            matches = re.search(r"Episode (\d+)", sub_title)
                            if matches:
                                if episode["s"] == 0:
                                    episode["s"] = 1
                                episode["e"] = matches.group(1)
                            """if episode["s"] != 0 and episode["e"] == 0:
								title2 = entry.xpath(".//link[contains(@rel, 'self')]")[0].get('title')
								matches = re.search(r"(\d+)", title2)
								if matches:
									episode["e"] = matches.group(1)
									print("Episode b : ", episode["e"])"""

                    print(" - ", episode["s"], episode["e"], episode["show"])
                    print("   ", episode["uri"])

                    # Add to parent show
                    for x in shows:
                        # merge shows
                        if x["title"] == show_title:
                            x["episodes"] = x["episodes"] + [episode]
                            break
                    else:
                        # new show
                        show = {}
                        show["title"] = show_title
                        show["episodes"] = [episode]
                        show["type"] = "tv"
                        show["image"] = show_entry["images"][
                            "standard"].replace("{recipe}", "192x108")
                        shows.append(show)

    return shows