Changeset 16486


Ignore:
Timestamp:
Aug 5, 2016, 7:41:19 AM (3 years ago)
Author:
dferreira
Message:

Final presentation updated. URL now works with md5.

Location:
internals/2016/aptoideimagesdetector
Files:
6 edited

Legend:

Unmodified
Added
Removed
  • internals/2016/aptoideimagesdetector/trunk/aptoide_mature_app_detector/aptoide_mature_app_detector/explicit_content_detector/API/urls.py

    r16462 r16486  
    55
    66urlpatterns = [
    7     url(r'^(?P<app_id>[0-9]+)/$', views.index, name='index'),
     7    url(r'^(?P<app_md5>[0-9a-zA-Z]+)/$', views.index, name='index'),
    88    url(r'^(?P<app_id>[0-9]+)/true/$', views.true, name='true'),
    99    url(r'^(?P<app_id>[0-9]+)/false/$', views.false, name='false'),
    10     url(r'^(?P<app_id>[0-9]+)/error/$', views.error, name='error'),
     10    url(r'^error/$', views.error, name='error'),
    1111]
  • internals/2016/aptoideimagesdetector/trunk/aptoide_mature_app_detector/aptoide_mature_app_detector/explicit_content_detector/API/views.py

    r16476 r16486  
    33# Aptoide, 2016
    44
    5 # API in Django to deploy the analysis of an app, given its ID.
     5# API in Django to deploy the analysis of an app, given its MD5.
    66# Just start the server and write the following url:
    7 # http://127.0.0.1:8000/detect_mature/id_of_app
     7# http://127.0.0.1:8000/detect_mature/md5_of_app
    88
    99from django.http import HttpResponse
     
    1111from django.db.models.base import ModelBase
    1212from bs4 import BeautifulSoup
     13from datetime import datetime, time
    1314from Explicit_detector import analyse_app
    1415import threading
     
    2021class Model(ModelBase):
    2122        _model = analyse_app.get_model()
     23        _time = datetime.now()
    2224
    2325
    24 def index(request, app_id):
    25         url = "http://webservices.aptoide.com/webservices/3/getApkInfo/id:"
     26def index(request, app_md5):
     27        now = datetime.now()
     28        url = "http://webservices.aptoide.com/webservices/3/getApkInfo/md5sum:"
    2629        illust2vec = Model._model
    27 
     30        Model._time = now
    2831        try:
    2932                # Fetching the JSON content
    30                 webpage = urllib2.urlopen(url+str(app_id)+"/json")
     33                webpage = urllib2.urlopen(url+str(app_md5)+"/json")
    3134                soup = BeautifulSoup(webpage, "lxml")
    3235                               
     
    3740
    3841                        print "Fetching data..."
     42                        app_id = page['apk']['id']
    3943                        title = page['meta']['title']
    4044
     
    8589                        status = 'Failed'
    8690                        print "App does not exist"
    87                         return redirect('error', app_id=app_id)
     91                        return redirect('error')
    8892        except:
    8993                status = 'Failed'
    9094                print "Error during parsing"
    91         #response = json.dumps({'app_id': app_id, 'status': status,'is_mature_content': exp}, sort_keys=True)
    92         #return HttpResponse(response)
    9395
    9496        # If it's explicit content, redirects to true page. Otherwise, redirects to false page.
     
    98100
    99101def true(request, app_id):
    100         return HttpResponse(json.dumps({'app_id': app_id, 'status': 'OK','mature_content': 'yes'}, sort_keys=True))
     102        return HttpResponse(json.dumps({'app_id': app_id, 'status': 'OK','mature_content': 'yes', 'time':str(datetime.now()-Model._time)}, sort_keys=True))
    101103
    102104def false(request, app_id):
    103         return HttpResponse(json.dumps({'app_id': app_id, 'status': 'OK','mature_content': 'no'}, sort_keys=True))
     105        return HttpResponse(json.dumps({'app_id': app_id, 'status': 'OK','mature_content': 'no', 'time':str(datetime.now()-Model._time)}, sort_keys=True))
    104106
    105 def error(request, app_id):
    106         return HttpResponse(json.dumps({'app_id': app_id, 'status': 'Failed','mature_content': '?'}, sort_keys=True))
     107def error(request):
     108        return HttpResponse(json.dumps({'status': 'Failed', 'time':str(datetime.now()-Model._time)}, sort_keys=True))
  • internals/2016/aptoideimagesdetector/trunk/aptoide_mature_app_detector/readme.rst

    r16459 r16486  
    77---------------------------
    88
    9 Django API to analyse an aptoide app given an ID
     9Django API to analyse an aptoide app given an MD5 sum of an app
    1010and check if it has nudity content or not with 95% accuracy.
    1111
    1212---------------------------
    13 Just go to the paste aptoide_mature_app_detector/explicit_content_detector
     13Just go to the folder aptoide_mature_app_detector/explicit_content_detector
    1414and, from the command-line, run:
    1515python manage.py runserver
    1616
    17 Then, choose an app ID and go to the url 127.0.0.1:8000/detect_mature/id_of_an_app
     17Then, choose an app MD5 sum and go to the url 127.0.0.1:8000/detect_mature/md5_sum
    1818
    1919That's it!
  • internals/2016/aptoideimagesdetector/trunk/aptoide_mature_app_detector/requirements.txt

    r16465 r16486  
    77-> Numpy
    88-> Scipy
    9 -> Skimage
    109-> Pillow
    1110-> Chainer
    1211-> NLTK
     12-> MatPlotLib
    1313-> Scikit-Image
    1414-> Scikit-Learn
    1515
    16 It is also needed to downlad libraries from NLTK, apart pip install.
     16It is also needed to downlad libraries from NLTK, after pip install.
    1717Best way is run:
    1818> import nltk
    19 > nltk.download()
    20 and download all of the packages.
     19> nltk.download(‘all’)
Note: See TracChangeset for help on using the changeset viewer.