1. Announcing Mekorama on the Web!

    Now anyone can play levels from the forum online, with one click!

    Dismiss Notice
  2. Psst! If you're new here, welcome! Please visit these pages first for information about the forum and Mekorama:

    Welcome! ¡Bienvenido! Selamat datang! Добро пожаловать! Willkommen!
    and
    Everything you want to know about Mekorama

    Dismiss Notice

Help - Forum Sort levels by views AND date ?

Discussion in 'General (Issues, Help, Discussions)' started by vince, Aug 31, 2016.

  1. vince

    vince Famous Member

    Messages:
    67
    Levels:
    44
    Albums:
    1
    Likes Received:
    957
    Joined:
    Jun 27, 2016
    Hello,
    Is it possible to see the most viewed (or most rated) levels in the last day, week or month ? And not since the creation of the forum... It is getting really messy with dozens of upload each day.
    Thanks
     
    Last edited: Sep 1, 2016
  2. vince

    vince Famous Member

    Messages:
    67
    Levels:
    44
    Albums:
    1
    Likes Received:
    957
    Joined:
    Jun 27, 2016
    Ok it seems impossible so I did it myself. Here are the results ! For the rating, I took into account the total number of stars, not the average rating.

    20 best rated levels last month
    53 right-moment meko
    50 castle-jump richardfu_
    50 sneak-in-v richardfu_
    47 hercules richardfu_
    45 remote-control-ii richardfu_
    45 mini-mini-maze meko
    45 the-drawer richardfu_
    44 yellow-land meko
    40 expedition-ii richardfu_
    40 align KPACABA
    40 the-mill richardfu_
    40 dam-building richardfu_
    40 sneak-in-ii richardfu_
    40 witchs-house retrograde
    39 sneak-in-iii richardfu_
    36 electric-chair Jomer
    35 square-one vince
    35 tower-crossing-ii richardfu_
    35 build-up richardfu_
    35 rebels-v2 vince

    20 most viewed level last month
    1K yellow-land meko
    594 have-a-ball vince
    556 sneak-in-v richardfu_
    549 design_challenge1 Aleric
    532 mini-pagoda meko
    520 the-cliffs Mark69
    459 sneak-in-iii richardfu_
    449 the-mountain meko
    432 walk-around meko
    416 catch-the-spy TR O
    411 tutorial-1 trids
    410 design_challenge_2 Aleric
    408 small-city meko
    373 right-moment meko
    367 under-control vince
    362 zen-temple meko
    359 the-mistery meko
    352 ezpz1 trids
    345 the-farm meko
    339 shortcuts meko

    20 best rated level last week
    45 remote-control-ii richardfu_
    45 mini-mini-maze meko
    40 expedition-ii richardfu_
    40 align KPACABA
    35 square-one vince
    35 tower-crossing-ii richardfu_
    33 aztec-island B Hill
    32 escape-game Gepeto
    30 bug-report-passing-through meko
    30 upside-down cpw
    25 bunker AndroidHackPro
    25 rescue-fixed TR O
    25 expedition richardfu_
    20 quantum-bridge retrograde
    19 fairground Gepeto
    16 reinicio AndroidHackPro
    16 good-pivot meko
    15 cloudy-day Gepeto
    15 trapped meko
    15 rest-request Gepeto

    20 most viewed level last week
    338 pool-party richardfu_
    322 mini-mini-maze meko
    321 manor-secret retrograde
    314 expedition richardfu_
    234 bug-report-passing-through meko
    234 trapped meko
    230 patience Scare Crow
    217 square-one vince
    214 escape-game Gepeto
    208 mekorama-jump-over-a-bug zolv
    202 expedition-ii richardfu_
    202 align KPACABA
    198 fairground Gepeto
    193 tower-crossing-ii richardfu_
    176 remote-control-ii richardfu_
    170 slink meko
    167 rescue-fixed TR O
    155 rest-request Gepeto
    145 aztec-island B Hill
    145 good-pivot meko
     
    Last edited: Sep 2, 2016
    meko, Gepeto and nGord like this.
  3. Gepeto

    Gepeto MekoStudio Architect Staff Member

    Messages:
    453
    Levels:
    48
    Albums:
    1
    Likes Received:
    2,504
    Joined:
    Jul 7, 2016
    I don't know if you did that by hands but I hope not! :eek:
    Your thread woke me up on my keyboard, so in case you (or others) are interested in, here is a Python3 code that can help in that way:
    Code:
    #!/usr/bin/python3
    # BeautifulSoup needs to be installed with "pip install BeautifulSoup4"
    # By Gepeto on 09/02/2016
    
    import urllib.request
    from bs4 import BeautifulSoup
    from datetime import datetime
    
    order = {
        'most commented':'comment_count',
        'most viewed':'view_count',
        'highest rated':'rating_avg',
        'most rated':'rating_count',
        'most liked':'likes'
        }
    ordering=order['most viewed'] # Changing the order amongst the dict above
    
    pages = range(1,300)
    results_number = 20
    from_date = datetime.strptime('08/01/2016', '%m/%d/%Y') # start Month/Day/Year
    levels = []
    
    print('Order:', ordering)
    for page in pages:
        with urllib.request.urlopen('http://mekoramaforum.com/media/?order='+ordering+'&page='+str(page)) as response:
            html = response.read()
            soup = BeautifulSoup(html, "html5lib")
    
            # print('Page', str(page))
            for media in soup.find_all('div', attrs={'class': 'mediaContainer'}):
                level = {}
    
                author = media.find('a', attrs={'class': 'username'}).text
                level['author'] = author
    
                titleSection = media.find('a', attrs={'class': 'mediaTitle'})
                level['title']= titleSection.text.strip()
                level['url'] =titleSection['href']
        
                stats = media.find_all('div', attrs={'class': 'statCol'})
                stats_data = []
                for stat in stats:
                    stats_data.append(stat.text.strip()) #.replace('K','000'))
        
                level['comments'] = stats_data[0]
                level['views'] = stats_data[1]
                level['likes'] = stats_data[2]
                level['rate'] = stats_data[3]
        
                date_str = media.find('div', attrs={'class': 'mediaLabel'}).text.strip()
                date_object = datetime.strptime(date_str, '%d %b %Y')
                level['date'] = date_object
        
                if date_object > from_date and len(levels) < results_number:
                    levels.append(level) # Just for futures uses or results filtering
                    print(str(len(levels))+'.', '"'+level['title'], '"\t', level['author'], '\tviews:', level['views'], '\trate:', level['rate'], '\tlikes:', level['likes'], '\tcomments:', level['comments'], '\tdate:', level['date'].strftime('%m/%d/%Y'))
    
            if not len(levels) < results_number:
                break
    
    Sorry, no syntax highlighting possible...
    It's not an improved script, just a simple one to get a quick result depending on filtering arguments.
     
    Last edited: Sep 2, 2016
    cpw and vince like this.
  4. vince

    vince Famous Member

    Messages:
    67
    Levels:
    44
    Albums:
    1
    Likes Received:
    957
    Joined:
    Jun 27, 2016
    For some reason I did it on mobile phone with a great app called Automate. Thanks for your code, I don't know Python but I will try to use it ! :)
     
    Gepeto likes this.
  5. Gepeto

    Gepeto MekoStudio Architect Staff Member

    Messages:
    453
    Levels:
    48
    Albums:
    1
    Likes Received:
    2,504
    Joined:
    Jul 7, 2016
    OK... Good to know about this app. I'll give it try too :)
     
    vince likes this.
  6. TR O

    TR O Well-Known Member

    Messages:
    39
    Levels:
    32
    Albums:
    18
    Likes Received:
    623
    Joined:
    Aug 2, 2016
    Wow! you guys a programer?:eek: I checked out python3 & automate, don't know how to use at alll.haha
     
    vince likes this.
  7. Gepeto

    Gepeto MekoStudio Architect Staff Member

    Messages:
    453
    Levels:
    48
    Albums:
    1
    Likes Received:
    2,504
    Joined:
    Jul 7, 2016
    @TR O Haha :) I am not able to code a game such as mekorama but scripting with Python is not a big deal. It is more or less getting the html of a web page and seeking for some patterns to print them.
    @vince I have tried Automate on Android and I am not sure that's the one you're speaking about... Nothing about parsing a web page or things like that :confused:
     
    vince likes this.
  8. vince

    vince Famous Member

    Messages:
    67
    Levels:
    44
    Albums:
    1
    Likes Received:
    957
    Joined:
    Jun 27, 2016
    I just made an http request with automate, and getting informations with split function. There is not a specialized tool to parse a web page. I know this may not be the proper way to do it but I don't know much about programming :confused:
     
    Gepeto likes this.
  9. Gepeto

    Gepeto MekoStudio Architect Staff Member

    Messages:
    453
    Levels:
    48
    Albums:
    1
    Likes Received:
    2,504
    Joined:
    Jul 7, 2016
    There's no proper way to do that. I just wanted to be be sure that you wasn't so desperate to have an answer that you did it by hands :p Otherwise I find really interesting to know more about other smart ways such like your. I'll dig on that.
     
    vince likes this.
  10. vince

    vince Famous Member

    Messages:
    67
    Levels:
    44
    Albums:
    1
    Likes Received:
    957
    Joined:
    Jun 27, 2016
    If anyone is interested, I made a app with Automate to sort levels by views or ratings, since a custom date. All you have to do is to download Automate for Android, go to "Automate community" (on the top right). Search for "Mekorama sort". Then launch the flow called "begin" (you can make a shortcut for it). It is helpful if you don't look at the forum for a few days and don't want to look back at 50 pages :) It took me some time to make it user-friendly, but it is ready now :p
     
    Last edited: Sep 6, 2016
    nGord and Gepeto like this.
  11. Gepeto

    Gepeto MekoStudio Architect Staff Member

    Messages:
    453
    Levels:
    48
    Albums:
    1
    Likes Received:
    2,504
    Joined:
    Jul 7, 2016
    @vince Thanks for sharing. That seems a really great app, as I like. I have downloaded your app but when I tried to launch it (begin mode or whatever) it asks me to get the purchase version of Automate and if I refuse, it goes back to the start menu of your app... :(

    I have updated too my Python script (so I can do it as I want with it), but your app seems to be more friendly user so it is sad that I can't use it (unless I pay...)
     
  12. vince

    vince Famous Member

    Messages:
    67
    Levels:
    44
    Albums:
    1
    Likes Received:
    957
    Joined:
    Jun 27, 2016
    @Gepeto Sorry for that! I forgot that the free version limits the size of the flow you are running... I will find a way to split it :)
     
  13. vince

    vince Famous Member

    Messages:
    67
    Levels:
    44
    Albums:
    1
    Likes Received:
    957
    Joined:
    Jun 27, 2016
    @Gepeto This should do the trick: please download Meko1, Meko2, Meko3, Meko4 and Switch from Automate Community, then launch the flow "begin" in Meko1.
     
  14. Gepeto

    Gepeto MekoStudio Architect Staff Member

    Messages:
    453
    Levels:
    48
    Albums:
    1
    Likes Received:
    2,504
    Joined:
    Jul 7, 2016
    @vince Thanks. I tried quickly but I need to take a more carafully look at Automate because it always asks me for permissions... I agree but the process fails. I met that too with a process I tried to build but thought of something weird I am missing. That's kind of a mekorama puzzle where I need to get to the win spot :)
     
  15. vince

    vince Famous Member

    Messages:
    67
    Levels:
    44
    Albums:
    1
    Likes Received:
    957
    Joined:
    Jun 27, 2016
    @Gepeto Thanks for trying! By the way, the flow Meko1 was bugged, please download it again :confused:. I don't know why the installation of permission fails, maybe you have to instal it directly from Google play (search for Automate permissions)
     
  16. Gepeto

    Gepeto MekoStudio Architect Staff Member

    Messages:
    453
    Levels:
    48
    Albums:
    1
    Likes Received:
    2,504
    Joined:
    Jul 7, 2016
    Hi @vince!
    As you may noticed I have first made an update of the stats for september here. Finally I have moved them to a new thread for a better organisation.
    You are the one that started that! :D Thanks!
     
  17. B Hill

    B Hill Active Member

    Messages:
    63
    Levels:
    24
    Albums:
    3
    Likes Received:
    251
    Joined:
    Jul 28, 2016
    This would be nice to have every month! A roundup of the last month's activities. And new members could look back and find the best levels easily.
     
  18. vince

    vince Famous Member

    Messages:
    67
    Levels:
    44
    Albums:
    1
    Likes Received:
    957
    Joined:
    Jun 27, 2016
    You're welcome :) Thanks for your update. I thought about doing it a few days ago but I was waiting for someone to ask for it :p
     
  19. Gepeto

    Gepeto MekoStudio Architect Staff Member

    Messages:
    453
    Levels:
    48
    Albums:
    1
    Likes Received:
    2,504
    Joined:
    Jul 7, 2016
    @B Hill - I plan to do that every month (I need to add a reminder on my phone... :))

    @vince - I hesitated first as it is your idea but, as everything is automated on my code to output with BBCode... :rolleyes: I did it to me first, than I thought: "what a selfish guy I am! :mad:" :D. I gave up with the Automate app :( But coding it was fine to me.
     
    vince likes this.
  20. B Hill

    B Hill Active Member

    Messages:
    63
    Levels:
    24
    Albums:
    3
    Likes Received:
    251
    Joined:
    Jul 28, 2016
    @Gepeto I have not used Python before but see what you are doing, basically parsing up to 300 pages of html results. Nice work. It looks like you could also add a to_date qualifier to search a date range, such as one month and do that for each month going back to the beginning.
     

Share This Page