def main(): nombre = argv[1] api_key = environ['TMDBAPI'] payload = { 'api_key' : api_key, 'query' : nombre, 'language' : 'es' } r = loads(requests.get('http://api.themoviedb.org/3/search/movie', params=payload ).text) titulo = r['results'][0]['title'] poster_path = r['results'][0]['poster_path'] download("https://image.tmdb.org/t/p/original/%s" % poster_path, "%s.jpg" %titulo)
def btnDownload_clkd(self): index = self.titleList.currentIndex() filmid = self.reqtext['results'][index]['id'] poster_path = self.reqtext['results'][index]['poster_path'] download( 'https://image.tmdb.org/t/p/%s/%s' % (self.poster_download_size, poster_path), '%s/%s.jpg' % (self.poster_download_path, filmid))
def PosterPreview(self, index): title = self.reqtext['results'][index]['title'] poster_path = self.reqtext['results'][index]['poster_path'] download('https://image.tmdb.org/t/p/%s/%s' % (self.poster_preview_size,poster_path), '%s/%s.jpg' %(self.poster_preview_path, title)) scene = QtGui.QGraphicsScene() scene.addPixmap(QtGui.QPixmap('%s/%s.jpg' % (self.poster_preview_path,title))) self.posterView.setScene(scene) w, h = imagesize.get('%s/%s.jpg' % (self.poster_preview_path,title)) self.posterView.fitInView(QtCore.QRectF(0, 0, w, h), QtCore.Qt.KeepAspectRatio)
def downloadDir(url, dir): if not os.path.exists(dir): os.makedirs(dir) files = getFiles(url) for file in files: if file.endswith('/'): downloadDir('%s/%s' % (url, file), '%s/%s' % (dir, file)) else: path = ('locales/%s' % file if (file.endswith('.help') or file.endswith('.comms')) else dir + '/%s' % file) if os.path.exists(path): os.remove(path) download(url + '/%s' % file, path)
def PosterPreview(self, index): title = self.reqtext['results'][index]['title'] poster_path = self.reqtext['results'][index]['poster_path'] download( 'https://image.tmdb.org/t/p/%s/%s' % (self.poster_preview_size, poster_path), '%s/%s.jpg' % (self.poster_preview_path, title)) scene = QtGui.QGraphicsScene() scene.addPixmap( QtGui.QPixmap('%s/%s.jpg' % (self.poster_preview_path, title))) self.posterView.setScene(scene) w, h = imagesize.get('%s/%s.jpg' % (self.poster_preview_path, title)) self.posterView.fitInView(QtCore.QRectF(0, 0, w, h), QtCore.Qt.KeepAspectRatio)
def lives(self): try: open('raw/tools/lives/lives.txt') except: printf('salah/* downloading resources ...') try: b = base64.b16decode(self.tete) download(b, 'raw/tools/lives/lives.txt') printf('notice/* downloading ok!') raw_input("\033[1;32m*\033[0mpress enter to menu ...") perintah('clear') self.menu() except Exception as f: printf('\nsalah/* connection rijected.') keluar()
def downloadImage(self,url,pic_no,path): # this function download the image. Before dowloading # it checks whether or not it is already present. #download(url,filepath) name = '%d'%pic_no+'.' extension = url.split('.')[-1] if '?' in extension: extension=extension.split('?')[-2] name=name+'%s'%extension #D:\Photos\Reddit-users\user\user(1)\name.jpg filepath = path+r'\%s'%name if not os.path.exists(filepath): download(url,filepath) print 'done.....' else: print 'photo already exists'
def download_PDB_and_FASTA(modelname,targetdir='.'): plist = PDB.PDBList() try: modelfile = plist.retrieve_pdb_file(modelname,pdir=targetdir)#this handles directory creation except: raise Exception("Failed to Retrieve PDB file") targetdir = os.path.dirname(modelfile) url = __seqres_url % modelname.upper() fastafile = os.path.join(targetdir,modelname+".faa") # this makes the assumption that modelfile is in fact the filename of the model. download(url,fastafile) #download the DSSP output dsspUrl = __dssp_url % modelname.lower() dsspSaveFile = os.path.join(targetdir,modelname+".dssp") download(dsspUrl,dsspSaveFile) return modelfile, fastafile
def install_addon(repo_url, addons, addon, user, home, release, enabled): # Avoid installing already existing addons if exists("%s/addons/%s" % (home, addon)) and enabled: update_db(addon, home, True) return # Check the xml definition for package dependencies and install them first dependencies = addons.findall('addon[@id="%s"]/requires/import' % (addon)) for dep in dependencies: dep_name = dep.get('addon') # 'xbmc.*' are not really addons if dep_name.split('.')[0] != 'xbmc': install_addon(repo_url, addons, dep_name, user, home, release, enabled) # Find the location for the .zip file in the xml definition addon_path = addons.find('addon[@id="%s"]/extension/path' % (addon)).text # Compute full url for the zip file zip_url = '%s/%s' % (repo_url, addon_path) # We save the zip file in packages/ as kodi does zip_base = basename(addon_path) zip_local = '%s/addons/packages/%s' % (home, zip_base) download(zip_url, zip_local) # Extract the zip in the addon directory zip(zip_local, 'r').extractall("%s/addons/" % (home)) # chown -R to the user pwdata = getpwnam(user) for root, dirs, files in walk("%s/addons/%s" % (home, addon), topdown=False): for name in files: chown(path_join(root, name), pwdata.pw_uid, pwdata.pw_gid) for name in dirs: chown(path_join(root, name), pwdata.pw_uid, pwdata.pw_gid) chown("%s/addons/%s" % (home, addon), pwdata.pw_uid, pwdata.pw_gid) update_db(addon, home, enabled)
def write_package(self): key = pj('secret', 'key.pem') certs = pj('secret', 'certs') tmp_dir = pj(os.path.dirname(self.build_dir), '.tmp') package = self.package_name + '.' + self.ext if not os.path.isfile(key): sys.stderr.write(key + ' is missing\n') return if not os.path.isfile(pj(certs, 'safari_extension.cer')): sys.stderr.write( pj(certs, 'safari_extension.cer') + ' is missing\n' ) return try: os.remove(package) except: pass try: rmtree(tmp_dir) except: pass try: os.makedirs(tmp_dir) except: pass try: os.makedirs(certs) except: pass if not os.path.isfile(pj(certs, 'AppleWWDRCA.cer')): print('Downloading AppleWWDRCA.cer...') download( 'https://developer.apple.com/certificationauthority/AppleWWDRCA.cer', pj(certs, 'AppleWWDRCA.cer') ) if not os.path.isfile(pj(certs, 'AppleIncRootCertificate.cer')): print('Downloading AppleIncRootCertificate.cer...') download( 'https://www.apple.com/appleca/AppleIncRootCertificate.cer', pj(certs, 'AppleIncRootCertificate.cer') ) if which('xar') is None: try: rmtree(tmp_dir) except: pass return False subprocess.call([ 'xar', '-czf', package, '--compression-args=9', '--distribution', '--directory', os.path.dirname(self.build_dir), os.path.basename(self.build_dir) ]) sig_len = len(subprocess.Popen( ['openssl', 'dgst', '-binary', '-sign', key, key], stdout=subprocess.PIPE ).stdout.read()) digest_dat = pj(tmp_dir, self.ext + '_digest.dat') sig_dat = pj(tmp_dir, self.ext + '_sig.dat') subprocess.call([ 'xar', '--sign', '-f', package, '--digestinfo-to-sign', digest_dat, '--sig-size', str(sig_len), '--cert-loc', pj(certs, 'safari_extension.cer'), '--cert-loc', pj(certs, 'AppleWWDRCA.cer'), '--cert-loc', pj(certs, 'AppleIncRootCertificate.cer') ]) subprocess.call([ 'openssl', 'rsautl', '-sign', '-inkey', key, '-in', digest_dat, '-out', sig_dat ]) subprocess.call(['xar', '--inject-sig', sig_dat, '-f', package]) try: rmtree(tmp_dir) except: pass
def run_module(): # seed the result dict in the object result = dict( changed=True, ) # define available arguments/parameters a user can pass to the module module = AnsibleModule( argument_spec=dict( state=dict( type='str', default='enabled', required=False, choices=[ 'present', 'absent', 'enabled', 'disabled' ] ), name=dict( type='str', required=True ), kodi_user=dict( type='str', required=False, default='kodi' ), kodi_home=dict( type='str', required=False, default='' ), kodi_release=dict( type='str', required=True ), ), supports_check_mode=True ) # We only work with releases that have the database version 27 # See: https://kodi.wiki/view/Databases#Database_Versions if not SUPPORTED_RELEASES.__contains__(module.params['kodi_release']): module.fail_json( msg='Unsupported kodi release. Supported: %s' % (SUPPORTED_RELEASES), **result ) # Seed the default kodi home if not supplied if module.params['kodi_home']: kodi_home = module.params['kodi_home'] else: kodi_home = "%s/.kodi" % (getpwnam(module.params['kodi_user']).pw_dir) # Seed the default kodi repository kodi_repo = 'http://mirrors.kodi.tv/addons/%s/addons.xml.gz' % (module.params['kodi_release']) # Shortcut for the actual repository, computed removing 'addons.xml(.gz)' repo_base = '/'.join(kodi_repo.split('/')[0:-1]) if module.params['state'] == 'absent': if module.check_mode: # We would only remove the addon if it's in the directory, # or if it has traces in the db result['changed'] = ( exists("%s/addons/%s" % (kodi_home, module.params['name'])) or is_in_db(module.params['name'], kodi_home) ) module.exit_json(**result) result['changed'] = remove_addon(kodi_home, module.params['name']) module.exit_json(**result) elif module.params['state'] == 'disabled': enabled = False elif module.params['state'] in ['present', 'enabled']: enabled = True # If the directory already exists and the enabled status is as desired, then we have nothing to do if exists("%s/addons/%s" % (kodi_home, module.params['name'])): if is_enabled(module.params['name'], kodi_home) == enabled: result['changed'] = False module.exit_json(**result) addons_xml = mktemp() # Download the repository definition, uncompressing it if necessary # This check is left from an attempt to support multiple repositories which might be retried, no need to delete it. if kodi_repo.split('.')[-1] == 'gz': addons_xml_gz = mktemp() download(kodi_repo, addons_xml_gz.name) addons_xml.seek(0) addons_xml.truncate() addons_xml.write(gunzip(addons_xml_gz.name).read()) addons_xml.flush() else: download(kodi_repo, addons_xml.name) # Load the actual xml addons = etree.parse(addons_xml.name) install_addon(repo_base, addons, module.params['name'], module.params['kodi_user'], kodi_home, module.params['kodi_release'], enabled) result['changed'] = True module.exit_json(**result)
def maybe_download(url, file, multilingual=True): if not os.path.exists(file): download(url, file) maybe_convert_to_json(file, multilingual)
def btnDownload_clkd(self): index = self.titleList.currentIndex() filmid = self.reqtext['results'][index]['id'] poster_path = self.reqtext['results'][index]['poster_path'] download('https://image.tmdb.org/t/p/%s/%s' % (self.poster_download_size, poster_path), '%s/%s.jpg' %(self.poster_download_path, filmid))
def write_package(self): key = pj('secret', 'key.pem') certs = pj('secret', 'certs') tmp_dir = pj(os.path.dirname(self.build_dir), '.tmp') package = self.package_name + '.' + self.ext if not os.path.isfile(key): sys.stderr.write(key + ' is missing\n') return if not os.path.isfile(pj(certs, 'safari_extension.cer')): sys.stderr.write( pj(certs, 'safari_extension.cer') + ' is missing\n' ) return try: os.remove(package) except: pass try: rmtree(tmp_dir) except: pass try: os.makedirs(tmp_dir) except: pass try: os.makedirs(certs) except: pass if not os.path.isfile(pj(certs, 'AppleWWDRCA.cer')): print('Downloading AppleWWDRCA.cer...') download( 'https://developer.apple.com/certificationauthority/AppleWWDRCA.cer', pj(certs, 'AppleWWDRCA.cer') ) if not os.path.isfile(pj(certs, 'AppleIncRootCertificate.cer')): print('Downloading AppleIncRootCertificate.cer...') download( 'https://www.apple.com/appleca/AppleIncRootCertificate.cer', pj(certs, 'AppleIncRootCertificate.cer') ) subprocess.call([ 'xar', '-czf', package, '--compression-args=9', '--distribution', '--directory', os.path.dirname(self.build_dir), os.path.basename(self.build_dir) ]) sig_len = len(subprocess.Popen( ['openssl', 'dgst', '-binary', '-sign', key, key], stdout=subprocess.PIPE ).stdout.read()) digest_dat = pj(tmp_dir, self.ext + '_digest.dat') sig_dat = pj(tmp_dir, self.ext + '_sig.dat') subprocess.call([ 'xar', '--sign', '-f', package, '--digestinfo-to-sign', digest_dat, '--sig-size', str(sig_len), '--cert-loc', pj(certs, 'safari_extension.cer'), '--cert-loc', pj(certs, 'AppleWWDRCA.cer'), '--cert-loc', pj(certs, 'AppleIncRootCertificate.cer') ]) subprocess.call([ 'openssl', 'rsautl', '-sign', '-inkey', key, '-in', digest_dat, '-out', sig_dat ]) subprocess.call(['xar', '--inject-sig', sig_dat, '-f', package]) try: rmtree(tmp_dir) except: pass
def run(self): download( 'https://image.tmdb.org/t/p/%s/%s' % (self.poster_download_size, self.poster_path), '%s/%s.jpg' % (self.poster_download_path, self.title))
def run(self): download('https://image.tmdb.org/t/p/%s/%s' % (self.poster_download_size,self.poster_path), '%s/%s.jpg' %(self.poster_download_path, self.title))