Author Topic: [python]Download Porn Script  (Read 2158 times)

0 Members and 1 Guest are viewing this topic.

Offline techb

  • Soy Sauce Feeler
  • Global Moderator
  • King
  • *
  • Posts: 2350
  • Cookies: 345
  • Aliens do in fact wear hats.
    • View Profile
    • github
[python]Download Porn Script
« on: May 27, 2015, 12:56:38 pm »
I mostly view porn on my mobile and would like to download videos I like for offline viewing. So I wrote a script for SL4A to grab videos from one of my favorite sites, xhamster.com without having to be a member of the site.

This could be adapted to be used on other sites though, if they provide a location to the video somewhere in the source of the page. You would need to fiddle around with the regex, but completely doable. You could also make it work for regular computers by removing the android stuff.

Furthermore, this can be an example on how to save stream or binary data from the web using python and some examples on using the limited UI sl4a has.

Code: (python) [Select]
# getvid.py: Used to download porn vids
#   from xhamster.com without being a member.
# Made for Android's SL4A, root is not required.
# Writen by: techb
# Date: May 25 2015
# License: None, script is public domain,  but at
#   least credit me if you share this.
# This script is presented 'as is' and the author
#   is not responsible for misuse or errors you may get.

import android
import urllib2
import re
import sys
import os

droid = android.Android()

def findInPage(page):
  for line in page:
    if '.mp4' in line and 'file=' in line:
      found = re.search('file=".*"',line)
      if found:
        url = found.group()[6:-1]
        name = re.search(r'\w+\.mp4', url).group()
        return (name, url)
      else:
        droid.makeToast('Video not found in page.\nExiting.')
        sys.exit()

def getPage():
  site = droid.dialogGetInput('', 'Webpage:', None).result
  resp = urllib2.urlopen(site)
  page = resp.readlines()
  resp.close()
  return page

def saveVid(file_name, url):
  BUFF_SIZE = 1024*14 #play with this number to help download speeds
  progress = 0
  p = urllib2.urlopen(url)
  size = p.headers["Content-Length"]
  droid.dialogCreateHorizontalProgress("Downloading", "Progress", int(size))
  droid.dialogShow()
  # os.chdir("/choose/another/dir/if/you/want")
  with open(file_name, "wb") as f:
    while True:
      buff = p.read(BUFF_SIZE)
      if not buff:
        break
      progress += len(buff)
      droid.dialogSetCurrentProgress(progress)
      f.write(buff)
  f.close()
  droid.dialogDismiss()
  droid.makeToast("%s saved to %s" % (file_name, os.getcwd()))

if __name__ == '__main__':
  page = getPage()
  video = findInPage(page)
  saveVid(video[0], video[1])
  droid.notify(video[0], 'Download complete')
>>>import this
-----------------------------

Offline gray-fox

  • Knight
  • **
  • Posts: 208
  • Cookies: 52
    • View Profile
Re: [python]Download Porn Script
« Reply #1 on: May 27, 2015, 04:01:48 pm »
Sorry for going kind of off topic here, but which android version are you using(kitkat?). I just wonder it because I flashed new lollipop based rom to my nexus5 while back and wasn't able to make sl4a+python to work. So couldn't use any apps/scripts I had made. I had basically same issues that people in here --> https://groups.google.com/forum/m/#!topic/android-scripting/pe_4hxIgO1k
(Also had some issues with .sh scripts...that PIE thing..)

Didn't had time to wrestle with issue then and I have used chrooted enviroment since to run python scripts and stuff but can't use sl4a api with it, so it's not obviously so useful.

So if you are using some lollipop rom did you have to do something to make sl4a+python to work?

But cool script anyways.:D +1

Offline proxx

  • Avatarception
  • Global Moderator
  • Titan
  • *
  • Posts: 2803
  • Cookies: 256
  • ФФФ
    • View Profile
Re: [python]Download Porn Script
« Reply #2 on: May 27, 2015, 04:18:12 pm »
Finally a useful tool , I mean pron , yes pron.
lel coolstuff.

How do you use python on your mobile irl ? (actually using it)
Wtf where you thinking with that signature? - Phage.
This was another little experiment *evillaughter - Proxx.
Evilception... - Phage

Offline Sherlock Holmes

  • Peasant
  • *
  • Posts: 97
  • Cookies: 4
    • View Profile
Re: [python]Download Porn Script
« Reply #3 on: May 27, 2015, 05:10:12 pm »



How do you use python on your mobile irl ? (actually using it)


By installing sl4a on android device

"Scripting Layer for Android (SL4A) brings scripting languages to Android by allowing you
to edit and execute scripts and interactive interpreters directly on the Android device. Python, Perl,
JRuby, Lua, BeanShell, JavaScript, Tcl, and shell are currently supported."

I haven't used it myself but looked into it after tech b mentioned about it the other day.


And nice script.! I still need to learn python to understand it though :D

Offline proxx

  • Avatarception
  • Global Moderator
  • Titan
  • *
  • Posts: 2803
  • Cookies: 256
  • ФФФ
    • View Profile
Re: [python]Download Porn Script
« Reply #4 on: May 27, 2015, 05:19:41 pm »


By installing sl4a on android device

"Scripting Layer for Android (SL4A) brings scripting languages to Android by allowing you
to edit and execute scripts and interactive interpreters directly on the Android device. Python, Perl,
JRuby, Lua, BeanShell, JavaScript, Tcl, and shell are currently supported."

I haven't used it myself but looked into it after tech b mentioned about it the other day.


And nice script.! I still need to learn python to understand it though :D

I must live under a rock , pretty cool stuff.
Also the script is very easy to read.
Wtf where you thinking with that signature? - Phage.
This was another little experiment *evillaughter - Proxx.
Evilception... - Phage

Offline v32itas

  • Peasant
  • *
  • Posts: 123
  • Cookies: -4
  • coup de grâce
    • View Profile
Re: [python]Download Porn Script
« Reply #5 on: May 27, 2015, 07:14:20 pm »
+1 for this love spreading
"There is nothing more deceptive then an obvious fact." - SH

“There was no such thing as a fair fight. All vulnerabilities must be exploited.”
― Cary Caffrey





Offline kenjoe41

  • Symphorophiliac Programmer
  • Administrator
  • Baron
  • *
  • Posts: 990
  • Cookies: 224
    • View Profile
Re: [python]Download Porn Script
« Reply #6 on: May 27, 2015, 09:07:41 pm »
I can see scripting on Android is quite easy, nice script. Might need to extend it to provide a URL or something to specify which video to download or which genre to pull from.
I might need to learn some android scripting but time doesn't allow me.
If you can't explain it to a 6 year old, you don't understand it yourself.
http://upload.alpha.evilzone.org/index.php?page=img&img=GwkGGneGR7Pl222zVGmNTjerkhkYNGtBuiYXkpyNv4ScOAWQu0-Y8[<NgGw/hsq]>EvbQrOrousk[/img]