示例#1
0
 async def refresh_client(self):
     """
     The client's authorization is invalidated automatically
     after an hour, so we need to refresh it (just refreshing the
     access token using .refresh_token does not work).
     """
     self.da_client = deviantart.Api(config.da_client_id,
                                     config.da_client_secret)
示例#2
0
def fetch_folders(username='******'):
    da = deviantart.Api(da_logs["id"], da_logs["mdp"])
    LIMIT = 15
    has_more = True
    offset = 0
    all_folders = []
    while (has_more):
        collec = da.get_collections(username=username,
                                    offset=offset,
                                    limit=LIMIT)
        folder = collec['results']
        all_folders += folder
        has_more = collec["has_more"]
        offset += LIMIT
    return all_folders
示例#3
0
def fetch_img(n_img, folderid, username):
    # max number of img : 50
    if RUN_DA & (n_img <= 50):
        print('Fetching img from Deviantart')
        #create an API object with your client credentials
        da = deviantart.Api(da_logs["id"], da_logs["mdp"])
        #sketchit = DA_sketch_appli(da)
        #folderid = 'DC11C610-7878-FCF8-CDDF-DB9428F7CB29' # Sketch folder
        #folderid='5B222A0F-8E0B-D602-920C-BCA299BEAE3E'#amphibians
        #folderid = '0BB1B33D-87F6-F45A-ACB9-3AE61EA78C76' # inspiration 2017
        #folderid = '93C80B8C-18E8-98CC-764E-7CC2258ED2CD' # Birds
        #folderid =  "F4E960A3-2D38-9731-D51E-878957299FC5" # Sculptures
        #folderid="AA53736E-41A2-7032-C280-F39B57ED6E7D"#pantyhose-fan
        #folderid="44A4EDFE-8A95-06B8-2B48-DF5D873DA65E"#parazelsus

        infos_devs = []
        #collec = da.get_collection(folderid, username='******', offset=10, limit=10)
        collec = da.get_collection(folderid,
                                   username=username,
                                   offset=0,
                                   limit=12)

        #
        imgs = collec['results']
        urls = [imgs[i].preview['src'] for i in range(len(imgs))]
        dims = [[imgs[i].preview['width'], imgs[i].preview['height']]
                for i in range(len(imgs))]

        print('api query completed')
    else:
        urls = [
            'https://images-wixmp-ed30a86b8c4ca887773594c2.wixmp.com/i/2831f606-837e-4d80-9506-6c57243f6d31/dd9bbkc-b7b1a125-06b6-44ef-a868-47fd5f26ea02.jpg',
            'https://images-wixmp-ed30a86b8c4ca887773594c2.wixmp.com/f/70834e96-067e-42b9-8c26-8fe104d3fbaa/dd9bbn2-fd35a3c4-f95a-47ba-9253-8bbee53e1b73.jpg/v1/fill/w_900,h_1125,q_75,strp/zelda___botw2_by_larienne_dd9bbn2-fullview.jpg?token=eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJzdWIiOiJ1cm46YXBwOjdlMGQxODg5ODIyNjQzNzNhNWYwZDQxNWVhMGQyNmUwIiwiaXNzIjoidXJuOmFwcDo3ZTBkMTg4OTgyMjY0MzczYTVmMGQ0MTVlYTBkMjZlMCIsIm9iaiI6W1t7ImhlaWdodCI6Ijw9MTEyNSIsInBhdGgiOiJcL2ZcLzcwODM0ZTk2LTA2N2UtNDJiOS04YzI2LThmZTEwNGQzZmJhYVwvZGQ5YmJuMi1mZDM1YTNjNC1mOTVhLTQ3YmEtOTI1My04YmJlZTUzZTFiNzMuanBnIiwid2lkdGgiOiI8PTkwMCJ9XV0sImF1ZCI6WyJ1cm46c2VydmljZTppbWFnZS5vcGVyYXRpb25zIl19.O0OG8lr3TlphoQfOAzCqMKcf87VSqIoSDru0cWGCAU0'
        ]
        dims = [[3000, 1300], [3000, 1300]]

    return {'urls': urls, 'dims': dims}
示例#4
0
import deviantart

with open("_CLIENT_SECRET.txt") as f:
    CLIENT_SECRET = f.readline().strip()

# Log in to DA
da = deviantart.Api("11505", CLIENT_SECRET)
示例#5
0
 def __init__(self, bot):
     self.bot = bot
     self.search_limit = 5  # How many times we look for images per command
     self.post_limit = 20  # How many images get returned per iteration
     self.da_client = deviantart.Api(config.da_client_id,
                                     config.da_client_secret)
示例#6
0
 def __init__(self):
     super().__init__("deviantart")
     self.client = deviantart.Api(keys.deviantart.get("key"),
                                  keys.deviantart.get("secret"),
                                  scope="user")
     self.favfolder = None
示例#7
0
from pybooru import Danbooru
import deviantart
import praw
from twitter import *
from googleapiclient.discovery import build
from googleapiclient.errors import HttpError

app = Flask(__name__)

