Skip to content

Commit

Permalink
[Bluesky] Use native auth
Browse files Browse the repository at this point in the history
  • Loading branch information
GiovanH committed Oct 26, 2023
1 parent 9a1abd1 commit 7e67dcc
Showing 1 changed file with 5 additions and 6 deletions.
11 changes: 5 additions & 6 deletions gallery_dl/extractor/bluesky.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@

import json
import dataclasses
import netrc
import posixpath

import chitose
Expand All @@ -31,10 +30,9 @@ def __init__(self, extractor, instance="bsky.social"):
# BSKY_USER = extractor.config("username"),
# BSKY_PASSWD = extractor.config("password")

rc = netrc.netrc()
(BSKY_USER, _, BSKY_PASSWD) = rc.authenticators(instance)
username, password = extractor._get_auth_info()

self.agent.login(BSKY_USER, BSKY_PASSWD)
self.agent.login(username, password)

def bskyGetDid(self, user_id: str) -> str:
return json.loads(self.agent.get_profile(actor=user_id))['did']
Expand All @@ -60,7 +58,7 @@ def getSkeetJson(self, post_reference):

class _BlueskyPostExtractor(Extractor):
"""Extractor for bluesky posts"""
category = "bluesky"
category = "bsky.social"
subcategory = "post"
directory_fmt = ("{category}", "{user_id}")
filename_fmt = "{post_id} {filename}.{extension}"
Expand All @@ -72,9 +70,10 @@ class _BlueskyPostExtractor(Extractor):
def __init__(self, match):
Extractor.__init__(self, match)
self.user_id, self.post_id = match.groups()

self.api = BlueskyAPI(self)
self.json_obj = self.api.getSkeetJson(PostReference(self.user_id, self.post_id))

self.json_obj = self.api.getSkeetJson(PostReference(self.user_id, self.post_id))
self.metadata = self.json_obj
self.metadata.update(match.groupdict())

Expand Down

0 comments on commit 7e67dcc

Please sign in to comment.