Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
mega.py
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Tushar upadhyay
mega.py
Commits
837df565
Commit
837df565
authored
Jun 05, 2020
by
Tushar upadhyay
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Added get_embedlink method
parent
631ca606
Pipeline
#526
failed with stages
Changes
1
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
24 additions
and
1 deletion
+24
-1
src/mega/mega.py
src/mega/mega.py
+24
-1
No files found.
src/mega/mega.py
View file @
837df565
...
...
@@ -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
})
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment