diff --git a/synchronize/synchronize.py b/synchronize/synchronize.py new file mode 100644 index 0000000..7f07777 --- /dev/null +++ b/synchronize/synchronize.py @@ -0,0 +1,150 @@ +import requests +import os +import time +import json + +print('[' + time.strftime("%Y-%m-%d %H:%M:%S", time.localtime()) + ']' + '[INFO]:Starting the synchronizing system.') +#------------------------------------------------------------------------# +print('------------------------------------------------------------------------') + +#Part Of Load All Kinds Of Global Variables From Json File. + +print('[' + time.strftime("%Y-%m-%d %H:%M:%S", time.localtime()) + ']' + '[INFO]:Starting to specify global variables from json file.') +configopen=open("synchronize/config.json", mode='r') +configjson = configopen.read() +configopen.close() +config = json.loads(configjson) +SystemName=config['systemname'] +SavePath='synchronize/' + config['savepath'] +Version=config['version'] +UserAgent={'User-Agent':config['useragent']} +Log='[' + time.strftime("%Y-%m-%d %H:%M:%S", time.localtime()) + ']' + '[INFO]:Starting the synchronizing system.\n' + '------------------------------------------------------------------------\n' + '[' + time.strftime("%Y-%m-%d %H:%M:%S", time.localtime()) + ']' + '[INFO]:Starting to specify global variables.\n' + '[' + time.strftime("%Y-%m-%d %H:%M:%S", time.localtime()) + ']' + '[INFO]:Specifying global variables successful.\n' +print('[' + time.strftime("%Y-%m-%d %H:%M:%S", time.localtime()) + ']' + '[INFO]:Specifying global variables successful.') + +#------------------------------------------------------------------------# +print('------------------------------------------------------------------------') +Log=Log + '------------------------------------------------------------------------' + '\n' + +#The Part Of All Kinds Of Functions. + +print('[' + time.strftime("%Y-%m-%d %H:%M:%S", time.localtime()) + ']' + '[INFO]:Starting to load all kinds of modules.') +Log=Log + '[' + time.strftime("%Y-%m-%d %H:%M:%S", time.localtime()) + ']' + '[INFO]:Starting to load all kinds of modules.' + '\n' +#Module Which Be Used To Print And Save Logs. +def log(logvar): + global Log + print('[' + time.strftime("%Y-%m-%d %H:%M:%S", time.localtime()) + ']' + logvar) + Log=Log + '[' + time.strftime("%Y-%m-%d %H:%M:%S", time.localtime()) + ']' + logvar + '\n' +#Module Which Be Used To Synchronize Single File. +def synchronize(url, filepath): + global Log + global UserAgent + log('[INFO]:The ' + SystemName + ' is synchronizing the file ' + SavePath + filepath + '.') + try: + synchronize=requests.get(url, headers=UserAgent)#Without Proxies + with open(SavePath + filepath,"wb") as code: + code.write(synchronize.content) + except: + log('[ERROR]:There has a error in task of synchronizing the file ' + SavePath + filepath + '.') + else: + log('[INFO]:The file ' + SavePath + filepath + ' has been synchronized successfully.') +#Module Which Be Used To Determine Whether The Dir Exists. +def make_sure_dir_exists(dirpath): + global Log + if os.path.exists(SavePath + dirpath): + log('[INFO]:The dir ' + SavePath + dirpath + ' has already existed.Nothing to do.') + else: + log('[INFO]:The dir ' + SavePath + dirpath + ' does not exist.The ' + SystemName + ' will create one.') + os.makedirs(SavePath + dirpath) +log('[INFO]:Loading all kinds of modules successfully.') + +#------------------------------------------------------------------------# +print('------------------------------------------------------------------------') +Log=Log + '------------------------------------------------------------------------' + '\n' + +#Save JSON In Global Variables + +log('[INFO]:Starting to get the json of MC versions list.') +Log=Log + '[' + time.strftime("%Y-%m-%d %H:%M:%S", time.localtime()) + ']' + '[INFO]:Starting to get the json of MC versions list.' + '\n' +#Save MC Versions List Json In Global Variables +mcversionsjson=requests.get(url='http://launchermeta.mojang.com/mc/game/version_manifest.json') +log('[INFO]:Get json of MC versions successfully.') +Log=Log + '[' + time.strftime("%Y-%m-%d %H:%M:%S", time.localtime()) + ']' + '[INFO]:Get json of MC versions successfully.' + '\n' + +#------------------------------------------------------------------------# +print('------------------------------------------------------------------------') +Log=Log + '------------------------------------------------------------------------' + '\n' + +#The Part of Determining Whether The Dir Exists. + +#Determining Whether The Log Dir Exists. +log('[INFO]:Starting to determine whether the log dir exists.') +dirpath='synchronize/' + config['logspath'] +if os.path.exists(dirpath): + log('[INFO]:The dir ' + dirpath + ' has already existed.Nothing to do.') +else: + log('[INFO]:The dir ' + dirpath + ' does not exist.The ' + SystemName + ' will create one.') + os.makedirs(dirpath) +log('[INFO]:Determining whether the log dir exists successfully.') +log('[INFO]:Starting to determine whether all of dirs exists.') +#Determining Whether The MC Versions Dir Exists. +log('[INFO]:Starting to determine whether the MC versions dir exists.') +make_sure_dir_exists('mojang/launchermeta/mc/game') +log('[INFO]:Determining whether the MC versions dir exists successfully.') +#Determining Whether The Liteloader Versions Dir Exists. +log('[INFO]:Starting to determine whether the Liteloader versions dir exists.') +make_sure_dir_exists('liteloader/dl/versions') +log('[INFO]:Determining whether the Liteloader versions dir exists successfully.') +log('[INFO]:Determining whether all of dirs exists successfully.') + +#------------------------------------------------------------------------# +print('------------------------------------------------------------------------') +Log=Log + '------------------------------------------------------------------------' + '\n' + +#The Part of Synchronizing Single Important Files. + +log('[INFO]:Starting to synchronize single files.') +#Synchronizing The Minecraft Versions List File. +log('[INFO]:Starting to synchronize MC versions files.') +synchronize('http://launchermeta.mojang.com/mc/game/version_manifest.json', 'mojang/launchermeta/mc/game/version_manifest.json') +log('[INFO]:Synchronizing MC versions files successfully.') +#Synchronizing The Liteloader Versions List File. +log('[INFO]:Starting to synchronize Liteloader versions files.') +synchronize('http://dl.liteloader.com/versions/versions.json', 'liteloader/dl/versions/versions.json') +log('[INFO]:Synchronizing Liteloader versions files successfully.') + +#------------------------------------------------------------------------# +print('------------------------------------------------------------------------') +Log=Log + '------------------------------------------------------------------------' + '\n' + +log('[INFO]:Starting to synchronize more files.') +log('[WARN]:Attention!In the version new than 2.3.0,the synchronize tools will synchronize files in the background to improve the speed of synchronize,that means you will not see the log output in the shell/cmd/powershell.If you want to see all logs and not care about the speed,you can download the old version on gitee,but we will not provide update for it.') + +#------------------------------------------------------------------------# +print('------------------------------------------------------------------------') +Log=Log + '------------------------------------------------------------------------' + '\n' + +#MC Versions Synchronizing Part. +log('[INFO]:Starting synchronize all of MC versions.') + +#Part 1. +log('[INFO]:Starting synchronize part 1.') +log('[INFO]:Starting to synchronize files and dirs on https://launchermeta.mojang.com/.') +os.popen('python synchronize/part1.py','r') + +time.sleep(5) + +#Part 2. +log('[INFO]:Starting synchronize part 2.') +log('[INFO]:Starting to synchronize files and dirs on https://libraries.minecraft.net/.') +os.popen('python synchronize/part2.py','r') + +#------------------------------------------------------------------------# +print('------------------------------------------------------------------------') +Log=Log + '------------------------------------------------------------------------' + '\n' + +#Starting To Save Logs. +log('[INFO]:Starting to save logs.') +logwrite=open('synchronize/' + config['logspath'] + "main-" + str(time.strftime("%Y-%m-%d-%H-%M-%S", time.localtime()) + '.txt'),mode='w') +logwrite.write(Log + '[' + time.strftime("%Y-%m-%d %H:%M:%S", time.localtime()) + ']' + '[INFO]:Save logs successfully.' + '\n' + '[' + time.strftime("%Y-%m-%d %H:%M:%S", time.localtime()) + ']' + '[INFO]:All tasks of synchronizing have done successfully.') +print('[' + time.strftime("%Y-%m-%d %H:%M:%S", time.localtime()) + ']' + '[INFO]:Save logs successfully.' + '\n' + '[' + time.strftime("%Y-%m-%d %H:%M:%S", time.localtime()) + ']' + '[INFO]:All tasks of synchronizing have done successfully.') +logwrite.close() diff --git a/synchronize/synchronize/config.json b/synchronize/synchronize/config.json new file mode 100644 index 0000000..0cf4c9c --- /dev/null +++ b/synchronize/synchronize/config.json @@ -0,0 +1,7 @@ +{ + "savepath":"gemcapi/", + "version":"3.0.0", + "useragent":"'GeMCAPI/3.0.0 (GeMC Sync Release 3.0.0;Release)'", + "systemname":"GeMC API Synchronize Tool", + "logspath":"logs/" +} \ No newline at end of file diff --git a/synchronize/synchronize/part1.py b/synchronize/synchronize/part1.py new file mode 100644 index 0000000..0dae7b1 --- /dev/null +++ b/synchronize/synchronize/part1.py @@ -0,0 +1,101 @@ +import requests +import os +import time +import json +import sys + +#------------------------------------------------------------------------# + +#Part Of Load All Kinds Of Global Variables From Json File. + +configopen=open(os.path.dirname(os.path.abspath(sys.argv[0])) + "/config.json", mode='r') +configjson=configopen.read() +configopen.close() +config=json.loads(configjson) +SystemName=config['systemname'] +SavePath=os.path.dirname(os.path.abspath(sys.argv[0])) + "/" + config['savepath'] +Version=config['version'] +UserAgent={'User-Agent':config['useragent']} +Log='[' + time.strftime("%Y-%m-%d %H:%M:%S", time.localtime()) + ']' + '[INFO]:Starting the synchronizing system.\n' + '------------------------------------------------------------------------\n' + '[' + time.strftime("%Y-%m-%d %H:%M:%S", time.localtime()) + ']' + '[INFO]:Starting to specify global variables.\n' + '[' + time.strftime("%Y-%m-%d %H:%M:%S", time.localtime()) + ']' + '[INFO]:Specifying global variables successful.\n' + +#------------------------------------------------------------------------# +Log=Log + '------------------------------------------------------------------------' + '\n' + +#The Part Of All Kinds Of Functions. + +Log=Log + '[' + time.strftime("%Y-%m-%d %H:%M:%S", time.localtime()) + ']' + '[INFO]:Starting to load all kinds of modules.' + '\n' +#Module Which Be Used To Save Logs. +def log(logvar): + global Log + Log=Log + '[' + time.strftime("%Y-%m-%d %H:%M:%S", time.localtime()) + ']' + logvar + '\n' +#Module Which Be Used To Synchronize Single File. +def synchronize(url, filepath): + global Log + global UserAgent + log('[INFO]:The ' + SystemName + ' is synchronizing the file ' + SavePath + filepath + '.') + try: + synchronize=requests.get(url, headers=UserAgent)#Without Proxies + with open(SavePath + filepath,"wb") as code: + code.write(synchronize.content) + except: + log('[ERROR]:There has a error in task of synchronizing the file ' + SavePath + filepath + '.') + else: + log('[INFO]:The file ' + SavePath + filepath + ' has been synchronized successfully.') +#Module Which Be Used To Determine Whether The Dir Exists. +def make_sure_dir_exists(dirpath): + global Log + if os.path.exists(SavePath + dirpath): + log('[INFO]:The dir ' + SavePath + dirpath + ' has already existed.Nothing to do.') + else: + log('[INFO]:The dir ' + SavePath + dirpath + ' does not exist.The ' + SystemName + ' will create one.') + os.makedirs(SavePath + dirpath) +log('[INFO]:Loading all kinds of modules successfully.') + +#------------------------------------------------------------------------# +Log=Log + '------------------------------------------------------------------------' + '\n' + +#Save JSON In Global Variables + +log('[INFO]:Starting to get the json of MC versions list.') +Log=Log + '[' + time.strftime("%Y-%m-%d %H:%M:%S", time.localtime()) + ']' + '[INFO]:Starting to get the json of MC versions list.' + '\n' +#Save MC Versions List Json In Global Variables +mcversionsjson=requests.get(url='http://launchermeta.mojang.com/mc/game/version_manifest.json') +log('[INFO]:Get json of MC versions successfully.') +Log=Log + '[' + time.strftime("%Y-%m-%d %H:%M:%S", time.localtime()) + ']' + '[INFO]:Get json of MC versions successfully.' + '\n' + +#------------------------------------------------------------------------# +Log=Log + '------------------------------------------------------------------------' + '\n' + +log('[INFO]:Starting to count how many MC versions in total.') +#Count How Many MC Versions in total. +mcversionsjsontext=mcversionsjson.text +mcversionsnumber=mcversionsjsontext.count('"url":') +log('[INFO]:There has ' + str(mcversionsnumber) + ' MC versions in total .') +log('[INFO]:Counting how many MC versions in total successfully.') + +#Auto Synchronize Files And Dirs on https://launchermeta.mojang.com/. +log('[INFO]:Starting to synchronize files and dirs on https://launchermeta.mojang.com/.') +whiletimes=0#Set Var whiletimes To Avoid Error. +while(whiletimes < mcversionsnumber): + #Count While Times. + whiletimes=whiletimes + 1 + #Read Json Of MC Versions List. + downloadurlload=json.loads(mcversionsjsontext) + whiletimesload=whiletimes - 1 + onlineurl=downloadurlload['versions'][whiletimesload]['url'] + onlineurlwithouthttps=onlineurl.replace('https://', 'http://')#Avoid Https Connetion Errors + fileurl='mojang/launchermeta/' + onlineurl.replace('https://launchermeta.mojang.com/','') + filetosync=fileurl[::-1].split('/', 1)[-1][::-1] + #Synchronize. + make_sure_dir_exists(filetosync) + synchronize(onlineurlwithouthttps, fileurl) +log('[INFO]:Synchronizing files and dirs on https://launchermeta.mojang.com/ successfully.') + +#------------------------------------------------------------------------# +Log=Log + '------------------------------------------------------------------------' + '\n' + +#Starting To Save Logs. +log('[INFO]:Starting to save logs.') +logwrite=open(os.path.dirname(os.path.abspath(sys.argv[0])) + config['logspath'] + 'part1-' + str(time.strftime("%Y-%m-%d-%H-%M-%S", time.localtime()) + '.txt'),mode='w') +logwrite.write(Log + '[' + time.strftime("%Y-%m-%d %H:%M:%S", time.localtime()) + ']' + '[INFO]:Save logs successfully.' + '\n' + '[' + time.strftime("%Y-%m-%d %H:%M:%S", time.localtime()) + ']' + '[INFO]:All tasks of synchronizing have done successfully.') +logwrite.close() diff --git a/synchronize/synchronize/part2.py b/synchronize/synchronize/part2.py new file mode 100644 index 0000000..688ae66 --- /dev/null +++ b/synchronize/synchronize/part2.py @@ -0,0 +1,201 @@ +import requests +import os +import time +import json +import sys + +#------------------------------------------------------------------------# + +#Part Of Load All Kinds Of Global Variables From Json File. + +configopen=open(os.path.dirname(os.path.abspath(sys.argv[0])) + "/config.json", mode='r') +configjson=configopen.read() +configopen.close() +config=json.loads(configjson) +SystemName=config['systemname'] +SavePath=os.path.dirname(os.path.abspath(sys.argv[0])) + "/" + config['savepath'] +Version=config['version'] +UserAgent={'User-Agent':config['useragent']} +Log='[' + time.strftime("%Y-%m-%d %H:%M:%S", time.localtime()) + ']' + '[INFO]:Starting the synchronizing system.\n' + '------------------------------------------------------------------------\n' + '[' + time.strftime("%Y-%m-%d %H:%M:%S", time.localtime()) + ']' + '[INFO]:Starting to specify global variables.\n' + '[' + time.strftime("%Y-%m-%d %H:%M:%S", time.localtime()) + ']' + '[INFO]:Specifying global variables successful.\n' + +#------------------------------------------------------------------------# +Log=Log + '------------------------------------------------------------------------' + '\n' + +#The Part Of All Kinds Of Functions. + +Log=Log + '[' + time.strftime("%Y-%m-%d %H:%M:%S", time.localtime()) + ']' + '[INFO]:Starting to load all kinds of modules.' + '\n' +#Module Which Be Used To Save Logs. +def log(logvar): + global Log + Log=Log + '[' + time.strftime("%Y-%m-%d %H:%M:%S", time.localtime()) + ']' + logvar + '\n' +#Module Which Be Used To Synchronize Single File. +def synchronize(url, filepath): + global Log + global UserAgent + log('[INFO]:The ' + SystemName + ' is synchronizing the file ' + SavePath + filepath + '.') + try: + synchronize=requests.get(url, headers=UserAgent)#Without Proxies + with open(SavePath + filepath,"wb") as code: + code.write(synchronize.content) + except: + log('[ERROR]:There has a error in task of synchronizing the file ' + SavePath + filepath + '.') + else: + log('[INFO]:The file ' + SavePath + filepath + ' has been synchronized successfully.') +#Module Which Be Used To Determine Whether The Dir Exists. +def make_sure_dir_exists(dirpath): + global Log + if os.path.exists(SavePath + dirpath): + log('[INFO]:The dir ' + SavePath + dirpath + ' has already existed.Nothing to do.') + else: + log('[INFO]:The dir ' + SavePath + dirpath + ' does not exist.The ' + SystemName + ' will create one.') + os.makedirs(SavePath + dirpath) +log('[INFO]:Loading all kinds of modules successfully.') + +#------------------------------------------------------------------------# +Log=Log + '------------------------------------------------------------------------' + '\n' + +#Save JSON In Global Variables + +log('[INFO]:Starting to get the json of MC versions list.') +Log=Log + '[' + time.strftime("%Y-%m-%d %H:%M:%S", time.localtime()) + ']' + '[INFO]:Starting to get the json of MC versions list.' + '\n' +#Save MC Versions List Json In Global Variables +mcversionsjson=requests.get(url='http://launchermeta.mojang.com/mc/game/version_manifest.json') +log('[INFO]:Get json of MC versions successfully.') +Log=Log + '[' + time.strftime("%Y-%m-%d %H:%M:%S", time.localtime()) + ']' + '[INFO]:Get json of MC versions successfully.' + '\n' + +#------------------------------------------------------------------------# +Log=Log + '------------------------------------------------------------------------' + '\n' + +log('[INFO]:Starting to count how many MC versions in total.') +#Count How Many MC Versions in total. +mcversionsjsontext=mcversionsjson.text +mcversionsnumber=mcversionsjsontext.count('"url":') +log('[INFO]:There has ' + str(mcversionsnumber) + ' MC versions in total .') +log('[INFO]:Counting how many MC versions in total successfully.') + +#Auto Synchronize Files And Dirs on https://libraries.minecraft.net/. +log('[INFO]:Starting to synchronize files and dirs on https://libraries.minecraft.net/.') +#Part Of 'downloads'. +whiletimes=0#Set Var whiletimes To Avoid Error. +while(whiletimes < mcversionsnumber): + #Count While Times. + whiletimes=whiletimes + 1 + #Read Json Of MC Versions List. + downloadurlload=json.loads(mcversionsjsontext) + whiletimesload=whiletimes - 1 + onlineurl=downloadurlload['versions'][whiletimesload]['url'] + onlineurlwithouthttps=onlineurl.replace('https://', 'http://')#Avoid Https Connetion Errors + log('[INFO]:Starting to get the json of MC libraries ' + onlineurl +' list.') + #Save MC Libraries Json In Global Variables + try:#Avoid Http/Https Connection Errors Making Whole Synchronize Stop. + mclibrariesjson=requests.get(url=onlineurlwithouthttps) + except: + log('[ERROR]:There has a error in task of getting json of MC libraries ' + onlineurl + '.') + else: + log('[INFO]:Get json of MC libraries ' + onlineurl + ' successfully.') + #Read Json Of MC Libraries. + mclibrariesload=json.loads(mclibrariesjson.text) + #Synchronize Files In "downloads". + log('[INFO]:Starting to synchronize files in ”downloads".') + try:#Avoid Http/Https Connection Errors Or Synchronize Module Download Failed Errors Making Whole Synchronize Stop. + onlineurl2=mclibrariesload['downloads']['client']['url'] + fileurl2='mojang/launcher/' + onlineurl2.replace('https://launcher.mojang.com/','') + filetosync2=fileurl2[::-1].split('/', 1)[-1][::-1] + make_sure_dir_exists(filetosync2) + synchronize(onlineurl2, fileurl2) + onlineurl2=mclibrariesload['downloads']['client_mappings']['url'] + fileurl2='mojang/launcher/' + onlineurl2.replace('https://launcher.mojang.com/','') + filetosync2=fileurl2[::-1].split('/', 1)[-1][::-1] + make_sure_dir_exists(filetosync2) + synchronize(onlineurl2, fileurl2) + onlineurl2=mclibrariesload['downloads']['server']['url'] + fileurl2='mojang/launcher/' + onlineurl2.replace('https://launcher.mojang.com/','') + filetosync2=fileurl2[::-1].split('/', 1)[-1][::-1] + make_sure_dir_exists(filetosync2) + synchronize(onlineurl2, fileurl2) + onlineurl2=mclibrariesload['downloads']['server_mappings']['url'] + fileurl2='mojang/launcher/' + onlineurl2.replace('https://launcher.mojang.com/','') + filetosync2=fileurl2[::-1].split('/', 1)[-1][::-1] + make_sure_dir_exists(filetosync2) + synchronize(onlineurl2, fileurl2) + #Synchronize Files In "loggin". + onlineurl2=mclibrariesload['loggin']['client']['file']['url'] + fileurl2='mojang/launcher/' + onlineurl2.replace('https://launcher.mojang.com/','') + filetosync2=fileurl2[::-1].split('/', 1)[-1][::-1] + make_sure_dir_exists(filetosync2) + synchronize(onlineurl2, fileurl2) + except: + log('[ERROR]:There has a error in task of synchronizing files in "downloads".') + else: + log('[INFO]:Synchronizing files in "downloads" successfully.') + log('[INFO]:Starting to count how many MC libraries files in ' + onlineurl + ' in total.') + #Count How Many MC Libraries Files in total. + mclibrariesjsontext=mclibrariesjson.text + mclibrariesnumber=mclibrariesjsontext.count('"url":') - 6 + log('[INFO]:There has ' + str(mclibrariesnumber) + ' MC libraries files in ' + onlineurl + ' in total.') + log('[INFO]:Counting how many MC libraries files in ' + onlineurl + ' in total successfully.') + whiletimes3=0#Set Var whiletimes To Avoid Error. + while(whiletimes3 < mclibrariesnumber): + #Count While Times. + whiletimes3=whiletimes3 + 1 + whiletimesload3=whiletimes3 - 1 + #Synchronize Files In "libraries". + log('[INFO]:Starting to synchronize Files In "libraries".') + try:#Avoid Http/Https Connection Errors Or Synchronize Module Download Failed Errors Making Whole Synchronize Stop. + #Synchronize Files In "libraries/.../downloads/artifact". + onlineurl3=mclibrariesload['libraries'][whiletimesload3]['downloads']['artifact']['url'] + onlineurlwithouthttps3=onlineurl3.replace('https://', 'http://') + fileurl3='mojang/libraries/' + onlineurl3.replace('https://libraries.minecraft.net/','') + filetosync3=fileurl3[::-1].split('/', 1)[-1][::-1] + make_sure_dir_exists(filetosync3) + synchronize(onlineurlwithouthttps3, fileurl3) + #Synchronize Files In "libraries/.../downloads/classifiers/javadoc". + onlineurl3=mclibrariesload['libraries'][whiletimesload3]['downloads']['classifiers']['javadoc']['url'] + onlineurlwithouthttps3=onlineurl3.replace('https://', 'http://') + fileurl3='mojang/libraries/' + onlineurl3.replace('https://libraries.minecraft.net/','') + filetosync3=fileurl3[::-1].split('/', 1)[-1][::-1] + make_sure_dir_exists(filetosync3) + synchronize(onlineurlwithouthttps3, fileurl3) + #Synchronize Files In "libraries/.../downloads/classifiers/natives-linux". + onlineurl3=mclibrariesload['libraries'][whiletimesload3]['downloads']['classifiers']['natives-linux']['url'] + onlineurlwithouthttps3=onlineurl3.replace('https://', 'http://') + fileurl3='mojang/libraries/' + onlineurl3.replace('https://libraries.minecraft.net/','') + filetosync3=fileurl3[::-1].split('/', 1)[-1][::-1] + make_sure_dir_exists(filetosync3) + synchronize(onlineurlwithouthttps3, fileurl3) + #Synchronize Files In "libraries/.../downloads/classifiers/natives-macos". + onlineurl3=mclibrariesload['libraries'][whiletimesload3]['downloads']['classifiers']['natives-macos']['url'] + onlineurlwithouthttps3=onlineurl3.replace('https://', 'http://') + fileurl3='mojang/libraries/' + onlineurl3.replace('https://libraries.minecraft.net/','') + filetosync3=fileurl3[::-1].split('/', 1)[-1][::-1] + make_sure_dir_exists(filetosync3) + synchronize(onlineurlwithouthttps3, fileurl3) + #Synchronize Files In "libraries/.../downloads/classifiers/natives-windows". + onlineurl3=mclibrariesload['libraries'][whiletimesload3]['downloads']['classifiers']['natives-windows']['url'] + onlineurlwithouthttps3=onlineurl3.replace('https://', 'http://') + fileurl3='mojang/libraries/' + onlineurl3.replace('https://libraries.minecraft.net/','') + filetosync3=fileurl3[::-1].split('/', 1)[-1][::-1] + make_sure_dir_exists(filetosync3) + synchronize(onlineurlwithouthttps3, fileurl3) + #Synchronize Files In "libraries/.../downloads/artifact/classifiers/sources". + onlineurl3=mclibrariesload['libraries'][whiletimesload3]['downloads']['classifiers']['sources']['url'] + onlineurlwithouthttps3=onlineurl3.replace('https://', 'http://') + fileurl3='mojang/libraries/' + onlineurl3.replace('https://libraries.minecraft.net/','') + filetosync3=fileurl3[::-1].split('/', 1)[-1][::-1] + make_sure_dir_exists(filetosync3) + synchronize(onlineurlwithouthttps3, fileurl3) + except: + log('[ERROR]:There has a error in task of synchronizing files in ”libraries".') + else: + log('[INFO]:Synchronizing files in "libraries" successfully.') + +log('[INFO]:Synchronizing files and dirs on https://libraries.minecraft.net/ successfully.') + +#------------------------------------------------------------------------# +Log=Log + '------------------------------------------------------------------------' + '\n' + +#Starting To Save Logs. +log('[INFO]:Starting to save logs.') +logwrite=open(os.path.dirname(os.path.abspath(sys.argv[0])) + config['logspath'] + 'part1-' + str(time.strftime("%Y-%m-%d-%H-%M-%S", time.localtime()) + '.txt'),mode='w') +logwrite.write(Log + '[' + time.strftime("%Y-%m-%d %H:%M:%S", time.localtime()) + ']' + '[INFO]:Save logs successfully.' + '\n' + '[' + time.strftime("%Y-%m-%d %H:%M:%S", time.localtime()) + ']' + '[INFO]:All tasks of synchronizing have done successfully.') +logwrite.close()