Konuyu Oyla:
  • Toplam: 1 Oy - Ortalama: 5
  • 1
  • 2
  • 3
  • 4
  • 5
[YENİ] [Python] Face uzerinden Youtube video arama ve indirme
#61
Peki diyelim bi tane indirdik face üzerinde sonra tekrar çalıştırınca aynı tag isminde 2gönderi olacak facede hangisini indireceğini nasıl belirliyor, gönderi zamanına göre mi yoksa indirdikten sonra gönderiyi siliyor mu?

Bendeki sorun nedir hala anlamış değilim, token çalışıyor link ile video yükleyebiliyorum ama youtube videosu indirme scripti çalışmıyor Sad
Ara
Cevapla
#62
(24-12-2017, Saat: 10:32)oktay811 Nickli Kullanıcıdan Alıntı:  Peki diyelim bi tane indirdik face üzerinde sonra tekrar çalıştırınca aynı tag isminde 2gönderi olacak facede hangisini indireceğini nasıl belirliyor, gönderi zamanına göre mi yoksa indirdikten sonra gönderiyi siliyor mu?

Bendeki sorun nedir hala anlamış değilim, token çalışıyor link ile video yükleyebiliyorum ama youtube videosu indirme scripti çalışmıyor Sad

Oktay sorun sadece sende değil zaten dediğim gibi tag ve class isimlerinden kaynaklanıyor, aynı tag ve classdaki en son videoyu bulmak o kadar zor bir şey değil.. regex[0] yada split[0] yaparsın..
Ara
Cevapla
#63
@oktay811 burdaki kodu düzenledim. Hala lazımsa kullanabilirsin..

PHP Kod:
#-*-coding:utf8;-*-

import HTMLParser
import urllib2
import re
,sys,urllib,time,os
from xml
.sax import saxutils as su
from urllib import quote
, unquote
import platform
import subprocess

windows 
= False

if platform.platform().startswith("Linux"):
    try:
        
os.makedirs('/sdcard/FaceVideo/')
    
except:
        
pass     
    
try:
        
from termcolor import colored, cprint
    except
:
        print 
"Gerekli modüller yükleniyor...\n"
        
arg="pip install termcolor"
        
os.system(sys.executable+" "+sys.prefix+"/bin/"+arg)
        
os.execv(sys.executable, ['python'] + sys.argv)
        
from termcolor import colored, cprint
    
try:
        
from bs4 import BeautifulSoup
    except
:
        
arg="pip install bs4"
        
os.system(sys.executable+" "+sys.prefix+"/bin/"+arg)
        
os.execv(sys.executable, ['python'] + sys.argv)
        
from bs4 import BeautifulSoup
    
try:
        
import mechanize
    except
:
        
arg="pip install mechanize"
        
os.system(sys.executable+" "+sys.prefix+"/bin/"+arg)
        
os.execv(sys.executable, ['python'] + sys.argv)
        
import mechanize
    
try:
        
import requests
    except
:
        
arg="pip install requests"
        
os.system(sys.executable+" "+sys.prefix+"/bin/"+arg)
        
os.execv(sys.executable, ['python'] + sys.argv)
        
import requests
    
try:
        
from requests_toolbelt import MultipartEncoder
    except
:
        
arg="pip install requests_toolbelt"
        
os.system(sys.executable+" "+sys.prefix+"/bin/"+arg)
        
os.execv(sys.executable, ['python'] + sys.argv)   
        
from requests_toolbelt import MultipartEncoder     
else:
    try:
        
from termcolor import colored, cprint
    except
:
        print 
"Gerekli modüller yükleniyor...\n"
        
subprocess.call(["python","-m","pip","install","termcolor"])
    try:
        
from bs4 import BeautifulSoup
    except
:
        
subprocess.call(["python","-m","pip","install","bs4"])
        
from termcolor import colored, cprint
    
try:
        
import mechanize
    except
:
        
subprocess.call(["python","-m","pip","install","mechanize"])
        
import mechanize
    
try:
        
import requests
    except
:
        
subprocess.call(["python","-m","pip","install","requests"])
        
import requests
    
try:
        
from requests_toolbelt import MultipartEncoder
    except
:
        
subprocess.call(["python","-m","pip","install","requests_toolbelt"])
        
from requests_toolbelt import MultipartEncoder
    
try:
        
from colorama import init
        init
()
    
except:
        
subprocess.call(["python","-m","pip","install","colorama"])
        
from colorama import init
        init
()
    
windows = True
     
if windows == True:
    
def yaz(parametre, time_sleep = 0.009):
        
sys.stdout.write(parametre)
        
sys.stdout.flush()
else:
    
def yaz(parametre, time_sleep = 0.009):
        for 
i in parametre:
            
time.sleep(time_sleep)
            
sys.stdout.write(i)
            
sys.stdout.flush()    

        
        
y=colored('Proje Adı  : FaceTube Video Downloader \n','white','on_blue')
a=colored('İletişim   : http://www.qpython.club \n','white','on_blue')
c=colored('Geliştirici: Ethnic                  \n','white','on_blue')
des= colored('_'*60,'blue',attrs=['bold'])
yaz(des+'\n\n'+y+'\n'+a+'\n'+c+'\n'+des+'\n',0.002)


h = HTMLParser.HTMLParser()
br = mechanize.Browser()
br.set_handle_robots(False)
br.addheaders = [('User-agent', 'Mozilla/5.0 (compatible; Konqueror/3.5; Linux) KHTML/3.5.5 (like Gecko) (Kubuntu)')]

if 
platform.platform().startswith("Linux"):
    try:
        
token=open("/sdcard/FaceVideo/token.txt")
        
token=token.read()
    
except:
        
token=open("/sdcard/FaceVideo/token.txt","w")
        
token=token.write(raw_input(colored("Access Token   : ",'blue',attrs=['bold'])))
        
token=open("/sdcard/FaceVideo/token.txt")
        
token=token.read()
        
    try:
        
mail=open("/sdcard/FaceVideo/mail.txt")
        
mail=mail.read()    
    
except:    
        
mail=open("/sdcard/FaceVideo/mail.txt","w")
        
mail=mail.write(raw_input(colored("\nFacebook email   : ",'blue',attrs=['bold']))) 
        
mail=open("/sdcard/FaceVideo/mail.txt")
        
mail=mail.read()
        
    try:    
        
pasw=open("/sdcard/FaceVideo/pasw.txt")
        
pasw=pasw.read()    
    
except:
        
pasw=open("/sdcard/FaceVideo/pasw.txt","w")
        
pasw=pasw.write(raw_input(colored("\nFacebook şifre   : ",'blue',attrs=['bold']))) 
        
pasw=open("/sdcard/FaceVideo/pasw.txt")
        
pasw=pasw.read()
else:
    try:
        
token=open("token.txt")
        
token=token.read()
    
except:
        
token=open("token.txt","w")
        
token=token.write(raw_input(colored("Access Token   : ",'blue',attrs=['bold'])))
        
token=open("token.txt")
        
token=token.read()

    try:
        
mail=open("mail.txt")
        
mail=mail.read()    
    
except:    
        
mail=open("mail.txt","w")
        
mail=mail.write(raw_input(colored("\nFacebook email   : ",'blue',attrs=['bold'])))
        
mail=open("mail.txt")
        
mail=mail.read()
        
    try:    
        
pasw=open("pasw.txt")
        
pasw=pasw.read()    
    
except:
        
pasw=open("pasw.txt","w")
        
pasw=pasw.write(raw_input(colored("\nFacebook şifre   : ",'blue',attrs=['bold']))) 
        
pasw=open("pasw.txt")
        
pasw=pasw.read()
    
yaz(colored('\nFacebook Yükleniyor','blue',attrs=['bold']))
op=br.open("https://facebook.com")
username=mail
password
=pasw
yaz
(colored('\n\n- Kullanici verileri isleniyor...','blue',attrs=['bold']))
br.select_form(nr=0)
br.form["email"]=username
br
.form["pass"]=password
br
.method="POST"
br.submit()
yaz(colored("\n\n- Facebook'a giriş yapılıyor...",'blue',attrs=['bold']))
text=br.open("https://facebook.com").read()
    
if(
text.find("home_icon",0,len(text))!=-1):
    
yaz(colored('\n\n- Başarıyla giriş yapıldı.\n\n','green',attrs=['dark'])+des+'\n\n',0.001)
else:
    
yaz(colored('\n\n- Giriş Yapılamadı! Lütfen Giriş bilgilerinizi kontrol ediniz\n','red',attrs=['bold']))
    try:
        
os.remove("/sdcard/FaceVideo/mail.txt")
        
os.remove("/sdcard/FaceVideo/pasw.txt")
        
quit()
    
except:
        try:
            
os.remove("mail.txt")
            
os.remove("pasw.txt")
            
quit()
        
except:
            
quit()
    

