Commit 837df565 authored by Tushar upadhyay's avatar Tushar upadhyay

Added get_embedlink method

parent 631ca606
Pipeline #526 failed with stages
......@@ -349,7 +349,30 @@ class Mega:
):
continue
return file
# Pass filename and extension to get embed link
# But this should work only for video files
def get_embedlink(self,filename,extension):
'''
Returns a Embed link Only for Video Files
Example
if file name is myvideo.mp4
m.get_embedlink('myvideo','mp4')
'''
if(extension==None):
raise Exception('file extension is required!')
supported_extensions = ['mp4','mpg','3gp','flv','avi']
if(extension in supported_extensions):
file = self.find(f"{filename}.{extension}")
if(file==None):
raise Exception('File not found')
file_url = str(self.get_link(file)).split('!')
embed_url = f"https://mega.nz/embed/{file_url[1]}#{file_url[2]}"
return embed_url
else:
raise Exception('This Extension is not supported')
def get_files(self):
logger.info('Getting all files...')
files = self._api_request({'a': 'f', 'c': 1, 'r': 1})
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment