Changeset 16513


Ignore:
Timestamp:
Aug 9, 2016, 3:51:46 PM (3 years ago)
Author:
dferreira
Message:

Images with local url added

Location:
internals/2016/aptoideimagesdetector/trunk/aptoide_mature_app_detector/aptoide_mature_app_detector/explicit_content_detector/API
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • internals/2016/aptoideimagesdetector/trunk/aptoide_mature_app_detector/aptoide_mature_app_detector/explicit_content_detector/API/Explicit_detector/Illustration2Vector/illustration2vec_master/analyse_image.py

    r16506 r16513  
    2222
    2323def analyse_explicit(illust2vec, image_dir):
     24
     25        print image_dir
    2426
    2527        try:
  • internals/2016/aptoideimagesdetector/trunk/aptoide_mature_app_detector/aptoide_mature_app_detector/explicit_content_detector/API/views.py

    r16508 r16513  
    2525        _model = analyse_app.get_model()
    2626        _time = datetime.now()
     27
     28
     29def local_url(parent_dir, image_path):
     30        try:
     31                image_path = image_path['path']
     32        except:
     33                pass
     34        path = image_path.split("/")[-1:][0]
     35        final_path = "/"+parent_dir+"/"+path[0]+"/"+path[1]+"/"+path[2]+"/"+path[3:]
     36        return final_path
     37
    2738
    2839# Function that analyses the information of an app and returns if it is explicit or not
     
    5566        if 'sshots' in page['media']:
    5667                for s in page['media']['sshots']:
    57                         try:
    58                                 temp = s['path'].split('http://',1)
    59                         except:
    60                                 temp = s.split('http://',1)
    61                         scr.append(config['directories']['local_image_path_prefix']+temp[1])
     68                        #try:
     69                        #       temp = s['path'].split('http://',1)
     70                        #except:
     71                        #       temp = s.split('http://',1)
     72                        #scr.append(config['directories']['local_image_path_prefix']+temp[1])
     73                        print local_url(config['directories']['local_image_path_prefix'],s)
     74                        scr.append(local_url(config['directories']['local_image_path_prefix'],s))
    6275
    6376        if 'sshots_hd' in page['media']:
    6477                for s in page['media']['sshots_hd']:
    65                         try:
    66                                 temp = s['path'].split('http://',1)
    67                         except:
    68                                 temp = s.split('http://',1)
    69                         scr_hd.append(config['directories']['local_image_path_prefix']+temp[1])
     78                        #try:
     79                        #       temp = s['path'].split('http://',1)
     80                        #except:
     81                        #       temp = s.split('http://',1)
     82                        #scr_hd.append(config['directories']['local_image_path_prefix']+temp[1])
     83                        scr.append(local_url(config['directories']['local_image_path_prefix'],s))
    7084
    7185        min_age = page['meta']['min_age']
     
    109123        Model._time = now
    110124        exp = False
    111         try:
     125        #try:
    112126                # Fetching the JSON content
    113                 webpage = urllib2.urlopen(url+str(app_id)+"/json")
    114                 soup = BeautifulSoup(webpage, "lxml")
     127        webpage = urllib2.urlopen(url+str(app_id)+"/json")
     128        soup = BeautifulSoup(webpage, "lxml")
    115129                               
    116                 text = soup.get_text()
    117                 page = json.loads(text)
    118                 if page['status']!='FAIL':
     130        text = soup.get_text()
     131        page = json.loads(text)
     132        if page['status']!='FAIL':
    119133
    120                         exp = get_data(page)
     134                exp = get_data(page)
    121135
    122                 else:
    123                         status = 'Failed'
    124                         print "App does not exist"
    125                         return redirect('error')
    126         except:
     136        else:
    127137                status = 'Failed'
    128                 print "Error during parsing"
     138                print "App does not exist"
    129139                return redirect('error')
     140        #except:
     141        #       status = 'Failed'
     142        #       print "Error during parsing"
     143        #       return redirect('error')
    130144
    131145        # If it's explicit content, redirects to true page. Otherwise, redirects to false page.
Note: See TracChangeset for help on using the changeset viewer.