face='https://developers.facebook.com/tools/debug/echo/?q='

def indir(son,isim):
    
oku = urllib2.urlopen(son)
    
toplam = int(oku.info().getheaders('Content-Length')[0])
    if 
toplam < 1048576 :
        
mb= str(toplam/1025) + ' kb'
    
else:
        
mb= str(toplam/1048576) + ' mb'
    
print des+'\n\n'
    
print colored('- Video boyutu : %s \n\n' % mb,'yellow',attrs=['bold'])

    
uzanti = oku.info().getheaders('Content-Type')[0].split('/')[1]
    if 
uzanti == '3gpp':
        
uzanti=uzanti.replace('3gpp','3gp')
    else:
        
pass
    
if platform.platform().startswith("Linux"):
        
save=open("/sdcard/FaceVideo/"+isim+'.'+uzanti,"ab")
    else:
        
save=open(isim+'.'+uzanti,"ab")
    
sayi=0
    sayi2
=0
    
    
while True:
        
a = toplam/50
        b 
= oku.read(a)
        
sayi += a
    
        
if not b:
            break
        
save.write(b)
        if(
sayi < toplam):
            
sayi+=0
            sayi2
+=2
            kb
= str(sayi/1048576) + ' mb'
            
sys.stdout.write(colored("- Video idiriliyor : %%%s " % str(sayi2) + "  %s \r" % str(kb),'green',attrs=['bold']))
            
sys.stdout.flush()
    
yaz(colored('\n\n- Video FaceVideo klasörüne indirildi.   \n\n','blue',attrs=['bold']))


def hdlink(title):
    
yaz(colored('- Videonun hesabınıza yansıması bekleniyor.\n\n- Bu işlem bir kaç dk sürebilir...\n\n','blue',attrs=['bold']))
    while 
True:
        try:
            
hedef=h.unescape(br.open("http://facebook.com/profile.php?=73322363").read().decode('utf-8'))
            
soup = BeautifulSoup(hedef, 'html.parser')
            
vlin=re.findall('href="(.*?)videos_by',hedef)[-1]+'videos_by'
            
break
        
except:
            
time.sleep(5)
            
pass
    aut
=0
    
while True:
        try:
            
vlink=h.unescape(br.open(vlin).read().decode('utf-8'))
        
except:
            print 
'Bağlantı Hatası!'
#            print vlink
        
try:
            
vurl='https://www.facebook.com'+re.findall('class="async_saving _400z _2-40 __-q" href="(.*?)\"',vlink)[0]
        
except:
            
pass
        
try:
            
vtitle=re.findall('video_tab" aria-label="(.*?)ajaxify="#" rel="async"',vlink)[0]
        
except:
            
vtitle=''
            
pass
#        print title
#        print vtitle
        
if title in vtitle:
            
durl=h.unescape(br.open(vurl).read().decode('utf-8'))
            try:
                try:
                    
hdurl=re.findall('hd_src:\"(.*?)\"',durl)[0]
                
except:
                    
hdurl=re.findall('sd_src:\"(.*?)\"',durl)[0]
            
except Exception as e:
                print 
e
                pass
            indir
(hdurl,vtitle)
            break
        else:
            
time.sleep(4)
            
aut+=1
            
if aut == 20:
                
yaz(colored('\n- Video bulunamadı!\n','red',attrs=['bold']))
                break
            
pass
    

def put_video
(video_url, page_id, access_token,description, title):
    
yaz(colored('- Video Facebook\'a yükleniyor..\n\n- Bu işlem bir kaç dakika sürebilir \n\n','blue',attrs=['bold']))
    
video_file_name=title
    local_video_file
=video_url
    path 
= "{0}/videos".format(page_id)
    
fb_url = "https://graph-video.facebook.com/{0}?access_token={1}".format(
            
path, access_token)
    
m = MultipartEncoder(
        
fields={'description': description,
                
'title': title,
                
'comment':'postvideo',
                
'file_url': video_url }
    )
    
r = requests.post(fb_url, headers={'Content-Type': m.content_type}, data=m) 
    if 
r.status_code == 200:
        
j_res = r.json()
        
facebook_video_id = j_res.get('id')
#        print ("facebook_video_id = {0}".format(facebook_video_id))
        
yaz(colored("- Video hesabınıza yüklendi. \n\n",'green'))
        
hdlink(title)
    else:
        
yaz(colored("\n\n- Facebook upload error: {0}".format(r.text),'red',attrs=['bold']))
        
