Skip to content

Instantly share code, notes, and snippets.

@geecko86
Created April 26, 2018 12:32
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save geecko86/8580b092f16f6aa6788829c4f53754da to your computer and use it in GitHub Desktop.
Save geecko86/8580b092f16f6aa6788829c4f53754da to your computer and use it in GitHub Desktop.
pass the public URL of a mytf1 video to open it in VLC. Made for linux.
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
#
# LPJ.py
#
# Copyright 2013 Unknown <geecko@archvaio>
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
# MA 02110-1301, USA.
#
#
from sys import argv
from os import system
from html.parser import HTMLParser
#import xml.etree.ElementTree as ET
from lxml import html
import requests
def UrlToStr(url):
import urllib.request
connection = urllib.request.urlopen(url)
page = connection.read()
return page
def getLastURL():
mainPage = str(UrlToStr("http://www.tf1.fr/tmc/quotidien-avec-yann-barthes/videos?filter=replay"))
index = mainPage.find("videoLink", mainPage.index('class="content"'))
startIndex = mainPage.rfind("href", 0, index) + 6
endIndex = mainPage.find("html", startIndex) + 4
return mainPage[startIndex:endIndex]
def main():
if len(argv) == 1 or argv[1] == "last" or argv[1] == "2":
vidURL = getLastURL()
if len(argv) > 1 and argv[1] == "2":
vidURL = vidURL.replace("premiere", "deuxieme")
print(vidURL)
else:
vidURL = argv[1]
#page = str(UrlToStr(vidURL))
tree = html.fromstring(requests.get(vidURL).content)
player = tree.xpath("//div[@class='iframe_player']")[0]
vidID = player.get("data-watid")
print('vlc ' + "http://www.wat.tv/get/iphone/"+ vidID +".m3u8?bwmin=100000&bwmax=3000000")
system('vlc ' + "http://www.wat.tv/get/iphone/"+ vidID +".m3u8?bwmin=100000&bwmax=3000000")
return 0
if __name__ == '__main__':
main()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment