Skip to content

Commit

Permalink
add files
Browse files Browse the repository at this point in the history
  • Loading branch information
sereneblue committed Sep 2, 2017
1 parent bccad39 commit f800adf
Show file tree
Hide file tree
Showing 6 changed files with 183 additions and 0 deletions.
78 changes: 78 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
# apkdl
Search and download APKs from the command line

# Install

### Using pip

```
$ pip install apkdl
```

### Build from source

```
$ git clone https://github.com/sereneblue/apkdl
$ cd fts
$ python setup.py install
```

# Usage

```
$ apkdl firefox focus
Searching for: firefox focus
[00] Firefox Focus: The privacy browser
Developer: Mozilla
=========================================
[01] Firefox Browser fast & private
Developer: Mozilla
=========================================
[02] Dolphin Zero Incognito Browser - Private Browser
Developer: Dolphin Browser
=========================================
[03] Offline Survival Manual
Developer: ligi
=========================================
[04] DuckDuckGo Search & Stories
Developer: DuckDuckGo
=========================================
[05] ProtonMail - Encrypted Email
Developer: ProtonMail
=========================================
[06] Firefox Nightly for Developers (Unreleased)
Developer: Mozilla
=========================================
[07] AfterFocus
Developer: MotionOne
=========================================
[08] Find My Device
Developer: Google Inc.
=========================================
[09] Brave Browser: Fast AdBlocker
Developer: Brave Software
=========================================
[10] Todoist: To-Do List, Task List
Developer: Doist
=========================================
[11] Pale Moon web browser
Developer: Moonchild Productions
=========================================
[12] Firefox for Android Beta
Developer: Mozilla
=========================================
[13] Opera Free VPN - Unlimited VPN
Developer: OSL Networks
=========================================
[14] Samsung Internet Browser Beta
Developer: Samsung Electronics Co., Ltd.
=========================================
Which app would you like to download?
> 0
Downloading org.mozilla.focus.apk ...
Download completed!
```

# Credits

APKs are grabbed from https://apkpure.com.
1 change: 1 addition & 0 deletions apkdl/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
__version__ = "1.0.0"
38 changes: 38 additions & 0 deletions apkdl/__main__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
from apkdl.dl import download, search, APPS
import sys

def main():
if len(sys.argv) > 1:
query = " ".join(sys.argv[1:])

print('Searching for: {}'.format(query))

search(query)

if len(APPS) > 0:
for idx, app in enumerate(APPS):
print("""[{:02d}] {}\n Developer: {}""".format(idx, app[0], app[1]))
print('=========================================')

option = ""
while option == "":
option = input('Which app would you like to download?\n> ')
try:
if 0 <= int(option) < len(APPS):
option = int(option)
else:
print('That was not a valid option')
option = ""
except ValueError:
option = ""

print('Downloading {}.apk ...'.format(APPS[option][2].split('/')[-1]))

download(APPS[option][2])

print('Download completed!')
else:
print('No results')
else:
print('Missing input! Try:')
print('apkdl [app name]')
30 changes: 30 additions & 0 deletions apkdl/dl.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
from bs4 import BeautifulSoup
from urllib.parse import quote_plus
import requests

APPS = []

def download(link):
res = requests.get(link + '/download?from=details', headers={
'User-Agent':'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_11_6) AppleWebKit/601.7.5 (KHTML, like Gecko) Version/9.1.2 Safari/601.7.5'
}).text
soup = BeautifulSoup(res, "html.parser").find('a', {'id':'download_link'})
if soup['href']:
r = requests.get(soup['href'], stream=True, headers={
'User-Agent':'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_11_6) AppleWebKit/601.7.5 (KHTML, like Gecko) Version/9.1.2 Safari/601.7.5'
})
with open(link.split('/')[-1] + '.apk', 'wb') as file:
for chunk in r.iter_content(chunk_size=1024):
if chunk:
file.write(chunk)

def search(query):
res = requests.get('https://apkpure.com/search?q={}&region='.format(quote_plus(query)), headers={
'User-Agent':'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_11_6) AppleWebKit/601.7.5 (KHTML, like Gecko) Version/9.1.2 Safari/601.7.5'
}).text
soup = BeautifulSoup(res, "html.parser")
for i in soup.find('div', {'id':'search-res'}).findAll('dl', {'class':'search-dl'}):
app = i.find('p', {'class':'search-title'}).find('a')
APPS.append((app.text,
i.findAll('p')[1].find('a').text,
'https://apkpure.com' + app['href']))
2 changes: 2 additions & 0 deletions setup.cfg
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
[metadata]
description-file = README.md
34 changes: 34 additions & 0 deletions setup.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
from setuptools import setup, find_packages
from apkdl import __version__
import os

setup(
name ='apkdl',
version = __version__,
description = 'Search and download APKs from the command line',
url = 'https://github.com/sereneblue/apkdl',
author = 'sereneblue',
license = "MIT",
packages = find_packages(),
classifiers = [
'Intended Audience :: Developers',
'Environment :: Console',
'Topic :: Utilities',
'License :: OSI Approved :: MIT License',
'Natural Language :: English',
'Operating System :: OS Independent',
'Programming Language :: Python :: 3',
'Programming Language :: Python :: 3.2',
'Programming Language :: Python :: 3.3',
'Programming Language :: Python :: 3.4',
'Programming Language :: Python :: 3.5',
'Programming Language :: Python :: 3.6',
],
keywords = ['android', 'apk', 'cli'],
install_requires = ['requests', 'beautifulsoup4'],
entry_points = {
'console_scripts':[
'apkdl=apkdl.__main__:main'
],
}
)

0 comments on commit f800adf

Please sign in to comment.