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
AndeYashwanth
mega.py
Commits
6b71d2bf
Commit
6b71d2bf
authored
May 09, 2020
by
alec mcginnis
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Update mega.py
made def _parse_url() more robust
parent
987ac143
Pipeline
#547
failed with stages
Changes
1
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
14 additions
and
8 deletions
+14
-8
src/mega/mega.py
src/mega/mega.py
+14
-8
No files found.
src/mega/mega.py
View file @
6b71d2bf
...
...
@@ -189,16 +189,22 @@ class Mega:
raise
RequestError
(
json_resp
)
return
json_resp
[
0
]
# def _parse_url(self, url):
# # parse file id and key from url
# if '!' in url:
# match = re.findall(r'/#!(.*)', url)
# path = match[0]
# return path
# else:
# raise RequestError('Url key missing')
def
_parse_url
(
self
,
url
):
# parse file id and key from url
if
'#'
in
url
:
id
=
url
.
split
(
"file/"
,
5
)[
1
]
key
=
id
.
split
(
"#"
,
5
)[
1
]
id
=
id
.
split
(
"#"
,
5
)[
0
]
path
=
str
(
id
)
+
'!'
+
str
(
key
)
return
path
else
:
raise
RequestError
(
'Url key missing'
)
url
=
url
.
replace
(
" "
,
""
)
#strip spaces
id
=
re
.
findall
(
r'\W\w\w\w\w\w\w\w\w\W'
,
url
)[
0
][
1
:
-
1
]
id_index
=
re
.
search
(
id
,
url
)
.
end
()
key
=
url
[
id_index
+
1
:]
return
str
(
id
)
+
'!'
+
str
(
key
)
def
_process_file
(
self
,
file
,
shared_keys
):
if
file
[
't'
]
==
0
or
file
[
't'
]
==
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