Jump to content

Recommended Posts

Posted (edited)

I am new to heliohost.

I am running a python script which needs module youtube-dl:  https://youtube-dl.org

 

can you please install python module youtube-dl

 

I am trying to run a script which demand this.

 

i am on Johnny server.

 

Thanks and you guys are doing great job.

Edited by carlosmc
Posted

What does the script that needs this do?

the script allows that from the wii console, videos from youtube.com can be viewed through youtube-dl (the official support of youtube in this console already finished) is only for personal use

Posted

this is the script

 

 

#!/usr/bin/python

import cgi
form = cgi.FieldStorage()

import re
import httplib
import urllib
import subprocess
import sys
import os

# IMPORTANT: This directory must exist, and the web user must have full access to it
media_dir = "/public_html/media/"

if ("query" not in form and "watch" not in form):
    print("Content-type: text/plain\n")
    print("No search query entered.")
    sys.exit(0)

if ("watch" in form):
    watch = re.sub(r'[./]', '', str(form["watch"].value))
    outfile = media_dir + watch + ".mp4"
    subprocess.call(["youtube-dl", "-f", "18", "-o", outfile, "https://www.youtube.com/watch?v=" + watch], stdout = open("/dev/null", "w"))
    print("Content-type: video/mp4")
    print("Content-Length: " + str(os.path.getsize(outfile)) + "\n")
    f = open(outfile)
    while (True):
        chunk = f.read(1048576)
        if (len(chunk) == 0):
            f.close()
            break
        sys.stdout.write(chunk)
    sys.exit(0)


query = str(form["hola"].value)

conn = httplib.HTTPSConnection("www.youtube.com")
conn.request("GET", "/results?search_query=" + urllib.quote(query))
res = conn.getresponse()
ytlines = res.read().split("\n")
conn.close()

names = []
urls = []
for i in ytlines:
    m = re.search('/watch\?v=[^"]*"[^>]*title="[^"]*"', i)
    if (m):
        if (re.search('ypc-badge', i)):
            continue
        m = i[m.start():m.end()]
        names.append(re.sub('/watch\?v=([^"]*)".*title="([^"]*)".*', r'\2', m))
        urls.append(re.sub('/watch\?v=([^"]*)".*title="([^"]*)".*', r'\1', m))

print("Content-type: text/plain\n")
for i,j in zip(names, urls):
    print("youtube.py?watch=" + j + "&videoname=/" + i)
   

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...