Skip to content

Commit

Permalink
Merge pull request #6 from RyouMon/dev
Browse files Browse the repository at this point in the history
Fix issue #5.
  • Loading branch information
RyouMon authored Feb 22, 2022
2 parents f9eba47 + 5ed2584 commit e8a89a1
Showing 1 changed file with 15 additions and 16 deletions.
31 changes: 15 additions & 16 deletions src/favorites_crawler/items.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,11 +24,19 @@ def get_filename(self, url):
return unquote(url.rsplit('/', maxsplit=1)[1])

def get_folder_name(self):
name = self.title
prefix = self.get_folder_prefix()
subfix = self.get_folder_subfix()
return f'{prefix}{name}{subfix}'

def get_folder_prefix(self):
return f'[{self.id}] '

def get_folder_subfix(self):
tags = ' '.join(self.tags)
prefix = f'[{self.id}] {self.title}'
if tags:
return prefix + f' [{tags}]'
return prefix
if not tags:
return ''
return f' [{tags}]'


@dataclass
Expand Down Expand Up @@ -64,19 +72,10 @@ def get_filename(self):


@dataclass
class LemonPicPostItem:
id: int = field(default=None)
title: str = field(default=None)
image_urls: List = field(default_factory=list)
tags: List = field(default_factory=list)
referer: str = field(default=None)
class LemonPicPostItem(BaseItem):

def get_filename(self, url):
tags = ' '.join(self.tags)
folder = f'{self.title} [{tags}]'
name = url.rsplit('/', maxsplit=1)[1]
filename = os.path.join(folder, name)
return drop_illegal_characters(filename)
def get_folder_prefix(self):
return ''


@dataclass
Expand Down

0 comments on commit e8a89a1

Please sign in to comment.