quit()

    
def youtube():
    
    
google = raw_input(colored('Youtube\'da Ara : ','red',attrs=['bold']))
    print 
'\n'
    
google=google.replace(' ','+')
    
query = urllib.quote(google)
    
url = "https://www.youtube.com/results?search_query="+query
    
try:
        
html= h.unescape(br.open(face+url).read().decode('utf-8'))
    
except:
        
yaz(colored('\n-Bağlantı hatası! Veri bağlantısını kontrol edin.\n\n','red',attrs=['bold']))
        
quit()
    if 
str(c[29]) != 'c':
        
quit()
    else:
        
pass
    
try:
        
data=su.unescape(html, {'&quot;':'"','&amp;':'&'})
        
soup = BeautifulSoup(html, 'html.parser')
        
sure=[]
        for 
sur in soup.findAll('span', class_="video-time"):
            
sure.append(sur.getText())
        
say = 0
        link
= []
        
title1=[]
        for 
vid in soup.findAll(attrs={'class':'yt-uix-tile-link'}):
            
adres= 'https://www.youtube.com' + vid['href']
            
say+=1
            liste 
= str(say) + " - " + vid['title'] +'  '+colored(sure[say-1],'green',attrs=['dark'])+'\n'+colored('-','red',attrs=['bold'])*60+'\n'
            
link.append(adres)
            
title1.append(vid['title'])
            
yaz(liste,0.0001)
        print 
des+'\n'
    
except Exception as e:
        print 
des+'\n'
        
pass
    
if not link:
        
yaz(colored('\n- Sonuç bulunamadı! Yeniden deneyin.\n\n','red',attrs=['bold']))
        
youtube()
    else:
        
pass
    yanlis 
= False
    
while not yanlis:
        try:
            
al=raw_input(colored('Video Seç : ','blue',attrs=['bold']))
            
cevap='http://video.genyoutube.net/'+link[int(al)-1].split('?v=')[1]
            
isim=title1[int(al)-1]
            break
        
except:
            
yaz(colored('\n- Lütfen video numarasını doğru giriniz.\n\n','red',attrs=['bold']))
            
pass
    yaz
(colored('\nSecilen ','blue',attrs=['bold'])+ colored(isim.encode('utf-8'),'cyan',attrs=['dark']) + '\n\n')
    
res= h.unescape(br.open(face+cevap).read().decode('utf-8'))
    
soup1 = BeautifulSoup(res, 'html.parser')
    
sad=[]
    for 
vid in soup1.findAll('div',class_="col-md-3 col-sm-4 col-xs-6 text-center downbuttonbox"):
        
sad.append(vid.find('a').get("href"))    
    
video_url=sad[0]
    
page_id = "me"
    
access_token=token
    description 
= "qpython.club"
    
title = isim
    put_video
(video_url, page_id, access_token, description, title)
youtube() 
Ara
Cevapla
#64
@Ethniz çok teşekkür ederim hocam Smile
Ara
Cevapla
#65
Rica ederim.. Smile
Ara
Cevapla
#66
teşekkürler
Ara
Cevapla
#67
Rica ederim..
Ara
Cevapla
#68
Yunus Abi test yaptım. Çok faydalı bir script olmuş. Eline sağlık
Ara
Cevapla
#69
Eyvallah Smile güle güle kullan Smile
Ara
Cevapla
#70
herşey tamam ama video seç diyor şeçiyorum indirmiyo neden acaba access token olmadan film aratınmı geliyormu
Ara
Cevapla

{lang: 'en'}


Konu ile Alakalı Benzer Konular
Konular Yazar Yorumlar Okunma Son Yorum
  15gb .myd uzantılı dosya python ile okutma perry 1 2,016 27-11-2022, Saat: 17:59
Son Yorum: perry
Question Python Dili Soru & Cevap gecemor 1,493 1,184,386 08-11-2022, Saat: 11:18
Son Yorum: Antonyobanderas
  GÜNCEL Python request , c# request e göre çok yavaş ne yapabilirim perry 12 5,204 28-09-2022, Saat: 20:27
Son Yorum: krast
  YENİ Python Pyqt5 memory leak sorunu perry 3 2,439 28-09-2022, Saat: 11:33
Son Yorum: gecemor
  YENİ PYTHON ads approval CaglarDevv 2 2,255 04-07-2022, Saat: 01:23
Son Yorum: CaglarDevv

Hızlı Menü:


Konuyu Okuyanlar: 1 Ziyaretçi
Change Theme