Konuyu Oyla:
  • Toplam: 1 Oy - Ortalama: 5
  • 1
  • 2
  • 3
  • 4
  • 5
[YENİ] [Python] Face uzerinden Youtube video arama ve indirme
#1
Bu defa sadece facebook erisiminiz olsa bile youtubedan video arayabilir, sectiginiz videoyu facebook uzerinden dolayli olarak indirebilirsiniz.

Aradığınız videoyu sectikten sonra kod videoyu önce facebook hesabınıza yükleyecek ardından video hesabınıza görünmesini bekleyecek, video hesabınıza yansır yansımaz en yüksek kalitede indirmeye başlayacak..

Kodu kullanmak için acceess token almanız gereklidir, uzun vadeli access token almanız önerilir..

facebook giris bilgilerinizi ve access tokeni bir defa girmeniz yeterlidir, devamında scripti her actığinızda kod giris bigilerinizi ve tokeni ilk girisinizde kaydettiği FaceVideo klsöründen okuyacak. farklı bir hesap yada token kullanacaksanız FaceVideo klasorundeki mail.txt ve passw.txt yada token icin token.txt dosyalarını silin.

ilk kurulumda bazi modüllerin yüklenmesi için bir defaya mahsus normal internet gereklidir.

Önemli Not: Scripti Forumda konusu bulunan Pydroid uyguaması ile çalıştırın..

İPUCU: Koda kolay erişmek için altdaki pytube.py dosyasını sdcard anadizine atın. Pydroidi her açtığınızda import facetube yazıp play düğmesine basarak kodu çalıştırabilirsiniz.. eğer android 6 ve üzeri telefon kullaniyorsaniz bir defaya mahsus Pydroid uygulamasının üst barında bulunan dosya simgesine dokunup 'open' diyerek dosya okuma izni verin aksi halde 'import facetube' diyerek kodu çalıştıramazsınız..

kodla ilgili bir sorun yaşarsanız çekinmeden söyleyin..
'nasıl access token alırım' gibisinden sorulara cevap vermiyorum, forumda facebooka video yukleme konusuna bakın...


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 coloredcprint
    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 coloredcprint
    
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 coloredcprint
    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 coloredcprint
    
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(parametretime_sleep 0.009):
        
sys.stdout.write(parametre)
        
sys.stdout.flush()
else:
    
def yaz(parametretime_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')
descolored('_'*60,'blue',attrs=['bold'])
yaz(des+'\n\n'+y+'\n'+a+'\n'+c+'\n'+des+'\n',0.002)


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 :
        
mbstr(toplam/1025) + ' kb'
    
else:
        
mbstr(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:
        
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_urlpage_idaccess_token,descriptiontitle):
    
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(
            
pathaccess_token)
    
MultipartEncoder(
        
fields={'description'description,
                
'title'title,
                
'comment':'postvideo',
                
'file_url'video_url }
    )
    
requests.post(fb_urlheaders={'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:
        
htmlh.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, {'"':'"','&':'&'})
        
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')
    
resh.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_urlpage_idaccess_tokendescriptiontitle)
youtube() 


Ek Dosyalar Ekran Görüntüleri
   

.py   facetube.py (Dosya Boyutu: 12.09 KB / İndirme Sayısı: 118)
Ara
Cevapla
#2
Eline sağlık, sadece facebook paketi olanlar için güzel bir alternatif. Kodu denemedim ama ekran görüntüsüne bakarak şunu diyebilirim, video isimlerinin yanına süresini de yazdırabilirsen daha bilgilendirici olur diye düşünüyorum Smile
Turbobit Premium Link Çeviri | Turbobit Link Generator | http://turbobit.qpython.club
Cevapla
#3
(10-10-2017, Saat: 15:17)gecemor Nickli Kullanıcıdan Alıntı:  Eline sağlık, sadece facebook paketi olanlar için güzel bir alternatif. Kodu denemedim ama ekran görüntüsüne bakarak şunu diyebilirim, video isimlerinin yanına süresini de yazdırabilirsen daha bilgilendirici olur diye düşünüyorum Smile

Bencede mantıklı.. Smile bakıyorum hemen.. Smile
Ara
Cevapla
#4
arama sonuclarına video sureleri eklendi..
Ara
Cevapla
#5
like
Turbobit Premium Link Çeviri | Turbobit Link Generator | http://turbobit.qpython.club
Cevapla
#6
Teşekkürler
Ara
Cevapla
#7
rica ederim kaptan Smile
Ara
Cevapla
#8
Çarkçıydı bir zamanlarSmile
Ara
Cevapla
#9
Ooo alırım bir dal Smile
Ara
Cevapla
#10
ayıpsın paket senin olsun Smile
Turbobit Premium Link Çeviri | Turbobit Link Generator | http://turbobit.qpython.club
Cevapla

{lang: 'en'}


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

Hızlı Menü:


Konuyu Okuyanlar: 1 Ziyaretçi
Change Theme