Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix "invalid_filename" error when syncing to overleaf #70

Open
wants to merge 6 commits into
base: master
Choose a base branch
from
Open
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
fix for csrfToken and project query
svennniiii committed Mar 10, 2023
commit d8461937a7a4dabbf8ca24def1ccdd7332b43392
2 changes: 1 addition & 1 deletion olsync/olbrowserlogin.py
Original file line number Diff line number Diff line change
@@ -18,7 +18,7 @@
LOGIN_URL = "https://www.overleaf.com/login"
PROJECT_URL = "https://www.overleaf.com/project" # The dashboard URL
# JS snippet to get the first link
JAVASCRIPT_EXTRACT_PROJECT_URL = "document.getElementsByClassName('project-list-table-name-link')[0].href"
JAVASCRIPT_EXTRACT_PROJECT_URL = "document.getElementsByClassName('dash-cell-name')[1].firstChild.href"
# JS snippet to extract the csrfToken
JAVASCRIPT_CSRF_EXTRACTOR = "document.getElementsByName('ol-csrfToken')[0].content"
# Name of the cookies we want to extract
9 changes: 5 additions & 4 deletions olsync/olclient.py
Original file line number Diff line number Diff line change
@@ -15,6 +15,7 @@
import uuid
from socketIO_client import SocketIO
import time
import re

# Where to get the CSRF Token and where to send the login request to
LOGIN_URL = "https://www.overleaf.com/login"
@@ -89,8 +90,8 @@ def all_projects(self):
"""
projects_page = reqs.get(PROJECT_URL, cookies=self._cookie)
json_content = json.loads(
BeautifulSoup(projects_page.content, 'html.parser').find('meta', {'name': 'ol-projects'}).get('content'))
return list(OverleafClient.filter_projects(json_content))
BeautifulSoup(projects_page.content, 'html.parser').find("meta", {"content": re.compile('\{.*"projects".*\}')}).get('content'))
return list(OverleafClient.filter_projects(json_content['projects']))

def get_project(self, project_name):
"""
@@ -101,8 +102,8 @@ def get_project(self, project_name):

projects_page = reqs.get(PROJECT_URL, cookies=self._cookie)
json_content = json.loads(
BeautifulSoup(projects_page.content, 'html.parser').find('meta', {'name': 'ol-projects'}).get('content'))
return next(OverleafClient.filter_projects(json_content, {"name": project_name}), None)
BeautifulSoup(projects_page.content, 'html.parser').find("meta", {"content": re.compile('\{.*"projects".*\}')}).get('content'))
return next(OverleafClient.filter_projects(json_content['projects'], {"name": project_name}), None)

def download_project(self, project_id):
"""