Eski konuyu duzenleyemedigim icin yenisini actim. Ozellikle httpsciler icin iyi oldugunu dusunuyorum anladiniz siz onu. Her zamanki gibi scripts klasorune atiliyor, eger simple ile calismazsa soyleyin bi satir ekliyim. Bunun haricinde chrome kullanicilari koda kisayoldan ulasmak icin Chrome-Menu-Paylas Ozelligini kullanabilir
Bu ozellik kullanikdiginda konsol acilmiycagi icin yukleme bittiginde titresimle haber vermesini sagladim.(paylas ozelligi qpython son surum icin gecerlidir)
Bu ozellik kullanikdiginda konsol acilmiycagi icin yukleme bittiginde titresimle haber vermesini sagladim.(paylas ozelligi qpython son surum icin gecerlidir)
PHP Kod:
#qpy:console
import urllib
import urllib2
import mimetools, mimetypes
import os, stat, cookielib,re,time,sys,json
from androidhelper import Android
d=Android()
class Callable:
def __init__(self, anycallable):
self.__call__ = anycallable
# Controls how sequences are uncoded. If true, elements may be given multiple values by
# assigning a sequence.
doseq = 1
class MultipartPostHandler(urllib2.BaseHandler):
handler_order = urllib2.HTTPHandler.handler_order - 10 # needs to run first
def http_request(self, request):
data = request.get_data()
if data is not None and type(data) != str:
v_files = []
v_vars = []
try:
for(key, value) in data.items():
if type(value) == file:
v_files.append((key, value))
else:
v_vars.append((key, value))
except TypeError:
systype, value, traceback = sys.exc_info()
raise TypeError, "not a valid non-string sequence or mapping object", traceback
if len(v_files) == 0:
data = urllib.urlencode(v_vars, doseq)
else:
boundary, data = self.multipart_encode(v_vars, v_files)
contenttype = 'multipart/form-data; boundary=%s' % boundary
if(request.has_header('Content-Type')
and request.get_header('Content-Type').find('multipart/form-data') != 0):
print "Replacing %s with %s" % (request.get_header('content-type'), 'multipart/form-data')
request.add_unredirected_header('Content-Type', contenttype)
request.add_data(data)
return request
def multipart_encode(vars, files, boundary = None, buffer = None):
if boundary is None:
boundary = mimetools.choose_boundary()
if buffer is None:
buffer = ''
for(key, value) in vars:
buffer += '--%s\r\n' % boundary
buffer += 'Content-Disposition: form-data; name="%s"' % key
buffer += '\r\n\r\n' + value + '\r\n'
for(key, fd) in files:
file_size = os.fstat(fd.fileno())[stat.ST_SIZE]
filename = fd.name.split('/')[-1]
contenttype = mimetypes.guess_type(filename)[0] or 'application/octet-stream'
buffer += '--%s\r\n' % boundary
buffer += 'Content-Disposition: form-data; name="%s"; filename="%s"\r\n' % (key, filename)
buffer += 'Content-Type: %s\r\n' % contenttype
# buffer += 'Content-Length: %s\r\n' % file_size
fd.seek(0)
buffer += '\r\n' + fd.read() + '\r\n'
buffer += '--%s--\r\n\r\n' % boundary
return boundary, buffer
multipart_encode = Callable(multipart_encode)
https_request = http_request
def secenek(x):
d.dialogCreateAlert("Yuklemek istediginiz resimler?")
d.dialogSetMultiChoiceItems(x)
d.dialogSetPositiveButtonText('Sec')
d.dialogSetNegativeButtonText('Iptal')
d.dialogShow()
r=d.dialogGetResponse().result
if(r["which"]=='negative'):
sys.exit()
result = d.dialogGetSelectedItems().result
print result
return result
sayi2=0
token=""
def oku(dosya,sayi):
global sayi2
global token
try:
if token=="":
print "Token aliniyor.."
desen="\_token\"\svalue=\"(.*?)\""
token=re.findall(desen,opener.open("https://hizliresim.com").read())
token=token[0]
print token
params = {"_token":token,"local_files[]":open(dosya, "rb")}
print sayi+1,".nci resim yukleniyor,bekleyin.."
a=opener.open("https://hizliresim.com/p/yukle",params)
a=a.read()
desen="\[img\](.*?)\[\/img\]"
resim=re.findall(desen,a)
return resim[0]
except:
if(sayi2<3):
sayi2+=1
time.sleep(2)
print "tekrar deneniyor"
oku(dosya,sayi)
return "hata.."
if __name__=="__main__":
cookies = cookielib.CookieJar()
opener=urllib2.build_opener(urllib2.HTTPCookieProcessor(cookies),
MultipartPostHandler,urllib2.ProxyHandler({}))
yol="/sdcard/Pictures/Screenshots/"
x=os.listdir(yol)
dosya=secenek(x)
d.setClipboard("")
for i in dosya:
sonuc=oku(yol+x[i],i)
print sonuc
time.sleep(1)
d.setClipboard(d.getClipboard().result+"[img]"+sonuc+"[/img]")
print "\n"+d.getClipboard().result+"\n"
print "bb kodu seklinde panoya kopyalandi,foruma yapistirabilirsiniz"
d.vibrate()