Skip to content

Commit

Permalink
gh
Browse files Browse the repository at this point in the history
  • Loading branch information
krypton-byte committed Oct 22, 2021
1 parent e877f3b commit a1f17da
Show file tree
Hide file tree
Showing 9 changed files with 59 additions and 15 deletions.
1 change: 1 addition & 0 deletions .github/workflows/python-publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,5 +27,6 @@ jobs:
TWINE_USERNAME: ${{ secrets.PYPI_USERNAME }}
TWINE_PASSWORD: ${{ secrets.PYPI_PASSWORD }}
run: |
ls tiktok_downloader/*
python setup.py build sdist
twine upload dist/*
2 changes: 2 additions & 0 deletions build/lib/tiktok_downloader/__init__.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
from .snaptik import snaptik
from .ssstik import ssstik
from .scrapper import info_post
from .tikmate import tikmate
from .mdown import mdown
17 changes: 17 additions & 0 deletions build/lib/tiktok_downloader/mdown.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
from bs4 import BeautifulSoup
import requests
from requests.models import InvalidURL
from .utils import info_videotiktok
class mdown(requests.Session):
BASE_URL='https://musicaldown.com/'
def __init__(self) -> None:
super().__init__()
self.headers={"user-agent": "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/94.0.4606.81 Safari/537.36"}
def get_media(self, url):
bs=BeautifulSoup(self.get(self.BASE_URL).text,'html.parser')
form = {i['name']:i['value'] for i in bs.find_all('input', attrs={'type':'hidden'})}
form.update({bs.find('input', attrs={'type':'text'})['name']:url})
res=self.post(f'{self.BASE_URL}download', data=form, headers={"origin": "https://musicaldown.com","referer": "https://musicaldown.com/en/","sec-ch-ua": '"Chromium";v="94", "Google Chrome";v="94", ";Not A Brand";v="99"',"sec-ch-ua-mobile": "?0","sec-ch-ua-platform": "Linux","sec-fetch-dest": "document","sec-fetch-mode": "navigate","sec-fetch-site": "same-origin","sec-fetch-user": "?1","upgrade-insecure-requests": "1","user-agent": "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/94.0.4606.81 Safari/537.36"})
if 'err' in res.url:
raise InvalidURL()
return [info_videotiktok(i['href'], self) for i in BeautifulSoup(res.text,'html.parser').find_all('a', attrs={'target':'_blank'})]
4 changes: 0 additions & 4 deletions build/lib/tiktok_downloader/scrapper.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,7 @@
from requests import Session
import requests, json
from datetime import datetime
from bs4 import BeautifulSoup
import re
from tiktok_downloader.Except import InvalidUrl
from tiktok_downloader.keeptiktok import keeptiktok
from tiktok_downloader.utils import info_videotiktok
class info_post(requests.Session):
'''
:param url: video url(tiktok)
Expand Down
17 changes: 13 additions & 4 deletions build/lib/tiktok_downloader/server.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
from tiktok_downloader.mdown import mdown
from flask import Flask, request,render_template
from . import info_post, snaptik, ssstik
from . import info_post, snaptik, ssstik, tikmate
import json, os
app = Flask(__name__, template_folder=os.path.abspath(__file__+'/../templates'), static_folder=os.path.abspath(__file__+'/../static'))
@app.route('/')
Expand Down Expand Up @@ -53,12 +54,20 @@ def snapt(path):
return json.dumps({
'msg':'url tidak valid'
})
elif path not in ['snaptik', 'ssstik']:
elif path not in ['snaptik', 'ssstik', 'tikmate','mdown']:
return json.dumps({'msg':'path tidak ditemukan'})
if request.args.get('url'):
try:
ok=snaptik(request.args['url']).get_media() if path == 'snaptik' else ssstik().get_media(request.args['url'])
return json.dumps([{'type':i.type,'url':i.json} for i in ok],indent=4)
res=[]
if path == 'snaptik':
res = snaptik(request.args['url']).get_media()
elif path =='ssstik':
res = ssstik().get_media(request.args['url'])
elif path == 'tikmate':
res = tikmate().get_media(request.args['url'])
elif path == 'mdown':
res = mdown().get_media(request.args['url'])
return json.dumps([{'type':i.type,'url':i.json} for i in res],indent=4)
except Exception as e:
print(e)
return json.dumps({
Expand Down
20 changes: 20 additions & 0 deletions build/lib/tiktok_downloader/tikmate.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
from requests.models import InvalidURL
from . import snaptik
from .utils import info_videotiktok
from ast import literal_eval
import re
import requests
class tikmate(requests.Session):
BASE_URL='https://tikmate.online/'
def __init__(self) -> None:
super().__init__()
self.headers={'User-Agent':'Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/86.0.4240.111 Safari/537.36'}
def get_media(self, url):
token = re.search('name\=\"token\".*?value\=\"(.*?)\"',self.get(self.BASE_URL).text).group(1)
media = self.post(self.BASE_URL+'abc.php', data={'url':url, 'token':token},headers={"origin": "https://tikmate.online","referer": "https://tikmate.online/","sec-ch-ua": '"Chromium";v="94", "Google Chrome";v="94", ";Not A Brand";v="99"',"sec-ch-ua-mobile": "?0","sec-ch-ua-platform": "Linux","sec-fetch-dest": "iframe","sec-fetch-mode": "navigate","sec-fetch-site": "same-origin","sec-fetch-user": "?1","upgrade-insecure-requests": "1","user-agent": "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/94.0.4606.81 Safari/537.36"})
if "'error_api_get'" in media.text:
raise InvalidURL()
tt=re.findall(r'\(\".*?,.*?,.*?,.*?,.*?.*?\)',media.text)
d=literal_eval(tt[0]).__str__()
decode = snaptik.decoder.eval(f'decoder{d}')
return [info_videotiktok(self.BASE_URL+x, self) for x in re.findall('(download.php\?token.*?)\\\\\"',decode)]
6 changes: 2 additions & 4 deletions tiktok_downloader.egg-info/PKG-INFO
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
Metadata-Version: 2.1
Metadata-Version: 1.1
Name: tiktok-downloader
Version: 0.1.6
Summary: Tiktok Downloader&Scraper using bs4&requests
Expand All @@ -7,6 +7,7 @@ Author: Krypton Byte
Author-email: [email protected]
License: MIT
Download-URL: https://codeload.github.com/krypton-byte/tiktok-downloader/tar.gz/refs/tags/0.1.6
Description: UNKNOWN
Keywords: tiktok,downloader,scrapper,tikdok-scraper,tiktok-downloader
Platform: UNKNOWN
Classifier: Development Status :: 3 - Alpha
Expand All @@ -15,6 +16,3 @@ Classifier: Topic :: Software Development :: Build Tools
Classifier: License :: OSI Approved :: MIT License
Classifier: Programming Language :: Python :: 3.8
Classifier: Programming Language :: Python :: 3.9

UNKNOWN

3 changes: 2 additions & 1 deletion tiktok_downloader.egg-info/SOURCES.txt
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,13 @@ setup.py
tiktok_downloader/Except.py
tiktok_downloader/__init__.py
tiktok_downloader/__main__.py
tiktok_downloader/keeptiktok.py
tiktok_downloader/mdown.py
tiktok_downloader/scrapper.py
tiktok_downloader/server.py
tiktok_downloader/snaptik.py
tiktok_downloader/ssstik.py
tiktok_downloader/test.py
tiktok_downloader/tikmate.py
tiktok_downloader/utils.py
tiktok_downloader.egg-info/PKG-INFO
tiktok_downloader.egg-info/SOURCES.txt
Expand Down
4 changes: 2 additions & 2 deletions tiktok_downloader.egg-info/requires.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
bs4
flask
cloudscraper
requests
flask
py-mini-racer
requests

0 comments on commit a1f17da

Please sign in to comment.