mirror of
				https://github.com/ProjectSynthoria/SynthoriaArchive.git
				synced 2025-11-04 01:45:46 +02:00 
			
		
		
		
	Merge pull request #132 from kyamiko/master
Fixed possible crash in api_handler.py
This commit is contained in:
		
						commit
						1354a10577
					
				
					 2 changed files with 8 additions and 3 deletions
				
			
		| 
						 | 
					@ -59,6 +59,8 @@ def validate_user(upload_request):
 | 
				
			||||||
                return False, None, None
 | 
					                return False, None, None
 | 
				
			||||||
 | 
					
 | 
				
			||||||
            return True, user, None
 | 
					            return True, user, None
 | 
				
			||||||
 | 
					        else:
 | 
				
			||||||
 | 
					            return False, None, None
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    except Exception as e:
 | 
					    except Exception as e:
 | 
				
			||||||
        return False, None, e
 | 
					        return False, None, e
 | 
				
			||||||
| 
						 | 
					@ -99,7 +101,7 @@ def api_upload(upload_request, user):
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        # print(repr(torrent_file))
 | 
					        # print(repr(torrent_file))
 | 
				
			||||||
    except Exception as e:
 | 
					    except Exception as e:
 | 
				
			||||||
        pass
 | 
					        return flask.make_response(flask.jsonify({'Failure': ['No torrent file was attached.']}), 400)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    form = forms.UploadForm(CombinedMultiDict((torrent_file, form_info)))
 | 
					    form = forms.UploadForm(CombinedMultiDict((torrent_file, form_info)))
 | 
				
			||||||
    form.category.choices = _create_upload_category_choices()
 | 
					    form.category.choices = _create_upload_category_choices()
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -1,6 +1,9 @@
 | 
				
			||||||
# Uploads a single torrent file
 | 
					# Uploads a single torrent file
 | 
				
			||||||
# Works on nyaa.si and sukebei.nyaa.si
 | 
					# Works on nyaa.si and sukebei.nyaa.si
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					# Consider using api_uploader_v2.py instead
 | 
				
			||||||
 | 
					# It has a nice command line interface
 | 
				
			||||||
 | 
					
 | 
				
			||||||
import json
 | 
					import json
 | 
				
			||||||
import requests
 | 
					import requests
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					@ -86,7 +89,7 @@ is_complete  : False
 | 
				
			||||||
 | 
					
 | 
				
			||||||
# ######################################## CHANGE HERE ########################################
 | 
					# ######################################## CHANGE HERE ########################################
 | 
				
			||||||
 | 
					
 | 
				
			||||||
url = 'https://nyaa.si/api/upload'  # or https://sukebei.nyaa.si/api/upload or http://127.0.0.1:5500/api/upload
 | 
					url = 'https://nyaa.si/api/upload'  # or 'https://sukebei.nyaa.si/api/upload' or 'http://127.0.0.1:5500/api/upload'
 | 
				
			||||||
 | 
					
 | 
				
			||||||
# Required
 | 
					# Required
 | 
				
			||||||
username = ''
 | 
					username = ''
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
	Add table
		
		Reference in a new issue