# Tokens
handler = WebhookHandler('LINE ChannelSecret')
line = LineBotApi('LINE ChannelAccess')
reddit = praw.Reddit(client_id='REDDIT Client',
                     client_secret="REDDIT Secret",
                     user_agent='REDDIT UserAgent')
dvart = deviantart.Api('DVART Channel', 'DVART Secret')
tw = Twitter(auth=OAuth('TWITTER token', 'TWITTER token_secret',
                        'TWITTER consumer_key', 'TWITTER consumer_secret'))
youtube = build("youtube", "v3", developerKey="GOOGLE API KEY")

# Initialize bot
bot = BotClass(line, reddit, dvart, tw, youtube)


@app.route("/callback", methods=['POST'])
def callback():
    # get X-Line-Signature header value
    signature = request.headers['X-Line-Signature']
    # get request body as text
    body = request.get_data(as_text=True)
    app.logger.info("Request body: " + body)
示例#8
0
 def setUp(self):
     self.da = deviantart.Api(CLIENT_ID, CLIENT_SECRET)
示例#9
0
import deviantart
import random
import re
import modules.config as config

# Connect API
da = deviantart.Api(config.client_id, config.client_secret)

# Provides a DeviantArt image URL related to a cardname
def generate_image_url(cardname):
    deviations = {'results': []}
    tag_ = ""
    # For each word in the cardname, try and find a relevant DeviantArt tag
    for word in reversed(re.findall(r"[\w']+", cardname)):
        tags = da.search_tags(word)
        if(tags != []):
            tag_ = random.choice(tags)
            break
    if(tag_ == ""):
        # No tag was found, so pick some random deviations
        while(deviations['results'] == []):
            deviations = da.browse(endpoint='popular')
    else:
        # Browse deviations of that tag
        deviations = da.browse(endpoint='tags', tag=tag_)
        if(deviations['results'] == []):
            # No tag was found, so pick some random deviations
            while(deviations['results'] == []):
                deviations = da.browse(endpoint='popular')

示例#10
0
 def setUp(self):
     self.da = deviantart.Api("", "")
示例#11
0
def parsejobs(deviation):
    # create an API object with your client credentials
    da = deviantart.Api("", "")  # YOUR_CLIENT_ID, YOUR_CLIENT_SECRET
    # the name of the user we want to fetch deviations from
    __username__ = ""

    image_path = './{}/'.format(__username__)

    da_appurl = deviation.deviationid

    if (deviation.is_deleted):
        print('[ ! ] The post had been deleted!')
        return
    if (deviation.published_time):
        readableTime = datetime.datetime.fromtimestamp(
            int(deviation.published_time)).isoformat()
        readableTime = re.search(r'(.+)T', readableTime).group(1)
    else:
        readableTime = 'withoutDateTime'
    if (deviation.is_downloadable == False):
        try:
            imageDownloadUrl = deviation.content['src']
            regexSearch = re.search(r"https:\/\/.+net(.+)\/(.+)",
                                    imageDownloadUrl)
            date = regexSearch.group(1)
            date = re.sub(r"\/", '-', date)
            imageNameWithoutPath = 'deviantart-{0}-{1}-{2}'.format(
                readableTime, date, regexSearch.group(2))
            img_data = requests.get(imageDownloadUrl).content
            image_name = image_path + imageNameWithoutPath

            if (os.path.isfile(image_name)):
                print("[✗] {} was already downloaded.".format(
                    imageNameWithoutPath))
                return
            print(
                '[ ! ] This image\'s quality may not be well, beacuse the author blocked the download option.'
            )
            print('[✓] donwloading {}'.format(imageNameWithoutPath))
            with open(image_name, 'wb') as handler:
                handler.write(img_data)
        except:
            return
    imageInfo = da.download_deviation(da_appurl)

    regexSearch = re.search(
        r"https:\/\/s3.amazonaws.com\/.+deviantart.net\/(.+)\/(.+)\?",
        imageInfo['src'])
    imageDownloadUrl = regexSearch.group()[:-1]
    date = regexSearch.group(1)
    date = re.sub(r"\/", '-', date)
    imageNameWithoutPath = 'deviantart-{0}-{1}-{2}'.format(
        readableTime, date, regexSearch.group(2))

    img_data = requests.get(imageDownloadUrl).content

    image_name = image_path + imageNameWithoutPath

    if (os.path.isfile(image_name)):
        print("[✗] {} was already downloaded.".format(imageNameWithoutPath))
        return
    print('[✓] donwloading {}'.format(imageNameWithoutPath))
    with open(image_name, 'wb') as handler:
        handler.write(img_data)
示例#12
0

def get_cursor(_username):
    #global session
    #plurk = _session
    #global da
    #plurk = _da
    global __username__
    __username__ = _username


if __name__ == "__main__":
    t1 = time.time()

    # create an API object with your client credentials
    da = deviantart.Api("", "")  # YOUR_CLIENT_ID, YOUR_CLIENT_SECRET
    # the name of the user we want to fetch deviations from
    crawlUserName = ""

    # define defaults
    deviations = []

    offset = 0
    has_more = True

    path = './' + crawlUserName
    if not os.path.exists(path):
        os.mkdir(path)

    # while there are more deviations to fetch
    while has_more: