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

Proposal for Limiting files under 10M, minor formatting change. #2

Closed
wants to merge 2 commits into from
Closed
Changes from 1 commit
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
4 changes: 3 additions & 1 deletion main.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
import os
import sys

print "fetching msg from " + sys.argv[1] + "\n"
print "fetching message from " + sys.argv[1] + "\n"
url = sys.argv[1]
r = requests.get(url)
contents = r.text
Expand Down Expand Up @@ -55,6 +55,8 @@
songname = d["data"]["songList"][0]["songName"]
artistName = d["data"]["songList"][0]["artistName"]
filename = "./" + songdir + "/"+songname+"-"+artistName+".flac"
if os.path.getsize(filename) < 10000 * 1024: #Source from http://stackoverflow.com/questions/8626325/most-efficient-way-to-delete-a-file-if-its-below-a-certain-size
Copy link
Owner

@atlas-comstock atlas-comstock Apr 30, 2016

Choose a reason for hiding this comment

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

The position of this code is not right.
We should check the file size and delete it after downloading.
Thank you for you pull request. :P

Copy link
Author

Choose a reason for hiding this comment

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

Moved it to the bottom.

os.remove(filename)
print filename + " is downloading now ......\n\n"

f = urllib2.urlopen(songlink)
Expand Down