Script pentru download trailere apple

5 posts / 0 new
Last post
MCM1
Script pentru download trailere apple
AttachmentSize
trailerDownloader.py.txt2.03 KB

Ei bine, am gasit pe internet un script care imi permite sa descarc trailere de pe site-ul Apple. Sper sa va fie si voua de folos. (copiati script-ul si lipiti-l intr-un fisier KWrite cu denumirea - trailerDownloader.py, faceti-l executabil cu comanda chmod a+x si executati-l cu comanda ./trailerDownloader.py)

#!/usr/bin/python

import urllib
import re
import sys
import os
import string

from urllib import FancyURLopener

class myOpenUrl(FancyURLopener):
version = 'Mozilla/5.0 (Windows; U; Windows NT 5.1; it; rv:1.8.1.11) Gecko/20071127 Firefox/2.0.0.11'

#strap movie url from html
def getMovieUrl(movieName, resolution):

moviePageUrl = getMoviePage(movieName,resolution)

f = urllib.urlopen(moviePageUrl)
s = f.read()

s = re.findall(r'http.+apple.+'+resolution+'.+mov', s)

if s:
return s[0]
else:
print "Trailer not found"

#strap movie page from google search
def getMoviePage(movieName, resolution):
try:

myopener = myOpenUrl()
page = myopener.open('http://www.google.com/search?q='+ string.join(movieName.split(), "+") + "+site:http://www.hd-trailers.net/")
html = page.read()

s = re.findall(r'href=[\'"]/url.q=([^\'"& >]+)',html)
return s[0]

except e:
print "Search failed: %s" % e

def main():

#if you want you can change to 720 or 1080, but is not garantee that it will find it
resolution = "480"

movieNameList = []
if len(sys.argv) > 1:
if (sys.argv[1] == "-h"):
print "usages: ./trailerDownloader.py"
print "OR"
print "usage: ./trailerDownloader.py listOfMovie.txt"
sys.exit(0)
source = open(sys.argv[1], 'r')
movieNameList = source.readlines()
source.close()
else:
movieName = raw_input("Name of the movie : ")
movieNameList.append(movieName)

for movieName in movieNameList:

print "Searching for '"+movieName+"'..."
movieUrl = getMovieUrl(movieName,resolution)

if movieUrl:
try:
print "starting to download : "+ movieUrl
cmd = 'wget -U QuickTime/7.6.2 ' + movieUrl
os.system(cmd)
except e:
print "Error when trying to download : " + movieName
else:
print "movie not found"

if __name__ == '__main__':
main()

As aprecia daca cineva il poate imbunatati!...da rezultate neasteptate, din pacate!

symbianflo
symbianflo's picture
hmmm interesant , putem sa-l

hmmm interesant , putem sa-l mai imbunatatim pe ici pe colo ? =))
Ms fain


http://www.mandrivausers.ro/ MRB aint no shit , :p Linux user number 507107 Nu dați banii pe prostii, puneți Linux pe PISI ![ARLUG]

Unix is user-friendly. It’s just very selective about who its friends are

V3n3RiX
Interesant User-Agent ... :))

Interesant User-Agent ... :)) Ma mir cum de nu se prind idiotii aia de la Apple ca e ceva putred la mijloc.

symbianflo
symbianflo's picture
:)) ai zis tu tot ... cum sa

:)) ai zis tu tot ... cum sa se prinda daca sint idioti ? :D


http://www.mandrivausers.ro/ MRB aint no shit , :p Linux user number 507107 Nu dați banii pe prostii, puneți Linux pe PISI ![ARLUG]

Unix is user-friendly. It’s just very selective about who its friends are

MCM1
Descarcare old fashion

O sa-l cam las balta de script pt ca nu functioneaza asa cum trebuie, asa ca recomand celor care doresc sa descarce trailere apple sa o faca in old fashion, adica:
1. cu un browser de web sa mearga la trailer-ul dorit si sa urmareasca adresa/calea unde este trailer-ul;
2. sa deschida o konsola si sa dea comanda
wget -U QuickTime http://trailers.apple.com/movies/...

Exemplu: dorim sa descarcam trailer-ul battleship
wget -U QuickTime http://trailers.apple.com/movies/universal/battleship/battleship-tlr1_h4...
Explicatie: deschidem cu browser-ul de web locatia trailer-ului, in cazul de fata este ¨universal/battleship¨ si salvam trailer-ul sub forma: ¨battleship-tlr1_h480p.mov¨, daca dorim o alta rezolutie il salvam asa: ¨battleship-tlr1_h720p.mov¨, respectiv 1080p.

Succes!