Allow disabling short URLs with noshorturls.txt file

This commit is contained in:
Jay Lee
2020-05-13 13:00:51 -04:00
parent 1eb7ce3896
commit 32c02c36c9
3 changed files with 9 additions and 0 deletions

View File

@ -521,6 +521,7 @@ def SetGlobalVariables():
'allcache.txt',
filePresentValue=False,
fileAbsentValue=True)
_getOldSignalFile(GC_NO_SHORT_URLS, 'noshorturls.txt')
_getOldSignalFile(GC_NO_UPDATE_CHECK, 'noupdatecheck.txt')
# Assign directories first
for itemName in GC_VAR_INFO:

View File

@ -320,6 +320,8 @@ URL_SHORTENER_ENDPOINT = 'https://gam-shortn.appspot.com/create'
def shorten_url(long_url, httpc=None):
if GC_Defaults[GC_NO_SHORT_URLS]:
return long_url
if not httpc:
httpc = transport.create_http(timeout=10)
headers = {'Content-Type': 'application/json', 'User-Agent': GAM_INFO}

View File

@ -1140,6 +1140,8 @@ GC_NO_BROWSER = 'no_browser'
GC_OAUTH_BROWSER = 'oauth_browser'
# Disable GAM API caching
GC_NO_CACHE = 'no_cache'
# Disable Short URLs
GC_NO_SHORT_URLS = 'no_short_urls'
# Disable GAM update check
GC_NO_UPDATE_CHECK = 'no_update_check'
# Number of threads for gam batch
@ -1185,6 +1187,7 @@ GC_Defaults = {
GC_DRIVE_DIR: '',
GC_NO_BROWSER: False,
GC_NO_CACHE: False,
GC_NO_SHORT_URLS: False,
GC_NO_UPDATE_CHECK: False,
GC_NUM_THREADS: 25,
GC_OAUTH_BROWSER: False,
@ -1264,6 +1267,9 @@ GC_VAR_INFO = {
GC_NO_CACHE: {
GC_VAR_TYPE: GC_TYPE_BOOLEAN
},
GC_NO_SHORT_URLS: {
GC_VAR_TYPE: GC_TYPE_BOOLEAN
},
GC_NO_UPDATE_CHECK: {
GC_VAR_TYPE: GC_TYPE_BOOLEAN
},