Konuyu Oyla:
  • Toplam: 1 Oy - Ortalama: 5
  • 1
  • 2
  • 3
  • 4
  • 5
[YENİ] [Python] Face uzerinden Youtube video arama ve indirme
#11
hocam tam isabet olmuş elinize sağlık.
pc ile kullanmak mümkün mü? pc de denedim ancak çalıstıramadım.
Ara
Cevapla
#12
pc'de deneme firsatim olmadı ancak kodu yazarken pc de calışacak şekilde ayarlamaya çalıştım. nerde hata aldığını yani hata mesajını atarsan çözebiliriz..
Ara
Cevapla
#13
hocam hata mesajını atacam da bendeki hata biraz farklı yani py dosyasına giremiyorum 1 sn geçmeden atıyor..
Ara
Cevapla
#14
hocam kodu editöre yapıstırıp çalıştırın
Ara
Cevapla
#15
malesef olmuyor
Ara
Cevapla
#16
@Ethnic termcolor kullanımı ile ilgili bir problem var. Modüllü import etmeden önce "colored" kullanmışsın. Yani modüller yükleniyor yazısını colored ile yaptırmaya çalışmısın bu da hata veriyor doğal olarak Smile ayrıca modüşü pip il yükledikten sonra except bloğunda şu kısmı yazmayı unutmuşsun

from termcolor import colored, cprint
Turbobit Premium Link Çeviri | Turbobit Link Generator | http://turbobit.qpython.club
Cevapla
#17
Hatta platform else bloğunda, yani pc için yüklenecek modüller kısmında diğer modüllerde de aynısını yapmışsın. Yüklettikten sonra tekrar import etmen gerekiyor. Linux kısmında yani android için olan kısımda kodu modül yüklendikten sonra baştan başlattırıyoruz o yüzden sıkıntı olmuyo ama pc için tekrardan başlatma komutu yok, zaten baştan başlatmaya da gerek yok, tekrar import satırı eklemek yetiyo pc'de. Ama androidde bu sıkıntıydı ben de zamanında o yüzden tekrar başlattırarak halletmiştim.
Turbobit Premium Link Çeviri | Turbobit Link Generator | http://turbobit.qpython.club
Cevapla
#18
bazı kısımlarda hatalar olmuş tabi pcde test etmeyince farkına varmamış olabilirsin. Be o kısımları düzenledim, başka sorun var mı bilmiyorum, giriş yapıp detaylı kullanmadım.

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


def yaz
(parametretime_sleep 0.009):
    for 
i in parametre:
        
time.sleep(time_sleep)
        
sys.stdout.write(i)
        
sys.stdout.flush()

if 
platform.platform().startswith("Linux"):
    try:
        
os.makedirs('/sdcard/FaceVideo/')
    
except:
        
pass     
    
try:
        
from termcolor import coloredcprint
    except
:
        
yaz('- 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)
        
    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)
        
    try:
        
import mechanize
    except
:
        
arg="pip install mechanize"
        
os.system(sys.executable+" "+sys.prefix+"/bin/"+arg)
        
os.execv(sys.executable, ['python'] + sys.argv)
       
    try:
        
import requests
    except
:
        
arg="pip install requests"
        
os.system(sys.executable+" "+sys.prefix+"/bin/"+arg)
        
os.execv(sys.executable, ['python'] + sys.argv)
    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)        
else:
    try:
        
from termcolor import coloredcprint
    except
:
        
yaz("- Gerekli modüller yükleniyor...\n")
        
subprocess.call(["python","-m","pip","install","termcolor"])
        
from termcolor import coloredcprint
    
try:
        
from bs4 import BeautifulSoup
    except
:
        
subprocess.call(["python","-m","pip","install","bs4"])
        
from bs4 import BeautifulSoup
    
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 MultipartEncode
    except
:
        
subprocess.call(["python","-m","pip","install","requests_toolbelt"])
        
from requests_toolbelt import MultipartEncoder
        
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()
try:    
    
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()
except:
    
yaz(colored('\n- Bir hata oluştu! Tekrar deneyin.\n','red',attrs=['bold']))
    
quit()

    
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- Giriş Yapılamadı! Lütfen Giriş bilgilerinizi kontrol ediniz\n','red',attrs=['bold']))
    try:
        try:
            
os.remove("/sdcard/mail.txt")
            
os.remove("/sdcard/pasw.txt")
            
quit()
        
except:
            
os.remove("mail.txt")
            
os.remove("pasw.txt")
            
quit()
    
except:
        
pass
        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
    
try:
        
save=open("/sdcard/FaceVideo/"+isim+'.'+uzanti,"ab")
    
except:
        
save=open("/sdcard/"+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']))
    
hedef=h.unescape(br.open("https://facebook.com").read().decode('utf-8'))
    
soup BeautifulSoup(hedef'html.parser')
    for 
mid in soup.findAll(attrs={'class':'_2s25'}):
         
vlin=mid['href']+'/videos_by'
         
break
    
aut=0
    
while True:
        
vlink=h.unescape(br.open(vlin).read().decode('utf-8'))
        
vurl='https://www.facebook.com'+re.findall('<a class="\_\_\-\q" href="(.*?)\"',vlink)[0]
        
vtitle=re.findall('video_tab" aria-label="(.*?)" ajaxify="/',vlink)[0]
#        print title
#        print vtitle
        
if vtitle == title:
            
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(5)
            
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\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')
        
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'] + '\n'+colored('-','red',attrs=['bold'])*60+'\n'
            
link.append(adres)
            
title1.append(vid['title'])
            
yaz(liste,0.0001)
        print 
des+'\n'
    
except:
        
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() 
Turbobit Premium Link Çeviri | Turbobit Link Generator | http://turbobit.qpython.club
Cevapla
#19
gecemor ustam sizin verdiğiniz çalıstı eyvAllah fakat facebook a girerken hata alıyorum
Ara
Cevapla
#20
yoldayim suan eve varir varmaz bakacam
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 614 27-11-2022, Saat: 17:59
Son Yorum: perry
Question Python Dili Soru & Cevap gecemor 1,493 1,018,695 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,181 28-09-2022, Saat: 20:27
Son Yorum: krast
  YENİ Python Pyqt5 memory leak sorunu perry 3 774 28-09-2022, Saat: 11:33
Son Yorum: gecemor
  YENİ PYTHON ads approval CaglarDevv 2 1,024 04-07-2022, Saat: 01:23
Son Yorum: CaglarDevv

Hızlı Menü:


Konuyu Okuyanlar: 1 Ziyaretçi
Change Theme