From: James Bunton Date: Wed, 22 Feb 2017 12:08:44 +0000 (+1100) Subject: Port to Python3, run with only Python+Node (no libs) X-Git-Url: https://code.delx.au/youtube-cgi/commitdiff_plain/7697735a88f01ad5d61f50663e4221e75fafc3ca Port to Python3, run with only Python+Node (no libs) --- diff --git a/README.md b/README.md index 75a57a3..6c2ae14 100644 --- a/README.md +++ b/README.md @@ -4,8 +4,7 @@ YouTubeCgi is a simple tool to download videos from YouTube. It is able to fetch ## Requirements -- python 2.7 -- python-lxml +- python 3 - nodejs 4+ ## CLI Usage diff --git a/youtube.cgi b/youtube.cgi index 1a80bf7..c0b5e99 100755 --- a/youtube.cgi +++ b/youtube.cgi @@ -1,21 +1,18 @@ -#!/usr/bin/python2 +#!/usr/bin/env python3 -from __future__ import division - -import cookielib import cgi +import html.parser +import http.cookiejar import json -from lxml import html import os import re -import resource import shutil import subprocess import sys import time -import urllib -import urllib2 -import urlparse +import urllib.error +import urllib.parse +import urllib.request MAX_MEMORY_BYTES = 128 * 1024*1024 @@ -41,13 +38,13 @@ class VideoUnavailable(Exception): def print_form(url="", msg=""): script_url = "http://%s%s" % (os.environ["HTTP_HOST"], os.environ["REQUEST_URI"]) - sys.stdout.write("Content-Type: application/xhtml+xml\r\n\r\n") + sys.stdout.write("Content-Type: text/html\r\n\r\n") sys.stdout.write(""" - - + + delx.net.au - YouTube Scraper - +