Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Alternative folder for repost images and -norepost command line argument #93

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 13 additions & 3 deletions tumblr-photo-video-ripper.py
Original file line number Diff line number Diff line change
Expand Up @@ -181,9 +181,12 @@ def download_photos(self, site):

def _download_media(self, site, medium_type, start):
current_folder = os.getcwd()
target_folder = os.path.join(current_folder, site)
if not os.path.isdir(target_folder):
os.mkdir(target_folder)
target_folder_base = os.path.join(current_folder, site)
if not os.path.isdir(target_folder_base):
os.mkdir(target_folder_base)
target_folder_other = os.path.join(current_folder, site+'-other')
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why not using the origin site name as the new folder name? And we could avoid downloading the duplicate photos/videos as well.

I mean if the media in A is reblogged from B, you can just create a new folder B to store this media, instead of current A-other.

Copy link
Author

@msk-nightingale msk-nightingale Jul 23, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It is not comfortable when threre ara many reposts from many different blogs and a user need to see lot of photos / videos...

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It is not comfortable when threre ara many reposts from many different blogs and a user need to see lot of photos / videos...

Still use A and B as an example.

A: media1
   media2 (rebloged from B)
B: media2 (rebloged from C)
   media3

What if a user is trying to downloading media2 from site A, you will save it to A-other folder. And later if downloading from site B, media2 will be downloaded again and save to B-other folder.

Actually they are identical, which should not be save multiple times.

Then why not directly saving it to folder C (for site C)?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe... I made this feature for me and it's bad for me what you say.

if not os.path.isdir(target_folder_other):
os.mkdir(target_folder_other)

base_url = "http://{0}.tumblr.com/api/read?type={1}&num={2}&start={3}"
start = START
Expand All @@ -201,6 +204,13 @@ def _download_media(self, site, medium_type, start):
data = xmltodict.parse(xml_cleaned)
posts = data["tumblr"]["posts"]["post"]
for post in posts:
if '@reblogged-from-url' in post:
target_folder=target_folder_other
if len (sys.argv) > 2 and sys.argv[2] == '-norepost':
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Better add some help message on this new flag in the main function.

Update README as well please.

print ("Skipped\n")
continue
else:
target_folder=target_folder_base
try:
# if post has photoset, walk into photoset for each photo
photoset = post["photoset"]["photo"]
Expand Down