def getMediaList(self, folderName='', cacheType=CACHE_TYPE_MEMORY): if folderName == '': folderName = 'myfiles' opener = urllib2.build_opener( urllib2.HTTPCookieProcessor(self.cookiejar), MyHTTPErrorProcessor) opener.addheaders = [('User-Agent', self.user_agent), ('X-Requested-With', 'XMLHttpRequest')] sessionValue = self.authorization.getToken('session_token') if (sessionValue == ''): xbmcgui.Dialog().ok(self.addon.getLocalizedString(30000), self.addon.getLocalizedString(30049), self.addon.getLocalizedString(30050), 'sessionValue') self.crashreport.sendError('getMediaList:sessionValue', 'not set') xbmc.log( self.addon.getAddonInfo('name') + ': ' + self.addon.getLocalizedString(30050) + 'sessionValue', xbmc.LOGERROR) return if folderName == 'FOLLOWING': url = 'https://www.mediafire.com/api/1.4/device/get_foreign_resources.php?r=sfrv&session_token=' + sessionValue + '&response_format=json' request = urllib2.Request(url) self.cookiejar.add_cookie_header(request) # try login try: response = opener.open(request) except urllib2.URLError, e: xbmc.log( self.addon.getAddonInfo('name') + ': ' + str(e), xbmc.LOGERROR) return response_data = response.read() response.close() mediaFiles = [] # parsing page for files for r in re.finditer('\"folders\"\:\[\{.*?\}\]', response_data, re.DOTALL): entry = r.group() for q in re.finditer( '\"name\"\:\"([^\"]+)\"\,.*?\"folderkey\"\:\"([^\"]+)\"', entry, re.DOTALL): subfolderName, subfolderID = q.groups() media = package.package( 0, folder.folder(subfolderID, subfolderName)) mediaFiles.append(media)
def script_run(rootdir="./workforce"): try: conn_vals = parse_dbconfig(rootdir + '/config.toml') except: conn_vals = parse_dbconfig() conn_str = "host='{}' dbname='{}' user='******' password='******'".format( conn_vals[0], conn_vals[1], conn_vals[2], conn_vals[3]) foldernames = next(os.walk(rootdir))[1] foldernames.remove(".git") foldernames.sort() idirs = [] odirs = [] for x in foldernames: idirs.append(folder(rootdir + "/{0}/sql/".format(x))) odirs.append(folder(rootdir + "/{0}/data/".format(x))) for x, y in zip(idirs, odirs): f = [] fln = "00" try: f = next(os.walk(x.dirnm))[2] except StopIteration: pass for z in f: if z.endswith(".sql"): x.add_file(z) y.add_file("data{0}.csv".format(fln)) fln = increment_string(fln) try: for x, y in zip(idirs, odirs): for z, w in zip(x.files, y.files): query_exec(conn_str, z, w) print("Completed successfully!") except FileNotFoundError as e: print("NOTE: {0}".format(str(e))) print("If a query should exist within this dir, filepath must match") except Exception as e: print("FAILURE: {0}".format(str(e)))
def walk(path, depth = 0): current_folder = folder(path) current_folder.depth = depth # current_folder.size = get_folder_size(current_folder.path) for child in os.listdir(path): full_path = join(path, child) if not child.startswith("."): if isdir(full_path): new_folder = walk(full_path, depth+1) new_folder.parent = current_folder current_folder.children.append(new_folder) else: new_file = file(full_path) new_file.depth = depth +1 new_file.parent = current_folder current_folder.children.append(new_file) return current_folder
def getMediaList(self, folderName='', cacheType=CACHE_TYPE_MEMORY): if folderName == '': folderName = 'myfiles' opener = urllib2.build_opener(urllib2.HTTPCookieProcessor(self.cookiejar), MyHTTPErrorProcessor) opener.addheaders = [('User-Agent', self.user_agent),('X-Requested-With' ,'XMLHttpRequest')] sessionValue = self.authorization.getToken('session_token') if (sessionValue == ''): xbmcgui.Dialog().ok(self.addon.getLocalizedString(30000), self.addon.getLocalizedString(30049), self.addon.getLocalizedString(30050),'sessionValue') self.crashreport.sendError('getMediaList:sessionValue','not set') xbmc.log(self.addon.getAddonInfo('name') + ': ' + self.addon.getLocalizedString(30050)+ 'sessionValue', xbmc.LOGERROR) return if folderName == 'FOLLOWING': url = 'https://www.mediafire.com/api/1.4/device/get_foreign_resources.php?r=sfrv&session_token='+sessionValue+'&response_format=json' request = urllib2.Request(url) self.cookiejar.add_cookie_header(request) # try login try: response = opener.open(request) except urllib2.URLError, e: xbmc.log(self.addon.getAddonInfo('name') + ': ' + str(e), xbmc.LOGERROR) return response_data = response.read() response.close() mediaFiles = [] # parsing page for files for r in re.finditer('\"folders\"\:\[\{.*?\}\]' ,response_data, re.DOTALL): entry = r.group() for q in re.finditer('\"name\"\:\"([^\"]+)\"\,.*?\"folderkey\"\:\"([^\"]+)\"' ,entry, re.DOTALL): subfolderName,subfolderID = q.groups() media = package.package(0,folder.folder(subfolderID,subfolderName)) mediaFiles.append(media)
def sendmsg(): wx = zhibanqun() ct = context() fd = folder() ky = key() vt = vrbt() # 1.刷新 ky.flash() vt.flash() # 2.复制文本 ct.copycontext() wx.self_stick() # 3.截图 ky.cut() vt.cut() # 4.复制图片 fd.get_key() wx.self_stick() fd.get_vrbt() wx.self_stick() wx.send()
def run_example(): #first lets get the auth code from the client request_token_url = huddleAuthServer + "request?response_type=code" + "&client_id=" + consumer_key + "&redirect_uri=" + redirect_uri print "Get Your Authorization Code and paste it back into python\n" + request_token_url code = raw_input('--> ') auth = oAuth.oAuth(huddleAuthServer, code, consumer_key, redirect_uri) #store our access token tokenStore = auth.handleAccessToken() #now we can make calls to the api #we only have the uri for what folder we want to create the file in so first of all lets find the upload uri of that api = huddleApi.huddleApi(huddleApiServer, tokenStore) getFolder = folder.folder(api.getFolder("http://api.huddle.dev/files/folders/1237980/")) print getFolder.getLinksWithRel("create-document") getDocument = document.document(api.createFile("foo", "bar", getFolder.getLinksWithRel("create-document"))) #time to upload the contents api.uploadToFile("C:\\Users\\adam.flax\\Documents\\foo.txt", getDocument.getLinkWithRel("upload")) os.system("pause")
for r in re.finditer('\{\"audio\"\:.*?\"userRole\"\:0\}', response_data, re.DOTALL): entry = r.group() for q in re.finditer('\"(download)\"\:\"([^\"]+)\",', entry, re.DOTALL): downloadID, downloadURL = q.groups() for q in re.finditer('\"(title)\"\:\"([^\"]+)\",', entry, re.DOTALL): titleID, title = q.groups() downloadURL = re.sub('\\\\', '', downloadURL) downloadURL = re.sub('\%20', '+', downloadURL) media = package.package( file.file(title, title, title, self.AUDIO, '', ''), folder.folder('', '')) media.setMediaURL(mediaurl.mediaurl(downloadURL, '', '', '')) mediaFiles.append(media) for r in re.finditer( 'data\-downloadurl\=\"video\/[^\:]+\:([^\:]+)\:\/index\.php\?rm\=box_v2_download_file\&\;file_id\=([^\&]+)\&\;print_download_url\=1\"', response_data, re.DOTALL): fileName, fileID = r.groups() media = package.package( file.file(fileID, fileName, fileName, self.VIDEO, '', ''), folder.folder('', '')) mediaFiles.append(media) for r in re.finditer( 'data\-downloadurl\=\"audio\/[^\:]+\:([^\:]+)\:\/index\.php\?rm\=box_v2_download_file\&\;file_id\=([^\&]+)\&\;print_download_url\=1\"', response_data, re.DOTALL):
# return mediaFiles = [] # parsing page for files for r in re.finditer('\{\"audio\"\:.*?\"userRole\"\:0\}' ,response_data, re.DOTALL): entry = r.group() for q in re.finditer('\"(download)\"\:\"([^\"]+)\",' ,entry, re.DOTALL): downloadID,downloadURL = q.groups() for q in re.finditer('\"(title)\"\:\"([^\"]+)\",' ,entry, re.DOTALL): titleID,title = q.groups() downloadURL = re.sub('\\\\', '', downloadURL) downloadURL = re.sub('\%20', '+', downloadURL) media = package.package(file.file(title, title, title, self.AUDIO, '', ''),folder.folder('','')) media.setMediaURL(mediaurl.mediaurl(downloadURL, '','','')) mediaFiles.append(media) for r in re.finditer('data\-downloadurl\=\"video\/[^\:]+\:([^\:]+)\:\/index\.php\?rm\=box_v2_download_file\&\;file_id\=([^\&]+)\&\;print_download_url\=1\"' ,response_data, re.DOTALL): fileName,fileID = r.groups() media = package.package(file.file(fileID, fileName, fileName, self.VIDEO, '', ''),folder.folder('','')) mediaFiles.append(media) for r in re.finditer('data\-item_id\=\"([^\"]+)\" data\-item_type\=\"folder\" data\-behavior\=\"edit_in_place\" data\-validate\=\"filename not_empty_item_type\"\>([^\<]+)\<\/a\>' ,response_data, re.DOTALL): folderID,folderName = r.groups() media = package.package(0,folder.folder(folderID,folderName)) mediaFiles.append(media)
''' Quick and dirty hack by stephen to add cc to course capture videos Need to add better error handling ''' if __name__ == "__main__": print "Starting..." config = parsejson() db = datastore() db.loadtables() myrequests = httprequests(config.config) myrequests.login() try: while 1: for k,p in config.dirs.iteritems(): #print p f = folder(p) f.load() db.addnew(f.hasvideo()) pending = db.getallpending() #myrequests.createjob() for pend in pending: print p print "-----" info = myrequests.createjob() print pend[2] r = myrequests.addmedia(pend[2],info['jobid']) #after upload, save the task and job id to db and change status db.setrowinfo(pend[2], "uploaded", info['jobid'], r['taskid']) r2 = db.getinfo(pend[2]) print r2 myrequests.perform_transcription(r2[0][4])
import os from folder import folder from file import file def goThroughFolder(tree: folder): stack = [] stack.append(tree) while (stack): tree = stack.pop() # THis call will add to the tree.init(stack) tree.tranverse() pass print("Am Done, Study well") pass currDir = os.getcwd() # directory = input("Type the directory Want To Attack ") rootDir = folder(os.path.join(currDir, "en-US"), 0) goThroughFolder(rootDir)
def __init__(self): self.folders = folder()
except urllib2.URLError, e: xbmc.log(self.addon.getAddonInfo('name') + ': ' + str(e), xbmc.LOGERROR) return response_data = response.read() response.close() mediaFiles = [] # parsing page for files for r in re.finditer('\{\"folderkey\"\:.*?\"dropbox_enabled\"\:\"[^\"]+\"\}' ,response_data, re.DOTALL): entry = r.group() for q in re.finditer('\"folderkey\"\:\"([^\"]+)\"\,\"name\"\:\"([^\"]+)\"' ,entry, re.DOTALL): subfolderID,subfolderName = q.groups() media = package.package(0,folder.folder(subfolderID,subfolderName)) mediaFiles.append(media) url = 'https://www.mediafire.com/api/folder/get_content.php?r=mvbn&content_type=files&filter=all&order_by=name&order_direction=asc&chunk=1&version=1.2&folder_key='+folderName+'&session_token='+sessionValue+'&response_format=json' request = urllib2.Request(url) self.cookiejar.add_cookie_header(request) # try login try: response = opener.open(request) except urllib2.URLError, e: xbmc.log(self.addon.getAddonInfo('name') + ': ' + str(e), xbmc.LOGERROR) return response_data = response.read()
response_data = response.read() response.close() mediaFiles = [] # parsing page for files for r in re.finditer( '\{\"folderkey\"\:.*?\"dropbox_enabled\"\:\"[^\"]+\"\}', response_data, re.DOTALL): entry = r.group() for q in re.finditer( '\"folderkey\"\:\"([^\"]+)\"\,\"name\"\:\"([^\"]+)\"', entry, re.DOTALL): subfolderID, subfolderName = q.groups() media = package.package( 0, folder.folder(subfolderID, subfolderName)) mediaFiles.append(media) url = 'https://www.mediafire.com/api/folder/get_content.php?r=mvbn&content_type=files&filter=all&order_by=name&order_direction=asc&chunk=1&version=1.2&folder_key=' + folderName + '&session_token=' + sessionValue + '&response_format=json' request = urllib2.Request(url) self.cookiejar.add_cookie_header(request) # try login try: response = opener.open(request) except urllib2.URLError, e: xbmc.log( self.addon.getAddonInfo('name') + ': ' + str(e), xbmc.LOGERROR)
mediaFiles = [] if folderName == 'FRIENDS': for r in re.finditer( '\"thumbnail\"\:\"([^\"]+)\".*?\"userId\"\:\"([^\"]+)\"\,\"authName\"\:([^\,]+)\,\"authLastName\"\:([^\,]+)\,\"authFirstName\"\:([^\,]+)\,', response_data, re.DOTALL): thumb, userID, userName, userFirst, userLast = r.groups() thumbURL = re.sub('"', '', re.sub('\\\/', '/', thumb)) userName = re.sub('"', '', userName) userFirst = re.sub('"', '', userFirst) userLast = re.sub('"', '', userLast) if userName != 'null': media = package.package( 0, folder.folder('u=' + userID + 'f=0', userName, thumbURL)) else: media = package.package( 0, folder.folder('u=' + userID + 'f=0', userFirst + ' - ' + userLast, thumbURL)) mediaFiles.append(media) return mediaFiles elif folderName == 'FEED': for r in re.finditer('\{\"id\"\:.*?\d\"\}', response_data, re.DOTALL): entry = r.group() for q in re.finditer(
response_data = response.read() response.close() mediaFiles = [] if folderName == 'FRIENDS': for r in re.finditer('\"thumbnail\"\:\"([^\"]+)\".*?\"userId\"\:\"([^\"]+)\"\,\"authName\"\:([^\,]+)\,\"authLastName\"\:([^\,]+)\,\"authFirstName\"\:([^\,]+)\,' ,response_data, re.DOTALL): thumb,userID,userName,userFirst,userLast = r.groups() thumbURL = re.sub('"', '', re.sub('\\\/', '/', thumb)) userName = re.sub('"', '', userName) userFirst = re.sub('"', '', userFirst) userLast = re.sub('"', '', userLast) if userName != 'null': media = package.package(0,folder.folder('u='+userID+'f=0',userName, thumbURL)) else: media = package.package(0,folder.folder('u='+userID+'f=0',userFirst + ' - '+userLast, thumbURL)) mediaFiles.append(media) return mediaFiles elif folderName == 'FEED': for r in re.finditer('\{\"id\"\:.*?\d\"\}' ,response_data, re.DOTALL): entry = r.group() for q in re.finditer('\"hiveId\"\:\"([^\"]+)\".*?\"thumb\"\:\"([^\"]+)\".*\"title\"\:\"([^\"]+)\".*\"type\"\:\"video\"' ,entry, re.DOTALL): fileID,thumbnail,fileName = q.groups() thumbnail = re.sub('\\\\', '', thumbnail) fileName = urllib.quote(fileName) media = package.package(file.file(fileID, fileName, fileName, self.VIDEO, '', thumbnail),folder.folder('',''))
def list_folders(self, path = '/media'): from folder import folder obj = folder() result = obj.getdirs(search = path) return '\t'.join(result)
except: playbackType = 0 else: try: if mode == 'audio': playbackType = int(addon.getSetting('free_playback_type_audio')) else: playbackType = int(addon.getSetting('free_playback_type_video')) except: if mode == 'audio': playbackType = 0 else: playbackType = 1 mediaFile = file.file(filename, title, '', 0, '','') mediaFolder = folder.folder(directory,directory) mediaURLs = service.getPlaybackCall(playbackType,package.package(mediaFile,mediaFolder )) playbackURL = '' # BEGIN JoKeRzBoX # - Get list of possible resolutions (quality), pre-ordered from best to lower res, from a String constant # - Create associative array (a.k.a. hash list) availableQualities with each available resolution (key) and media URL (value) # - Simple algorithm to go through possible resolutions and find the best available one based on user's choice # FIX: list of qualities shown to user are now ordered from highest to low resolution if mode == 'audio': possibleQualities = addon.getLocalizedString(30058) else: possibleQualities = addon.getLocalizedString(30057) listPossibleQualities = possibleQualities.split("|") availableQualities = {}
for q in re.finditer('\"name\"\:\"([^\"]+)\",' ,entry, re.DOTALL): fileName= q.group(1) break # for q in re.finditer('\"url_for_page_link\"\:\"([^\"]+)\",' ,entry, re.DOTALL): for q in re.finditer('\"url_for_page_link\"\:\"([^\"]+)\",' ,entry, re.DOTALL): downloadURL = q.group(1) #downloadURL = re.sub('\\', '', downloadURL) #downloadURL = re.sub('\%20', '+', downloadURL) break for q in re.finditer('\"id\"\:([^\,]+),' ,entry, re.DOTALL): fileID = q.group(1) break if contentType == 'audio': media = package.package(file.file(fileID, fileName, fileName, self.AUDIO, '', ''),folder.folder('','')) elif contentType == 'video': media = package.package(file.file('f_'+str(fileID), fileName, fileName, self.VIDEO, '', ''),folder.folder('','')) #media.setMediaURL(mediaurl.mediaurl(downloadURL, '','','')) mediaFiles.append(media) for r in re.finditer('data\-downloadurl\=\"video\/[^\:]+\:([^\:]+)\:\/index\.php\?rm\=box_v2_download_file\&\;file_id\=([^\&]+)\&\;print_download_url\=1\"' ,response_data, re.DOTALL): fileName,fileID = r.groups() media = package.package(file.file(fileID, fileName, fileName, self.VIDEO, '', ''),folder.folder('','')) mediaFiles.append(media) for r in re.finditer('data\-downloadurl\=\"audio\/[^\:]+\:([^\:]+)\:\/index\.php\?rm\=box_v2_download_file\&\;file_id\=([^\&]+)\&\;print_download_url\=1\"' ,response_data, re.DOTALL): fileName,fileID = r.groups() media = package.package(file.file(fileID, fileName, fileName, self.AUDIO, '', ''),folder.folder('','')) mediaFiles.append(media)