Sfoglia il codice sorgente

login is now functional

master
sharky555 4 anni fa
parent
commit
2fa0c3c8d9
1 ha cambiato i file con 26 aggiunte e 28 eliminazioni
  1. +26
    -28
      autoupload.py

+ 26
- 28
autoupload.py Vedi File

@@ -20,17 +20,16 @@ from tqdm import tqdm
from langdetect import detect

# JPS-AU files
import jpspy
import smpy

def asciiart ():
print("""
██╗██████╗ ███████╗ █████╗ ██╗ ██╗
██║██╔══██╗██╔════╝ ██╔══██╗██║ ██║
██║██████╔╝███████╗█████╗███████║██║ ██║
██ ██║██╔═══╝ ╚════██║╚════╝██╔══██║██║ ██║
╚█████╔╝██║ ███████║ ██║ ██║╚██████╔╝
╚════╝ ╚═╝ ╚══════╝ ╚═╝ ╚═╝ ╚═════╝

███████╗███╗ ███╗ █████╗ ██╗ ██╗
██╔════╝████╗ ████║ ██╔══██╗██║ ██║
███████╗██╔████╔██║█████╗███████║██║ ██║
╚════██║██║╚██╔╝██║╚════╝██╔══██║██║ ██║
███████║██║ ╚═╝ ██║ ██║ ██║╚██████╔╝
╚══════╝╚═╝ ╚═╝ ╚═╝ ╚═╝ ╚═════╝
""")

# Get arguments using argparse
@@ -46,20 +45,19 @@ def getargs():

# Acquire the authkey used for torrent files from upload.php
def getauthkey():
# uploadpage = j.retrieveContent("https://sugoimusic.me/upload.php")
# soup = BeautifulSoup(uploadpage.text, 'html5lib')
# rel2 = str(soup.select('#wrapper #content .thin'))
# # Regex returns multiple matches, could be optimized.
# authkey = re.findall("(?<=value=\")(.*)(?=\")", rel2)[0]

# return authkey
smpage = sm.retrieveContent("https://sugoimusic.me/torrents.php?id=118") # Arbitrary page on JPS that has authkey
"""
Get SM session authkey for use by uploadtorrent() data dict.
Uses SM login data

:return: authkey
"""
smpage = sm.retrieveContent("https://sugoimusic.me/torrents.php?id=118") # Arbitrary page on JPS that has authkey
soup = BeautifulSoup(smpage.text, 'html5lib')
rel2 = str(soup.select('#content .thin .main_column .torrent_table tbody'))
authkey = re.findall('authkey=(.*)&amp;torrent_pass=', rel2)
return authkey
def copytree(src, dst, symlinks=False, ignore=None):
for item in os.listdir(src):
s = os.path.join(src, item)
@@ -75,13 +73,13 @@ def createtorrent(authkey, directory, filename, releasedata):
trackers=[authkey]) # Torf requires we store authkeys in a list object. This makes it easier to add multiple announce urls.
# Set torrent to private as standard practice for private trackers
t.private = True
t.source = "SugoiMusic"
t.source = "SugoiMusic"
t.generate()
## Format releasedata to bring a suitable torrent name.
# The reason we don't just use the directory name is because of an error in POSTING.
# POSTS do not seem to POST hangul/jp characters alongside files.
filename = f"{releasedata['artist']} - {releasedata['title']} [{releasedata['media']}-{releasedata['format']}].torrent"
#filename = filename.replace("\\","")
#filename = filename.replace("\\","")
try:
t.write(filename)
print("_" * 100)
@@ -548,7 +546,7 @@ def detectlanguage(string):

def uploadtorrent(torrent, cover, releasedata):

languages = ('Japanese', 'English', 'Korean', 'Chinese', 'Vietnamese')
languages = ('Japanese', 'English', 'Korean', 'Chinese', 'Vietnamese')
# POST url.
uploadurl = "https://sugoimusic.me/upload.php"

@@ -572,7 +570,7 @@ def uploadtorrent(torrent, cover, releasedata):

# If dryrun argument has not ben passed we will POST the results to JPopSuki.
if dryrun != True:
JPSres = j.retrieveContent(uploadurl, "post", data, postDataFiles)
JPSres = sm.retrieveContent(uploadurl, "post", data, postDataFiles)
print('\nUpload POSTED')

## TODO Filter through JPSres.text and create error handling based on responses
@@ -664,12 +662,12 @@ if __name__ == "__main__":
with open(f'json_data/config.json') as f:
cfg = json.load(f)
loginData = {'username': cfg['credentials']['username'], 'password': cfg['credentials']['password']}
loginUrl = "https://jpopsuki.eu/login.php"
loginTestUrl = "https://jpopsuki.eu"
successStr = "Latest 5 Torrents"
loginUrl = "https://sugoimusic.me/login.php"
loginTestUrl = "https://sugoimusic.me"
successStr = "Enabled users"

# j is an object which can be used to make requests with respect to the loginsession
j = jpspy.MyLoginSession(loginUrl, loginData, loginTestUrl, successStr, debug=args.debug)
sm = smpy.MyLoginSession(loginUrl, loginData, loginTestUrl, successStr, debug=args.debug)
# Acquire authkey
authkey = getauthkey()
# Gather data of FLAC file
@@ -678,13 +676,13 @@ if __name__ == "__main__":
# Folder_name equals the last folder in the path, this is used to rename .torrent files to something relevant.
folder_name = os.path.basename(os.path.normpath(directory))
# Identifying cover.jpg path
cover_path = directory + "/" + cfg['local_prefs']['cover_name']
# cover_path = directory + "/" + cfg['local_prefs']['cover_name']

# Create torrent file.
torrentfile = createtorrent(authkey, directory, folder_name, releasedata)

# Upload torrent to JPopSuki
uploadtorrent(torrentfile, cover_path, releasedata)
# uploadtorrent(torrentfile, cover_path, releasedata)

# Setting variable for watch/download folders
ftp_watch_folder = cfg['ftp_prefs']['ftp_watch_folder']


Caricamento…
Annulla
Salva