Skip to content
Open
Changes from all commits
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
38 changes: 19 additions & 19 deletions MooDLD.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
import mechanize
from Crypto.Cipher import DES

moodle = 'http://moodle.iitb.ac.in/login/index.php'
moodle = 'https://moodle.iitb.ac.in/login/index.php'
# Create a browser instance
br = mechanize.Browser()

Expand Down Expand Up @@ -208,7 +208,7 @@ def __init__(self, mainlink, name, chkbox=None, directory=None,
#Get nf_link for any course_object
def get_nf_link(self):
br.open(self.mainlink)
for link in br.links(url_regex='http://moodle.iitb.ac.in/mod/forum/view.php'):
for link in br.links(url_regex='https://moodle.iitb.ac.in/mod/forum/view.php'):
if "?f=" not in link.url and not link.url.endswith('id=340'):
self.nflink = link.url

Expand Down Expand Up @@ -321,9 +321,9 @@ def login(self, username, password):
br['username'] = username
br['password'] = password
br.submit()
if br.geturl() == 'http://moodle.iitb.ac.in/':
if br.geturl() == 'https://moodle.iitb.ac.in/':
for link in \
br.links(url_regex='http://moodle.iitb.ac.in/user/profile.php'):
br.links(url_regex='https://moodle.iitb.ac.in/user/profile.php'):
self.profile = link.url
br.open(self.profile)
global myname
Expand All @@ -339,7 +339,7 @@ def check_connection(self):
'''

try:
br.open('http://moodle.iitb.ac.in/login/index.php')
br.open('https://moodle.iitb.ac.in/login/index.php')
return 1
except:
t.log('Could not connect to moodle, Please check your connection and try again!')
Expand Down Expand Up @@ -412,7 +412,7 @@ def nfretrieve(self, url, directory, number):

#create an array of all discussion links (self.urls)
#Newer threads come first in br.links()
for link in br.links(url_regex="http://moodle.iitb.ac.in/mod/forum/discuss.php"):
for link in br.links(url_regex="https://moodle.iitb.ac.in/mod/forum/discuss.php"):
if link.url == lasturl:
break
#breaking loop once last visited discussion/thread is encountered
Expand All @@ -427,7 +427,7 @@ def nfretrieve(self, url, directory, number):
br.open(url)

#create an array of all downloadables
for link in br.links(url_regex="http://moodle.iitb.ac.in/pluginfile.php"):
for link in br.links(url_regex="https://moodle.iitb.ac.in/pluginfile.php"):
self.nflinks.append(link)

#Download all downloadables
Expand Down Expand Up @@ -485,16 +485,16 @@ def retrieve(self, url, directory):

#Find all links inside given url and form array (self.links)
for link in br.links(url_regex='.'):
if (not link.url.startswith('http://moodle.iitb.ac.in/login/logout.php')
if (not link.url.startswith('https://moodle.iitb.ac.in/login/logout.php')
and not link.url.startswith(br.geturl())
and not link.url.startswith('#')
and not link.url.startswith('http://moodle.iitb.ac.in/mod/forum')
and not link.url.startswith('http://moodle.iitb.ac.in/my')
and not link.url.startswith('http://moodle.iitb.ac.in/user')
and not link.url.startswith('http://moodle.iitb.ac.in/badges')
and not link.url.startswith('http://moodle.iitb.ac.in/calendar')
and not link.url.startswith('http://moodle.iitb.ac.in/grade')
and not link.url.startswith('http://moodle.iitb.ac.in/message')
and not link.url.startswith('https://moodle.iitb.ac.in/mod/forum')
and not link.url.startswith('https://moodle.iitb.ac.in/my')
and not link.url.startswith('https://moodle.iitb.ac.in/user')
and not link.url.startswith('https://moodle.iitb.ac.in/badges')
and not link.url.startswith('https://moodle.iitb.ac.in/calendar')
and not link.url.startswith('https://moodle.iitb.ac.in/grade')
and not link.url.startswith('https://moodle.iitb.ac.in/message')
and link.url not in downloaded):
self.links.append(link)

Expand Down Expand Up @@ -531,7 +531,7 @@ def retrieve(self, url, directory):
downloadlinks.append(link.url)
else:
#Retrieve from folders
if (br.geturl().startswith('http://moodle.iitb.ac.in/mod/folder')
if (br.geturl().startswith('https://moodle.iitb.ac.in/mod/folder')
and link.url not in downloaded
and link.text.startswith('[IMG]')):
foldername = br.title()[br.title().index(':') + 2:]
Expand All @@ -544,7 +544,7 @@ def retrieve(self, url, directory):
self.retrieve(link.url, newpath + '/')

#Retrieve Assignments
if br.geturl().startswith('http://moodle.iitb.ac.in/mod/assign') \
if br.geturl().startswith('https://moodle.iitb.ac.in/mod/assign') \
and link.url not in downloaded:
downloaded.append(link.url)
if directory.endswith("Assignments/"):
Expand Down Expand Up @@ -726,9 +726,9 @@ def load_online_courses(self):
'''
Finds all links for course main pages and creates course_object objects
'''
br.open('http://moodle.iitb.ac.in/')
br.open('https://moodle.iitb.ac.in/')

for link in br.links(url_regex='http://moodle.iitb.ac.in/course/view.php'):
for link in br.links(url_regex='https://moodle.iitb.ac.in/course/view.php'):
online_courses.append(course_object(link.url, link.text))

def update_from_preferences(self, n):
Expand Down