@@ -1,7 +1,8 @@ | |||
from sys import version_info | |||
from bs4 import BeautifulSoup | |||
from urllib.parse import urlparse, unquote, urlencode | |||
import shutil, cgi, os, urllib.request, argparse, sys, re, json | |||
import shutil, cgi, os, urllib.request, argparse, sys, re, json, gettext | |||
gettext.install('messages', localedir='po') | |||
#global variables | |||
base_folder = 'fmloader/' | |||
@@ -12,7 +13,7 @@ version = '0.0.5' | |||
try: | |||
assert version_info >= (3,6) | |||
except: | |||
print("you must have python 3.6 or higher installed\nthe script was intended to run on 3.6 or higher and won't account for python2 at all as well!") | |||
print(_("you must have python 3.6 or higher installed\nthe script was intended to run on 3.6 or higher and won't account for python2 at all as well!")) | |||
sys.exit() | |||
#end declarative jumbo | |||
@@ -54,10 +55,10 @@ def _download_file(link, file_link, additional_header=None, additional_fold=''): | |||
shutil.copyfileobj(response, out_file) | |||
except ValueError: | |||
raise ValueError | |||
print('Something\'s wrong with the link download routine') | |||
print(_('Something\'s wrong with the link download routine')) | |||
return -1 | |||
else: | |||
print('Done!') | |||
print(_('Done!')) | |||
return 0 | |||
def __zippyshare(parsed,baseurl): | |||
@@ -84,7 +85,7 @@ def __filesfm_file(parsed): | |||
try: | |||
result[1] = (parsed.find('div', class_='drop-down-options').find('a').get('href')) | |||
except: | |||
#print("Required div element not found or incorrect site") | |||
#print(_("Required div element not found or incorrect site")) | |||
return result | |||
if result[1].startswith('//'): | |||
if args.interactive: | |||
@@ -149,7 +150,7 @@ def _parse_files(parsed, link, __func_host): #this function is intended for fold | |||
input_invalid = True | |||
if args.interactive: | |||
while input_invalid: | |||
user_input = input('\nSelect your desired files by their indexes, comma separated (ex. 1,3,4): ') | |||
user_input = input('\n' + _('Select your desired files by their indexes, comma separated (ex. 1,3,4): ')) | |||
try: | |||
user_input = user_input.replace(' ',"").split(',') | |||
for i in range(len(user_input)): | |||
@@ -163,7 +164,7 @@ def _parse_files(parsed, link, __func_host): #this function is intended for fold | |||
try: | |||
pull = file_array[i][1] | |||
except: | |||
print('Errored index, continuing...') | |||
print(_('Errored index, continuing...')) | |||
continue | |||
_download_file(link,pull) | |||
elif file_array == 0: | |||
@@ -177,7 +178,7 @@ def url2bs(link): #simple, feed a link, poop a beautifulsoup object | |||
parsed = urllib.request.urlopen(link) | |||
parsed_bs = BeautifulSoup(parsed.read().decode('utf-8'), 'html.parser') | |||
except ValueError: | |||
print("Incorrect URL typed in, please copy and paste the link from the browser bar if possible! (recommended formatting: https://files.fm/u/{FILEID} )") | |||
print(_("Incorrect URL typed in, please copy and paste the link from the browser bar if possible! (recommended formatting: https://files.fm/u/{FILEID} )")) | |||
return -1 | |||
else: | |||
return parsed_bs | |||
@@ -202,12 +203,12 @@ def parse_link(link): #core function, if you'll ever intend to import it obv. fe | |||
if len(result) == 3: return _download_file(link,result[1], headers) | |||
else: return _download_file(link,result[1]) | |||
elif result[0] == 2: return _parse_files(parsed, link, __func_host) | |||
else: print('this should not happen'); return -1 | |||
else: print(_('this should not happen')); return -1 | |||
if __name__ == '__main__': | |||
parser = argparse.ArgumentParser(description='FilesFM python file&folder downloader') | |||
parser.add_argument('--interactive','-i', action='store_true', help='Enables prompts done during the download\nEnable this to activate partial folder downloads') | |||
parser.add_argument('urls', help='links to filehosts', nargs='*', type=str) | |||
parser = argparse.ArgumentParser(description=_('FilesFM python file&folder downloader')) | |||
parser.add_argument('--interactive','-i', action='store_true', help=_('Enables prompts done during the download\nEnable this to activate partial folder downloads')) | |||
parser.add_argument('urls', help=_('links to filehosts'), nargs='*', type=str) | |||
args = parser.parse_args() | |||
if len(sys.argv) > 1: | |||
for i in args.urls: |
@@ -0,0 +1,75 @@ | |||
# English translations for PACKAGE package. | |||
# Copyright (C) 2017 THE PACKAGE'S COPYRIGHT HOLDER | |||
# This file is distributed under the same license as the PACKAGE package. | |||
# john doe <acstubbins@openmailbox.org>, 2017. | |||
# | |||
msgid "" | |||
msgstr "" | |||
"Project-Id-Version: 0.0.5\n" | |||
"Report-Msgid-Bugs-To: acstubbins@opmbx.org \n" | |||
"POT-Creation-Date: 2017-11-18 14:06-0800\n" | |||
"PO-Revision-Date: 2017-11-18 14:13-0800\n" | |||
"Last-Translator: john doe <acstubbins@openmailbox.org>\n" | |||
"Language-Team: English\n" | |||
"Language: en_US\n" | |||
"MIME-Version: 1.0\n" | |||
"Content-Type: text/plain; charset=UTF-8\n" | |||
"Content-Transfer-Encoding: 8bit\n" | |||
"Plural-Forms: nplurals=2; plural=(n != 1);\n" | |||
#: filesfm.py:15 | |||
msgid "" | |||
"you must have python 3.6 or higher installed\n" | |||
"the script was intended to run on 3.6 or higher and won't account for " | |||
"python2 at all as well!" | |||
msgstr "" | |||
"you must have python 3.6 or higher installed\n" | |||
"the script was intended to run on 3.6 or higher and won't account for " | |||
"python2 at all as well!" | |||
#: filesfm.py:57 | |||
msgid "Something's wrong with the link download routine" | |||
msgstr "Something's wrong with the link download routine" | |||
#: filesfm.py:60 | |||
msgid "Done!" | |||
msgstr "Done!" | |||
#: filesfm.py:152 | |||
msgid "" | |||
"Select your desired files by their indexes, comma separated (ex. 1,3,4): " | |||
msgstr "" | |||
"Select your desired files by their indexes, comma separated (ex. 1,3,4): " | |||
#: filesfm.py:166 | |||
msgid "Errored index, continuing..." | |||
msgstr "Errored index, continuing..." | |||
#: filesfm.py:180 | |||
#, python-brace-format | |||
msgid "" | |||
"Incorrect URL typed in, please copy and paste the link from the browser bar " | |||
"if possible! (recommended formatting: https://files.fm/u/{FILEID} )" | |||
msgstr "" | |||
"Incorrect URL typed in, please copy and paste the link from the browser bar " | |||
"if possible! (recommended formatting: https://files.fm/u/{FILEID} )" | |||
#: filesfm.py:205 | |||
msgid "this should not happen" | |||
msgstr "this should not happen" | |||
#: filesfm.py:208 | |||
msgid "FilesFM python file&folder downloader" | |||
msgstr "FilesFM python file&folder downloader" | |||
#: filesfm.py:209 | |||
msgid "" | |||
"Enables prompts done during the download\n" | |||
"Enable this to activate partial folder downloads" | |||
msgstr "" | |||
"Enables prompts done during the download\n" | |||
"Enable this to activate partial folder downloads" | |||
#: filesfm.py:210 | |||
msgid "links to filehosts" | |||
msgstr "links to filehosts" |
@@ -0,0 +1,67 @@ | |||
# SOME DESCRIPTIVE TITLE. | |||
# Copyright (C) YEAR THE PACKAGE'S COPYRIGHT HOLDER | |||
# This file is distributed under the same license as the PACKAGE package. | |||
# FIRST AUTHOR <EMAIL@ADDRESS>, YEAR. | |||
# | |||
#, fuzzy | |||
msgid "" | |||
msgstr "" | |||
"Project-Id-Version: 0.0.5\n" | |||
"Report-Msgid-Bugs-To: acstubbins@opmbx.org" | |||
"POT-Creation-Date: 2017-11-18 14:06-0800\n" | |||
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" | |||
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n" | |||
"Language-Team: LANGUAGE <LL@li.org>\n" | |||
"Language: \n" | |||
"MIME-Version: 1.0\n" | |||
"Content-Type: text/plain; charset=UTF-8\n" | |||
"Content-Transfer-Encoding: 8bit\n" | |||
#: filesfm.py:15 | |||
msgid "" | |||
"you must have python 3.6 or higher installed\n" | |||
"the script was intended to run on 3.6 or higher and won't account for " | |||
"python2 at all as well!" | |||
msgstr "" | |||
#: filesfm.py:57 | |||
msgid "Something's wrong with the link download routine" | |||
msgstr "" | |||
#: filesfm.py:60 | |||
msgid "Done!" | |||
msgstr "" | |||
#: filesfm.py:152 | |||
msgid "" | |||
"Select your desired files by their indexes, comma separated (ex. 1,3,4): " | |||
msgstr "" | |||
#: filesfm.py:166 | |||
msgid "Errored index, continuing..." | |||
msgstr "" | |||
#: filesfm.py:180 | |||
#, python-brace-format | |||
msgid "" | |||
"Incorrect URL typed in, please copy and paste the link from the browser bar " | |||
"if possible! (recommended formatting: https://files.fm/u/{FILEID} )" | |||
msgstr "" | |||
#: filesfm.py:205 | |||
msgid "this should not happen" | |||
msgstr "" | |||
#: filesfm.py:208 | |||
msgid "FilesFM python file&folder downloader" | |||
msgstr "" | |||
#: filesfm.py:209 | |||
msgid "" | |||
"Enables prompts done during the download\n" | |||
"Enable this to activate partial folder downloads" | |||
msgstr "" | |||
#: filesfm.py:210 | |||
msgid "links to filehosts" | |||
msgstr "" |