Last active
December 8, 2020 14:39
-
-
Save larsenv/9343d9e9fa6fa379214af73ba1448fba to your computer and use it in GitHub Desktop.
This used to be the code for the RiiConnect24 News Channel. This is why it took me forever to make it. I think I've learned from my mistake tremendously. Kids, stay in school, or else your code will look like this when trying to work on a big project.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/usr/bin/python | |
| # -*- coding: utf-8 -*- | |
| import sys | |
| import subprocess | |
| import shutil | |
| import urllib2 | |
| import time | |
| import re | |
| import platform | |
| import os | |
| import glob | |
| import codecs | |
| from datetime import datetime, date | |
| from newspaper import * | |
| from itertools import ifilter | |
| from HTMLParser import HTMLParser | |
| reload(sys) | |
| sys.setdefaultencoding('ISO-8859-1') | |
| print 'News Channel Downloader for RiiConnect24-File-Maker, by Larsenv and VoidSt4r. http://riiconnect24.net' | |
| print '\n' | |
| newslanguagecodes = { | |
| 'Language': 'English', | |
| 'Code': '1', | |
| 'Language': 'French', | |
| 'Code': '3', | |
| 'Language': 'Spanish', | |
| 'Code': '4', | |
| } | |
| def getnewslink(category, link, number): | |
| with open(category, 'w+') as source_file: | |
| with open(category, 'wb') as dest_file: | |
| file1 = 'http://hosted.ap.org/lineups/' + link \ | |
| + 'HEADS.rss?SITE=AP&SECTION=HOME' | |
| file2 = urllib2.urlopen(file1) | |
| file3 = file2.read() | |
| file4 = dest_file.write(file3) | |
| with open(category, 'rb') as file: | |
| file1 = (file.readlines()[number])[12:-9] | |
| if 'http' in file1: | |
| parsedata(category, file1) | |
| def getallnumbers(category, link): | |
| category1 = category + '1' | |
| category2 = category + '2' | |
| category3 = category + '3' | |
| category4 = category + '4' | |
| category5 = category + '5' | |
| category6 = category + '6' | |
| category7 = category + '7' | |
| category8 = category + '8' | |
| category9 = category + '9' | |
| category10 = category + '10' | |
| categorya = category + 'a' | |
| with open(categorya, 'w+') as source_file: | |
| with open(categorya, 'wb') as dest_file: | |
| file1 = 'http://hosted.ap.org/lineups/' + link \ | |
| + 'HEADS.rss?SITE=AP&SECTION=HOME' | |
| file2 = urllib2.urlopen(file1) | |
| file3 = file2.read() | |
| file4 = dest_file.write(file3) | |
| myfile = open(categorya) | |
| lines = len(myfile.readlines()) | |
| if lines >= 9: | |
| getnewslink(category1, link, 9) | |
| if lines >= 14: | |
| getnewslink(category2, link, 14) | |
| if lines >= 19: | |
| getnewslink(category3, link, 19) | |
| if lines >= 24: | |
| getnewslink(category4, link, 24) | |
| if lines >= 29: | |
| getnewslink(category5, link, 29) | |
| if lines >= 34: | |
| getnewslink(category6, link, 34) | |
| if lines >= 39: | |
| getnewslink(category7, link, 39) | |
| if lines >= 44: | |
| getnewslink(category8, link, 44) | |
| if lines >= 49: | |
| getnewslink(category9, link, 49) | |
| if lines >= 54: | |
| getnewslink(category10, link, 54) | |
| def parsedata(filename, link): | |
| data1 = Article(link, language='en') # English | |
| data1.download() | |
| data1.parse() | |
| data2 = data1.html | |
| filename1 = filename + '-1' | |
| filename2 = filename + '-2' | |
| filename3 = filename + '-3' | |
| filename4 = filename + '-4' | |
| filename5 = filename + '-5' | |
| filename6 = filename + '-6' | |
| filename7 = filename + '-7' | |
| filename8 = filename + '-8' | |
| filename9 = filename + '-9' | |
| filename10 = filename + '-10' | |
| filename11 = filename + '-11' | |
| filename12 = filename + '-12' | |
| with open(filename1, 'w+') as f: | |
| with open(filename1, 'w+b') as dest_file: | |
| dest_file.write(data2.encode('utf-8')) | |
| with open(filename1, 'rb') as f: | |
| with open(filename2, 'wb') as g: | |
| g.writelines(ifilter(lambda line: 'timestamp updated' \ | |
| in line, f)) | |
| filelines1 = open(filename2) | |
| filelines2 = filelines1.readlines() | |
| filelines3 = filelines2[0] | |
| filelines4 = filelines3[61:77] | |
| filelines5 = datetime.strptime(filelines4, '%Y-%m-%dT%H%MZ') | |
| filelines6 = time.mktime(filelines5.timetuple()) | |
| filelines7 = ' = ' + filename | |
| filelines8 = '\n' | |
| filelines9 = filelines8 + str(filelines6) + filelines7 | |
| with open(filename12, 'w+') as dest_file: | |
| dest_file.write(filelines9) | |
| with open(filename1, 'rb') as f: | |
| with open(filename4, 'w+') as g: | |
| g.writelines(ifilter(lambda line: 'headline entry-title' \ | |
| in line, f)) | |
| with open(filename1, 'rb') as f: | |
| with open(filename6, 'w+') as g: | |
| g.writelines(ifilter(lambda line: \ | |
| 'ap-smallphoto-font-photo photo' in line, f)) | |
| with open(filename1, 'rb') as f: | |
| with open(filename8, 'w+') as g: | |
| g.writelines(ifilter(lambda line: 'ap-smallphoto-tr' \ | |
| in line, f)) | |
| with open(filename2, 'w+') as source_file: | |
| with open(filename2, 'wb') as dest_file: | |
| dest_file.write(data1.text.encode('utf-16be')) | |
| if 'ap-smallphoto-font-photo photo' in data2: | |
| with open(filename3, 'w+') as source_file: | |
| with open(filename3, 'wb') as dest_file: | |
| if data1.top_image[0:27] \ | |
| == 'http://hosted.ap.org/photos/': | |
| newspicture1 = data1.top_image[:-10] + '-medium.jpg' | |
| newspicture2 = urllib2.urlopen(newspicture1) | |
| newspicture3 = newspicture2.read() | |
| dest_file.write(newspicture3) | |
| with open(filename4, 'rb') as source_file: | |
| with open(filename5, 'wb') as dest_file: | |
| newstitle = source_file.read()[51:-8] | |
| dest_file.write(newstitle.encode('utf-16be')) | |
| if 'ap-smallphoto-font-photo photo' in data2: | |
| with open(filename6, 'rb') as source_file: | |
| with open(filename7, 'wb') as dest_file: | |
| newscredits = source_file.read()[69:-23] | |
| dest_file.write(newscredits.encode('utf-16be')) | |
| if 'ap-smallphoto-font-photo photo' in data2: | |
| with open(filename8, 'rb') as source_file: | |
| with open(filename9, 'wb') as dest_file: | |
| newscaptions1 = 'http://hosted.ap.org' \ | |
| + source_file.read()[74:-169] | |
| newscaptions2 = urllib2.urlopen(newscaptions1) | |
| newscaptions3 = newscaptions2.read() | |
| dest_file.write(newscaptions3) | |
| if 'ap-smallphoto-font-photo photo' in data2: | |
| with open(filename9, 'rb') as f: | |
| with open(filename10, 'w+') as g: | |
| g.writelines(ifilter(lambda line: 'ap-photo-td' \ | |
| in line, f)) | |
| if 'ap-smallphoto-font-photo photo' in data2: | |
| with open(filename10, 'rb') as source_file: | |
| with open(filename11, 'wb') as dest_file: | |
| newscaptions1 = source_file.readlines() | |
| newscaptions2 = newscaptions1[1] | |
| newscaptions3 = newscaptions2[70:-8] | |
| newscaptions4 = newscaptions3.split(' (AP Photo', 1)[0] | |
| dest_file.write(newscaptions4.encode('utf-16be')) | |
| def newsarticles(name, file): | |
| article1a = open(file, 'r') | |
| article1b = article1a.read() | |
| article1c = article1b.decode('utf-16be') | |
| if ' (AP) -- ' in article1c: | |
| article1d = article1c.split(' (AP) -- ', 1)[1] | |
| article1e = article1c.split(' (AP) -- ', 1)[0] | |
| article1f = article1d.encode('utf-16be') | |
| article1g = open(file, 'wb') | |
| article1h = article1g.write(article1f) | |
| article1i = name + '-13' | |
| article1j = article1e.encode('utf-16be') | |
| article1k = open(article1i, 'w+') | |
| article1l = article1k.write(article1j) | |
| print 'Downloading from Associated Press...' | |
| print 'Downloading National News...' | |
| getallnumbers('national', 'US') | |
| print 'Downloading International News...' | |
| getallnumbers('international', 'WORLD') | |
| print 'Downloading Sports News...' | |
| getallnumbers('sports', 'SPORTS') | |
| print 'Downloading Arts/Entertainment News...' | |
| getallnumbers('entertainment', 'ENTERTAINMENT') | |
| print 'Downloading Business News...' | |
| getallnumbers('business', 'BUSINESS') | |
| print 'Downloading Science News...' | |
| getallnumbers('science', 'SCIENCE') | |
| print 'Downloading Health News...' | |
| getallnumbers('health', 'HEALTH') | |
| print 'Downloading Technology News...' | |
| getallnumbers('technology', 'TECH') | |
| print '\n' | |
| print 'Making the news.bin...' | |
| with open('timestamps', 'w+') as dest_file: | |
| for filename in glob.glob('*-12'): | |
| with open(filename, 'rb') as readfile: | |
| shutil.copyfileobj(readfile, dest_file) | |
| timestamps1 = open('timestamps', 'rb') | |
| timestamps2 = timestamps1.readlines() | |
| timestamps3 = max(timestamps2) | |
| timestamps4 = (timestamps3.split(' = ', 1)[1])[:-1] | |
| timestamps5 = timestamps2.remove(max(timestamps2)) | |
| timestamps6 = max(timestamps2) | |
| timestamps7 = (timestamps6.split(' = ', 1)[1])[:-1] | |
| timestamps8 = timestamps2.remove(max(timestamps2)) | |
| timestamps9 = max(timestamps2) | |
| timestamps10 = (timestamps9.split(' = ', 1)[1])[:-1] | |
| timestamps11 = timestamps2.remove(max(timestamps2)) | |
| timestamps12 = max(timestamps2) | |
| timestamps13 = (timestamps12.split(' = ', 1)[1])[:-1] | |
| timestamps14 = timestamps2.remove(max(timestamps2)) | |
| timestamps15 = max(timestamps2) | |
| timestamps16 = (timestamps15.split(' = ', 1)[1])[:-1] | |
| timestamps17 = timestamps2.remove(max(timestamps2)) | |
| timestamps18 = max(timestamps2) | |
| timestamps19 = (timestamps18.split(' = ', 1)[1])[:-1] | |
| timestamps20 = timestamps2.remove(max(timestamps2)) | |
| timestamps21 = max(timestamps2) | |
| timestamps22 = (timestamps21.split(' = ', 1)[1])[:-1] | |
| timestamps23 = timestamps2.remove(max(timestamps2)) | |
| timestamps24 = max(timestamps2) | |
| timestamps25 = (timestamps24.split(' = ', 1)[1])[:-1] | |
| timestamps26 = timestamps2.remove(max(timestamps2)) | |
| timestamps27 = max(timestamps2) | |
| timestamps28 = (timestamps27.split(' = ', 1)[1])[:-1] | |
| timestamps29 = timestamps2.remove(max(timestamps2)) | |
| timestamps30 = max(timestamps2) | |
| timestamps31 = (timestamps30.split(' = ', 1)[1])[:-1] | |
| timestamps32 = timestamps2.remove(max(timestamps2)) | |
| timestamps33 = max(timestamps2) | |
| timestamps34 = (timestamps33.split(' = ', 1)[1])[:-1] | |
| timestamps35 = timestamps2.remove(max(timestamps2)) | |
| timestampsinseconds1 = open('timestamps', 'rb') | |
| timestampsinseconds2 = timestampsinseconds1.readlines() | |
| timestampsinseconds3 = max(timestampsinseconds2) | |
| timestampsinseconds4 = timestampsinseconds3.split(' = ', 1)[0] | |
| timestampsinseconds5 = \ | |
| timestampsinseconds2.remove(max(timestampsinseconds2)) | |
| timestampsinseconds6 = max(timestampsinseconds2) | |
| timestampsinseconds7 = timestampsinseconds6.split(' = ', 1)[0] | |
| timestampsinseconds8 = \ | |
| timestampsinseconds2.remove(max(timestampsinseconds2)) | |
| timestampsinseconds9 = max(timestampsinseconds2) | |
| timestampsinseconds10 = timestampsinseconds9.split(' = ', 1)[0] | |
| timestampsinseconds11 = \ | |
| timestampsinseconds2.remove(max(timestampsinseconds2)) | |
| timestampsinseconds12 = max(timestampsinseconds2) | |
| timestampsinseconds13 = timestampsinseconds12.split(' = ', 1)[0] | |
| timestampsinseconds14 = \ | |
| timestampsinseconds2.remove(max(timestampsinseconds2)) | |
| timestampsinseconds15 = max(timestampsinseconds2) | |
| timestampsinseconds16 = timestampsinseconds15.split(' = ', 1)[0] | |
| timestampsinseconds17 = \ | |
| timestampsinseconds2.remove(max(timestampsinseconds2)) | |
| timestampsinseconds18 = max(timestampsinseconds2) | |
| timestampsinseconds19 = timestampsinseconds18.split(' = ', 1)[0] | |
| timestampsinseconds20 = \ | |
| timestampsinseconds2.remove(max(timestampsinseconds2)) | |
| timestampsinseconds21 = max(timestampsinseconds2) | |
| timestampsinseconds22 = timestampsinseconds19.split(' = ', 1)[0] | |
| timestampsinseconds23 = \ | |
| timestampsinseconds2.remove(max(timestampsinseconds2)) | |
| timestampsinseconds24 = max(timestampsinseconds2) | |
| timestampsinseconds25 = timestampsinseconds24.split(' = ', 1)[0] | |
| timestampsinseconds26 = \ | |
| timestampsinseconds2.remove(max(timestampsinseconds2)) | |
| timestampsinseconds27 = max(timestampsinseconds2) | |
| timestampsinseconds28 = timestampsinseconds27.split(' = ', 1)[0] | |
| timestampsinseconds29 = \ | |
| timestampsinseconds2.remove(max(timestampsinseconds2)) | |
| timestampsinseconds30 = max(timestampsinseconds2) | |
| timestampsinseconds31 = timestampsinseconds30.split(' = ', 1)[0] | |
| timestampsinseconds32 = \ | |
| timestampsinseconds2.remove(max(timestampsinseconds2)) | |
| timestampsinseconds33 = max(timestampsinseconds2) | |
| timestampsinseconds34 = timestampsinseconds33.split(' = ', 1)[0] | |
| timestampsinseconds35 = \ | |
| timestampsinseconds2.remove(max(timestampsinseconds2)) | |
| seconds_to_2000 = 946684800 | |
| ticks_per_second = 71567500 | |
| wiitimestamp1 = hex(int(ticks_per_second * (float(timestampsinseconds4) | |
| - seconds_to_2000)))[2:8] + '00' | |
| wiitimestamp2 = hex(int(ticks_per_second * (float(timestampsinseconds7) | |
| - seconds_to_2000)))[2:8] + '00' | |
| wiitimestamp3 = hex(int(ticks_per_second | |
| * (float(timestampsinseconds10) | |
| - seconds_to_2000)))[2:8] + '00' | |
| wiitimestamp4 = hex(int(ticks_per_second | |
| * (float(timestampsinseconds13) | |
| - seconds_to_2000)))[2:8] + '00' | |
| wiitimestamp5 = hex(int(ticks_per_second | |
| * (float(timestampsinseconds16) | |
| - seconds_to_2000)))[2:8] + '00' | |
| wiitimestamp6 = hex(int(ticks_per_second | |
| * (float(timestampsinseconds19) | |
| - seconds_to_2000)))[2:8] + '00' | |
| wiitimestamp7 = hex(int(ticks_per_second | |
| * (float(timestampsinseconds22) | |
| - seconds_to_2000)))[2:8] + '00' | |
| wiitimestamp8 = hex(int(ticks_per_second | |
| * (float(timestampsinseconds25) | |
| - seconds_to_2000)))[2:8] + '00' | |
| wiitimestamp9 = hex(int(ticks_per_second | |
| * (float(timestampsinseconds28) | |
| - seconds_to_2000)))[2:8] + '00' | |
| wiitimestamp10 = hex(int(ticks_per_second | |
| * (float(timestampsinseconds31) | |
| - seconds_to_2000)))[2:8] + '00' | |
| wiitimestamp11 = hex(int(ticks_per_second | |
| * (float(timestampsinseconds34) | |
| - seconds_to_2000)))[2:8] + '00' | |
| globeparsers = [ | |
| timestamps4, | |
| timestamps7, | |
| timestamps10, | |
| timestamps13, | |
| timestamps16, | |
| timestamps19, | |
| timestamps22, | |
| timestamps25, | |
| timestamps28, | |
| timestamps31, | |
| timestamps34, | |
| ] | |
| names1 = timestamps4 + '-2' | |
| names2 = timestamps7 + '-2' | |
| names3 = timestamps10 + '-2' | |
| names4 = timestamps13 + '-2' | |
| names5 = timestamps16 + '-2' | |
| names6 = timestamps19 + '-2' | |
| names7 = timestamps22 + '-2' | |
| names8 = timestamps25 + '-2' | |
| names9 = timestamps28 + '-2' | |
| names10 = timestamps31 + '-2' | |
| names11 = timestamps34 + '-2' | |
| newsarticles(timestamps4, names1) | |
| newsarticles(timestamps7, names2) | |
| newsarticles(timestamps10, names3) | |
| newsarticles(timestamps13, names4) | |
| newsarticles(timestamps16, names5) | |
| newsarticles(timestamps19, names6) | |
| newsarticles(timestamps22, names7) | |
| newsarticles(timestamps25, names8) | |
| newsarticles(timestamps28, names9) | |
| newsarticles(timestamps31, names10) | |
| newsarticles(timestamps34, names11) | |
| titlesize1a = timestamps4 + '-5' | |
| titlesize1b = os.path.getsize(titlesize1a) | |
| with open(titlesize1a, 'rb') as source_file: | |
| titleopen1a = source_file.read() | |
| titlesize2a = timestamps7 + '-5' | |
| titlesize2b = os.path.getsize(titlesize2a) | |
| with open(titlesize2a, 'rb') as source_file: | |
| titleopen2a = source_file.read() | |
| titlesize3a = timestamps10 + '-5' | |
| titlesize3b = os.path.getsize(titlesize3a) | |
| with open(titlesize3a, 'rb') as source_file: | |
| titleopen3a = source_file.read() | |
| titlesize4a = timestamps13 + '-5' | |
| titlesize4b = os.path.getsize(titlesize4a) | |
| with open(titlesize4a, 'rb') as source_file: | |
| titleopen4a = source_file.read() | |
| titlesize5a = timestamps16 + '-5' | |
| titlesize5b = os.path.getsize(titlesize5a) | |
| with open(titlesize5a, 'rb') as source_file: | |
| titleopen5a = source_file.read() | |
| titlesize6a = timestamps19 + '-5' | |
| titlesize6b = os.path.getsize(titlesize6a) | |
| with open(titlesize6a, 'rb') as source_file: | |
| titleopen6a = source_file.read() | |
| titlesize7a = timestamps22 + '-5' | |
| titlesize7b = os.path.getsize(titlesize7a) | |
| with open(titlesize7a, 'rb') as source_file: | |
| titleopen7a = source_file.read() | |
| titlesize8a = timestamps25 + '-5' | |
| titlesize8b = os.path.getsize(titlesize8a) | |
| with open(titlesize8a, 'rb') as source_file: | |
| titleopen8a = source_file.read() | |
| titlesize9a = timestamps28 + '-5' | |
| titlesize9b = os.path.getsize(titlesize9a) | |
| with open(titlesize9a, 'rb') as source_file: | |
| titleopen9a = source_file.read() | |
| titlesize10a = timestamps31 + '-5' | |
| titlesize10b = os.path.getsize(titlesize10a) | |
| with open(titlesize10a, 'rb') as source_file: | |
| titleopen10a = source_file.read() | |
| titlesize11a = timestamps34 + '-5' | |
| titlesize11b = os.path.getsize(titlesize11a) | |
| with open(titlesize11a, 'rb') as source_file: | |
| titleopen11a = source_file.read() | |
| captionssize1a = timestamps4 + '-11' | |
| if os.path.exists(captionssize1a): | |
| with open(captionssize1a, 'rb') as source_file: | |
| captionssize1b = source_file.read() | |
| else: | |
| captionssize1b = int(0) | |
| if os.path.exists(captionssize1a): | |
| captionssize1c = os.path.getsize(captionssize1a) | |
| else: | |
| captionssize1c = int(0) | |
| captionssize2a = timestamps7 + '-11' | |
| if os.path.exists(captionssize2a): | |
| with open(captionssize2a, 'rb') as source_file: | |
| captionssize2b = source_file.read() | |
| else: | |
| captionssize2b = int(0) | |
| if os.path.exists(captionssize2a): | |
| captionssize2c = os.path.getsize(captionssize2a) | |
| else: | |
| captionssize2c = int(0) | |
| captionssize3a = timestamps10 + '-11' | |
| if os.path.exists(captionssize3a): | |
| with open(captionssize3a, 'rb') as source_file: | |
| captionssize3b = source_file.read() | |
| else: | |
| captionssize3b = int(0) | |
| if os.path.exists(captionssize3a): | |
| captionssize3c = os.path.getsize(captionssize3a) | |
| else: | |
| captionssize3c = int(0) | |
| captionssize4a = timestamps13 + '-11' | |
| if os.path.exists(captionssize4a): | |
| with open(captionssize4a, 'rb') as source_file: | |
| captionssize4b = source_file.read() | |
| else: | |
| captionssize4b = int(0) | |
| if os.path.exists(captionssize4a): | |
| captionssize4c = os.path.getsize(captionssize4a) | |
| else: | |
| captionssize4c = int(0) | |
| captionssize5a = timestamps16 + '-11' | |
| if os.path.exists(captionssize5a): | |
| with open(captionssize5a, 'rb') as source_file: | |
| captionssize5b = source_file.read() | |
| else: | |
| captionssize5b = int(0) | |
| if os.path.exists(captionssize5a): | |
| captionssize5c = os.path.getsize(captionssize5a) | |
| else: | |
| captionssize5c = int(0) | |
| captionssize6a = timestamps19 + '-11' | |
| if os.path.exists(captionssize6a): | |
| with open(captionssize6a, 'rb') as source_file: | |
| captionssize6b = source_file.read() | |
| else: | |
| captionssize6b = int(0) | |
| if os.path.exists(captionssize6a): | |
| captionssize6c = os.path.getsize(captionssize6a) | |
| else: | |
| captionssize6c = int(0) | |
| captionssize7a = timestamps22 + '-11' | |
| if os.path.exists(captionssize7a): | |
| with open(captionssize7a, 'rb') as source_file: | |
| captionssize7b = source_file.read() | |
| else: | |
| captionssize7b = int(0) | |
| if os.path.exists(captionssize7a): | |
| captionssize7c = os.path.getsize(captionssize7a) | |
| else: | |
| captionssize7c = int(0) | |
| captionssize8a = timestamps25 + '-11' | |
| if os.path.exists(captionssize8a): | |
| with open(captionssize8a, 'rb') as source_file: | |
| captionssize8b = source_file.read() | |
| else: | |
| captionssize8b = int(0) | |
| if os.path.exists(captionssize8a): | |
| captionssize8c = os.path.getsize(captionssize8a) | |
| else: | |
| captionssize8c = int(0) | |
| captionssize9a = timestamps28 + '-11' | |
| if os.path.exists(captionssize9a): | |
| with open(captionssize9a, 'rb') as source_file: | |
| captionssize9b = source_file.read() | |
| else: | |
| captionssize10b = int(0) | |
| if os.path.exists(captionssize9a): | |
| captionssize9c = os.path.getsize(captionssize9a) | |
| else: | |
| captionssize9c = int(0) | |
| captionssize10a = timestamps31 + '-11' | |
| if os.path.exists(captionssize10a): | |
| with open(captionssize10a, 'rb') as source_file: | |
| captionssize10b = source_file.read() | |
| if os.path.exists(captionssize10a): | |
| captionssize10c = os.path.getsize(captionssize10a) | |
| else: | |
| captionssize10c = int(0) | |
| captionssize11a = timestamps34 + '-11' | |
| if os.path.exists(captionssize11a): | |
| with open(captionssize11a, 'rb') as source_file: | |
| captionssize11b = source_file.read() | |
| else: | |
| captionssize11b = int(0) | |
| if os.path.exists(captionssize11a): | |
| captionssize11c = os.path.getsize(captionssize11a) | |
| else: | |
| captionssize11c = int(0) | |
| articlesize1a = timestamps4 + '-2' | |
| articlesize1b = os.path.getsize(articlesize1a) | |
| with open(articlesize1a, 'rb') as source_file: | |
| articleopen1a = source_file.read() | |
| articlesize2a = timestamps7 + '-2' | |
| articlesize2b = os.path.getsize(articlesize2a) | |
| with open(articlesize2a, 'rb') as source_file: | |
| articleopen2a = source_file.read() | |
| articlesize3a = timestamps10 + '-2' | |
| articlesize3b = os.path.getsize(articlesize3a) | |
| with open(articlesize3a, 'rb') as source_file: | |
| articleopen3a = source_file.read() | |
| articlesize4a = timestamps13 + '-2' | |
| articlesize4b = os.path.getsize(articlesize4a) | |
| with open(articlesize4a, 'rb') as source_file: | |
| articleopen4a = source_file.read() | |
| articlesize5a = timestamps16 + '-2' | |
| articlesize5b = os.path.getsize(articlesize5a) | |
| with open(articlesize5a, 'rb') as source_file: | |
| articleopen5a = source_file.read() | |
| articlesize6a = timestamps19 + '-2' | |
| articlesize6b = os.path.getsize(articlesize6a) | |
| with open(articlesize6a, 'rb') as source_file: | |
| articleopen6a = source_file.read() | |
| articlesize7a = timestamps22 + '-2' | |
| articlesize7b = os.path.getsize(articlesize7a) | |
| with open(articlesize7a, 'rb') as source_file: | |
| articleopen7a = source_file.read() | |
| articlesize8a = timestamps25 + '-2' | |
| articlesize8b = os.path.getsize(articlesize8a) | |
| with open(articlesize8a, 'rb') as source_file: | |
| articleopen8a = source_file.read() | |
| articlesize9a = timestamps28 + '-2' | |
| articlesize9b = os.path.getsize(articlesize9a) | |
| with open(articlesize9a, 'rb') as source_file: | |
| articleopen9a = source_file.read() | |
| articlesize10a = timestamps31 + '-2' | |
| articlesize10b = os.path.getsize(articlesize10a) | |
| with open(articlesize10a, 'rb') as source_file: | |
| articleopen10a = source_file.read() | |
| articlesize11a = timestamps34 + '-2' | |
| articlesize11b = os.path.getsize(articlesize11a) | |
| with open(articlesize11a, 'rb') as source_file: | |
| articleopen11a = source_file.read() | |
| locationsize1a = timestamps4 + '-13' | |
| if os.path.exists(locationsize1a): | |
| with open(locationsize1a, 'rb') as source_file: | |
| locationsize1b = source_file.read() | |
| else: | |
| locationsize1b = int(0) | |
| if os.path.exists(locationsize1a): | |
| locationsize1c = os.path.getsize(locationsize1a) | |
| else: | |
| locationsize1c = int(0) | |
| locationsize2a = timestamps7 + '-13' | |
| if os.path.exists(locationsize2a): | |
| with open(locationsize2a, 'rb') as source_file: | |
| locationsize2b = source_file.read() | |
| else: | |
| locationsize2b = int(0) | |
| if os.path.exists(locationsize2a): | |
| locationsize2c = os.path.getsize(locationsize2a) | |
| else: | |
| locationsize2c = int(0) | |
| locationsize3a = timestamps10 + '-13' | |
| if os.path.exists(locationsize3a): | |
| with open(locationsize3a, 'rb') as source_file: | |
| locationsize3b = source_file.read() | |
| else: | |
| locationsize3b = int(0) | |
| if os.path.exists(locationsize3a): | |
| locationsize3c = os.path.getsize(locationsize3a) | |
| else: | |
| locationsize3c = int(0) | |
| locationsize4a = timestamps13 + '-13' | |
| if os.path.exists(locationsize4a): | |
| with open(locationsize4a, 'rb') as source_file: | |
| locationsize4b = source_file.read() | |
| else: | |
| locationsize4b = int(0) | |
| if os.path.exists(locationsize4a): | |
| locationsize4c = os.path.getsize(locationsize4a) | |
| else: | |
| locationsize4c = int(0) | |
| locationsize5a = timestamps16 + '-13' | |
| if os.path.exists(locationsize5a): | |
| with open(locationsize5a, 'rb') as source_file: | |
| locationsize5b = source_file.read() | |
| else: | |
| locationsize5b = int(0) | |
| if os.path.exists(locationsize5a): | |
| locationsize5c = os.path.getsize(locationsize5a) | |
| else: | |
| locationsize5c = int(0) | |
| locationsize6a = timestamps19 + '-13' | |
| if os.path.exists(locationsize6a): | |
| with open(locationsize6a, 'rb') as source_file: | |
| locationsize6b = source_file.read() | |
| else: | |
| locationsize6b = int(0) | |
| if os.path.exists(locationsize6a): | |
| locationsize6c = os.path.getsize(locationsize6a) | |
| else: | |
| locationsize6c = int(0) | |
| locationsize7a = timestamps22 + '-13' | |
| if os.path.exists(locationsize7a): | |
| with open(locationsize7a, 'rb') as source_file: | |
| locationsize7b = source_file.read() | |
| else: | |
| locationsize7b = int(0) | |
| if os.path.exists(locationsize7a): | |
| locationsize7c = os.path.getsize(locationsize7a) | |
| else: | |
| locationsize7c = int(0) | |
| locationsize8a = timestamps25 + '-13' | |
| if os.path.exists(locationsize8a): | |
| with open(locationsize8a, 'rb') as source_file: | |
| locationsize8b = source_file.read() | |
| else: | |
| locationsize8b = int(0) | |
| if os.path.exists(locationsize8a): | |
| locationsize8c = os.path.getsize(locationsize8a) | |
| else: | |
| locationsize8c = int(0) | |
| locationsize9a = timestamps28 + '-13' | |
| if os.path.exists(locationsize9a): | |
| with open(locationsize9a, 'rb') as source_file: | |
| locationsize9b = source_file.read() | |
| else: | |
| locationsize10b = int(0) | |
| if os.path.exists(locationsize9a): | |
| locationsize9c = os.path.getsize(locationsize9a) | |
| else: | |
| locationsize9c = int(0) | |
| locationsize10a = timestamps31 + '-13' | |
| if os.path.exists(locationsize10a): | |
| with open(locationsize10a, 'rb') as source_file: | |
| locationsize10b = source_file.read() | |
| if os.path.exists(locationsize10a): | |
| locationsize10c = os.path.getsize(locationsize10a) | |
| else: | |
| locationsize10c = int(0) | |
| locationsize11a = timestamps34 + '-13' | |
| if os.path.exists(locationsize11a): | |
| with open(locationsize11a, 'rb') as source_file: | |
| locationsize11b = source_file.read() | |
| else: | |
| locationsize11b = int(0) | |
| if os.path.exists(locationsize11a): | |
| locationsize11c = os.path.getsize(locationsize11a) | |
| else: | |
| locationsize11c = int(0) | |
| articlesize1a = timestamps4 + '-2' | |
| articlesize1b = os.path.getsize(articlesize1a) | |
| with open(articlesize1a, 'rb') as source_file: | |
| articleopen1a = source_file.read() | |
| articlesize2a = timestamps7 + '-2' | |
| articlesize2b = os.path.getsize(articlesize2a) | |
| with open(articlesize2a, 'rb') as source_file: | |
| articleopen2a = source_file.read() | |
| articlesize3a = timestamps10 + '-2' | |
| articlesize3b = os.path.getsize(articlesize3a) | |
| with open(articlesize3a, 'rb') as source_file: | |
| articleopen3a = source_file.read() | |
| articlesize4a = timestamps13 + '-2' | |
| articlesize4b = os.path.getsize(articlesize4a) | |
| with open(articlesize4a, 'rb') as source_file: | |
| articleopen4a = source_file.read() | |
| articlesize5a = timestamps16 + '-2' | |
| articlesize5b = os.path.getsize(articlesize5a) | |
| with open(articlesize5a, 'rb') as source_file: | |
| articleopen5a = source_file.read() | |
| articlesize6a = timestamps19 + '-2' | |
| articlesize6b = os.path.getsize(articlesize6a) | |
| with open(articlesize6a, 'rb') as source_file: | |
| articleopen6a = source_file.read() | |
| articlesize7a = timestamps22 + '-2' | |
| articlesize7b = os.path.getsize(articlesize7a) | |
| with open(articlesize7a, 'rb') as source_file: | |
| articleopen7a = source_file.read() | |
| articlesize8a = timestamps25 + '-2' | |
| articlesize8b = os.path.getsize(articlesize8a) | |
| with open(articlesize8a, 'rb') as source_file: | |
| articleopen8a = source_file.read() | |
| articlesize9a = timestamps28 + '-2' | |
| articlesize9b = os.path.getsize(articlesize9a) | |
| with open(articlesize9a, 'rb') as source_file: | |
| articleopen9a = source_file.read() | |
| articlesize10a = timestamps31 + '-2' | |
| articlesize10b = os.path.getsize(articlesize10a) | |
| with open(articlesize10a, 'rb') as source_file: | |
| articleopen10a = source_file.read() | |
| articlesize11a = timestamps34 + '-2' | |
| articlesize11b = os.path.getsize(articlesize11a) | |
| with open(articlesize11a, 'rb') as source_file: | |
| articleopen11a = source_file.read() | |
| creditssize1a = timestamps4 + '-7' | |
| if os.path.exists(creditssize1a): | |
| with open(creditssize1a, 'rb') as source_file: | |
| creditssize1b = source_file.read() | |
| if os.path.exists(creditssize1a): | |
| creditssize1c = os.path.getsize(creditssize1a) | |
| else: | |
| creditssize1c = '0' | |
| creditssize2a = timestamps7 + '-7' | |
| if os.path.exists(creditssize2a): | |
| with open(creditssize2a, 'rb') as source_file: | |
| creditssize2b = source_file.read() | |
| if os.path.exists(creditssize2a): | |
| creditssize2c = os.path.getsize(creditssize2a) | |
| else: | |
| creditssize2c = '0' | |
| creditssize3a = timestamps10 + '-7' | |
| if os.path.exists(creditssize3a): | |
| with open(creditssize3a, 'rb') as source_file: | |
| creditssize3b = source_file.read() | |
| if os.path.exists(creditssize3a): | |
| creditssize3c = os.path.getsize(creditssize3a) | |
| else: | |
| creditssize3c = '0' | |
| creditssize4a = timestamps13 + '-7' | |
| if os.path.exists(creditssize4a): | |
| with open(creditssize4a, 'rb') as source_file: | |
| creditssize4b = source_file.read() | |
| if os.path.exists(creditssize4a): | |
| creditssize1c = os.path.getsize(creditssize4a) | |
| else: | |
| creditssize4c = '0' | |
| creditssize5a = timestamps16 + '-7' | |
| if os.path.exists(creditssize5a): | |
| with open(creditssize5a, 'rb') as source_file: | |
| creditssize5b = source_file.read() | |
| if os.path.exists(creditssize5a): | |
| creditssize5c = os.path.getsize(creditssize5a) | |
| else: | |
| creditssize5c = '0' | |
| creditssize6a = timestamps19 + '-7' | |
| if os.path.exists(creditssize6a): | |
| with open(creditssize6a, 'rb') as source_file: | |
| creditssize6b = source_file.read() | |
| if os.path.exists(creditssize6a): | |
| creditssize6c = os.path.getsize(creditssize6a) | |
| else: | |
| creditssize6c = '0' | |
| creditssize7a = timestamps22 + '-7' | |
| if os.path.exists(creditssize7a): | |
| with open(creditssize7a, 'rb') as source_file: | |
| creditssize7b = source_file.read() | |
| if os.path.exists(creditssize7a): | |
| creditssize7c = os.path.getsize(creditssize7a) | |
| else: | |
| creditssize7c = '0' | |
| creditssize8a = timestamps25 + '-7' | |
| if os.path.exists(creditssize8a): | |
| with open(creditssize8a, 'rb') as source_file: | |
| creditssize8b = source_file.read() | |
| if os.path.exists(creditssize8a): | |
| creditssize8c = os.path.getsize(creditssize8a) | |
| else: | |
| creditssize8c = '0' | |
| creditssize9a = timestamps28 + '-7' | |
| if os.path.exists(creditssize9a): | |
| with open(creditssize9a, 'rb') as source_file: | |
| creditssize9b = source_file.read() | |
| if os.path.exists(creditssize9a): | |
| creditssize9c = os.path.getsize(creditssize9a) | |
| else: | |
| creditssize9c = '0' | |
| creditssize10a = timestamps31 + '-7' | |
| if os.path.exists(creditssize10a): | |
| with open(creditssize10a, 'rb') as source_file: | |
| creditssize10b = source_file.read() | |
| if os.path.exists(creditssize10a): | |
| creditssize10c = os.path.getsize(creditssize10a) | |
| else: | |
| creditssize10c = '0' | |
| creditssize11a = timestamps34 + '-7' | |
| if os.path.exists(creditssize11a): | |
| with open(creditssize11a, 'rb') as source_file: | |
| creditssize11b = source_file.read() | |
| if os.path.exists(creditssize11a): | |
| creditssize11c = os.path.getsize(creditssize11a) | |
| else: | |
| creditssize11c = '0' | |
| picturessize1a = timestamps4 + '-3' | |
| if os.path.exists(picturessize1a): | |
| with open(picturessize1a, 'rb') as source_file: | |
| picturessize1b = source_file.read() | |
| if os.path.exists(picturessize1a): | |
| picturessize1c = os.path.getsize(picturessize1a) | |
| else: | |
| picturessize1c = '0' | |
| picturessize2a = timestamps7 + '-3' | |
| if os.path.exists(picturessize2a): | |
| with open(picturessize2a, 'rb') as source_file: | |
| picturessize2b = source_file.read() | |
| if os.path.exists(picturessize2a): | |
| picturessize2c = os.path.getsize(picturessize2a) | |
| else: | |
| picturessize2c = '0' | |
| picturessize3a = timestamps10 + '-3' | |
| if os.path.exists(picturessize3a): | |
| with open(picturessize3a, 'rb') as source_file: | |
| picturessize3b = source_file.read() | |
| if os.path.exists(picturessize3a): | |
| picturessize3c = os.path.getsize(picturessize3a) | |
| else: | |
| picturessize3c = '0' | |
| picturessize4a = timestamps13 + '-3' | |
| if os.path.exists(picturessize4a): | |
| with open(picturessize4a, 'rb') as source_file: | |
| picturessize4b = source_file.read() | |
| if os.path.exists(picturessize4a): | |
| picturessize4c = os.path.getsize(picturessize4a) | |
| else: | |
| picturessize4c = '0' | |
| picturessize5a = timestamps16 + '-3' | |
| if os.path.exists(picturessize5a): | |
| with open(picturessize5a, 'rb') as source_file: | |
| picturessize5b = source_file.read() | |
| if os.path.exists(picturessize5a): | |
| picturessize5c = os.path.getsize(picturessize5a) | |
| else: | |
| picturessize5c = '0' | |
| picturessize6a = timestamps19 + '-3' | |
| if os.path.exists(picturessize6a): | |
| with open(picturessize6a, 'rb') as source_file: | |
| picturessize6b = source_file.read() | |
| if os.path.exists(picturessize6a): | |
| picturessize6c = os.path.getsize(picturessize6a) | |
| else: | |
| picturessize6c = '0' | |
| picturessize7a = timestamps22 + '-3' | |
| if os.path.exists(picturessize7a): | |
| with open(picturessize7a, 'rb') as source_file: | |
| picturessize7b = source_file.read() | |
| if os.path.exists(picturessize7a): | |
| picturessize7c = os.path.getsize(picturessize7a) | |
| else: | |
| picturessize7c = '0' | |
| picturessize8a = timestamps25 + '-3' | |
| if os.path.exists(picturessize8a): | |
| with open(picturessize8a, 'rb') as source_file: | |
| picturessize8b = source_file.read() | |
| if os.path.exists(picturessize8a): | |
| picturessize8c = os.path.getsize(picturessize8a) | |
| else: | |
| picturessize8c = '0' | |
| picturessize9a = timestamps28 + '-3' | |
| if os.path.exists(picturessize9a): | |
| with open(picturessize9a, 'rb') as source_file: | |
| picturessize9b = source_file.read() | |
| if os.path.exists(picturessize9a): | |
| picturessize9c = os.path.getsize(picturessize9a) | |
| else: | |
| picturessize9c = '0' | |
| picturessize10a = timestamps31 + '-3' | |
| if os.path.exists(picturessize10a): | |
| with open(picturessize10a, 'rb') as source_file: | |
| picturessize10b = source_file.read() | |
| if os.path.exists(picturessize10a): | |
| picturessize10c = os.path.getsize(picturessize10a) | |
| else: | |
| picturessize10c = '0' | |
| picturessize11a = timestamps34 + '-3' | |
| if os.path.exists(picturessize11a): | |
| with open(picturessize11a, 'rb') as source_file: | |
| picturessize11b = source_file.read() | |
| if os.path.exists(picturessize11a): | |
| picturessize11c = os.path.getsize(picturessize11a) | |
| else: | |
| picturessize11c = '0' | |
| articlelists = [ | |
| 'national1', | |
| 'national2', | |
| 'national3', | |
| 'national4', | |
| 'national5', | |
| 'national6', | |
| 'national7', | |
| 'national8', | |
| 'national9', | |
| 'national10', | |
| 'international1', | |
| 'international2', | |
| 'international3', | |
| 'international4', | |
| 'international5', | |
| 'international6', | |
| 'international7', | |
| 'international8', | |
| 'international9', | |
| 'international10', | |
| 'sports1', | |
| 'sports2', | |
| 'sports3', | |
| 'sports4', | |
| 'sports5', | |
| 'sports6', | |
| 'sports7', | |
| 'sports8', | |
| 'sports9', | |
| 'sports10', | |
| 'entertainment1', | |
| 'entertainment2', | |
| 'entertainment3', | |
| 'entertainment4', | |
| 'entertainment5', | |
| 'entertainment6', | |
| 'entertainment7', | |
| 'entertainment8', | |
| 'entertainment9', | |
| 'entertainment10', | |
| 'business1', | |
| 'business2', | |
| 'business3', | |
| 'business4', | |
| 'business5', | |
| 'business6', | |
| 'business7', | |
| 'business8', | |
| 'business9', | |
| 'business10', | |
| 'science1', | |
| 'science2', | |
| 'science3', | |
| 'science4', | |
| 'science5', | |
| 'science6', | |
| 'science7', | |
| 'science8', | |
| 'science9', | |
| 'science10', | |
| 'health1', | |
| 'health2', | |
| 'health3', | |
| 'health4', | |
| 'health5', | |
| 'health6', | |
| 'health7', | |
| 'health8', | |
| 'health9', | |
| 'health10', | |
| 'technology1', | |
| 'technology2', | |
| 'technology3', | |
| 'technology4', | |
| 'technology5', | |
| 'technology6', | |
| 'technology7', | |
| 'technology8', | |
| 'technology9', | |
| 'technology10', | |
| ] | |
| topicsap1a = 'National News' | |
| topicsap1b = topicsap1a.encode('utf-16be') | |
| topicsap2a = 'Regional News' # I'm probably not gonna use this. | |
| topicsap2b = topicsap2a.encode('utf-16be') | |
| topicsap3a = 'International News' | |
| topicsap3b = topicsap3a.encode('utf-16be') | |
| topicsap4a = 'Sports' | |
| topicsap4b = topicsap4a.encode('utf-16be') | |
| topicsap5a = 'Arts/Entertainment' | |
| topicsap5b = topicsap5a.encode('utf-16be') | |
| topicsap6a = 'Business' | |
| topicsap6b = topicsap6a.encode('utf-16be') | |
| topicsap7a = 'Science/Health' | |
| topicsap7b = topicsap7a.encode('utf-16be') | |
| topicsap8a = 'Technology' | |
| topicsap8b = topicsap8a.encode('utf-16be') | |
| for articles in articlelists: | |
| if articles not in globeparsers: | |
| for articles in glob.glob('%s*' % articles): | |
| os.remove(articles) | |
| with open('titles', 'w+') as dest_file: | |
| for titles in glob.glob('*-5'): | |
| with open(titles, 'rb') as source_file: | |
| dest_file.write(source_file.read()) | |
| if datetime.now().hour == 0: | |
| with open('newstime-0', 'w+') as source_file: | |
| with open('newstime-0', 'wb') as dest_file: | |
| time1 = wiitimestamp1 + '00000001' + wiitimestamp2 \ | |
| + '00000002' + wiitimestamp3 + '00000003' \ | |
| + wiitimestamp4 + '00000004' | |
| dest_file.write(time1) | |
| elif datetime.now().hour == 1: | |
| with open('newstime-1', 'w+') as source_file: | |
| with open('newstime-01', 'wb') as dest_file: | |
| time1 = wiitimestamp1 + '00000001' + wiitimestamp2 \ | |
| + '00000002' + wiitimestamp3 + '00000003' \ | |
| + wiitimestamp4 + '00000004' | |
| dest_file.write(time1) | |
| elif datetime.now().hour == 2: | |
| with open('newstime-2', 'w+') as source_file: | |
| with open('newstime-2', 'wb') as dest_file: | |
| time1 = wiitimestamp1 + '00000001' + wiitimestamp2 \ | |
| + '00000002' + wiitimestamp3 + '00000003' \ | |
| + wiitimestamp4 + '00000004' | |
| dest_file.write(time1) | |
| elif datetime.now().hour == 3: | |
| with open('newstime-3', 'w+') as source_file: | |
| with open('newstime-3', 'wb') as dest_file: | |
| time1 = wiitimestamp1 + '00000001' + wiitimestamp2 \ | |
| + '00000002' + wiitimestamp3 + '00000003' \ | |
| + wiitimestamp4 + '00000004' | |
| dest_file.write(time1) | |
| elif datetime.now().hour == 4: | |
| with open('newstime-4', 'w+') as source_file: | |
| with open('newstime-4', 'wb') as dest_file: | |
| time1 = wiitimestamp1 + '00000001' + wiitimestamp2 \ | |
| + '00000002' + wiitimestamp3 + '00000003' \ | |
| + wiitimestamp4 + '00000004' | |
| dest_file.write(time1) | |
| elif datetime.now().hour == 5: | |
| with open('newstime-5', 'w+') as source_file: | |
| with open('newstime-5', 'wb') as dest_file: | |
| time1 = wiitimestamp1 + '00000001' + wiitimestamp2 \ | |
| + '00000002' + wiitimestamp3 + '00000003' \ | |
| + wiitimestamp4 + '00000004' | |
| dest_file.write(time1) | |
| elif datetime.now().hour == 6: | |
| with open('newstime-6', 'w+') as source_file: | |
| with open('newstime-6', 'wb') as dest_file: | |
| time1 = wiitimestamp1 + '00000001' + wiitimestamp2 \ | |
| + '00000002' + wiitimestamp3 + '00000003' \ | |
| + wiitimestamp4 + '00000004' | |
| dest_file.write(time1) | |
| elif datetime.now().hour == 7: | |
| with open('newstime-7', 'w+') as source_file: | |
| with open('newstime-7', 'wb') as dest_file: | |
| time1 = wiitimestamp1 + '00000001' + wiitimestamp2 \ | |
| + '00000002' + wiitimestamp3 + '00000003' \ | |
| + wiitimestamp4 + '00000004' | |
| dest_file.write(time1) | |
| elif datetime.now().hour == 8: | |
| with open('newstime-8', 'w+') as source_file: | |
| with open('newstime-8', 'wb') as dest_file: | |
| time1 = wiitimestamp1 + '00000001' + wiitimestamp2 \ | |
| + '00000002' + wiitimestamp3 + '00000003' \ | |
| + wiitimestamp4 + '00000004' | |
| dest_file.write(time8) | |
| elif datetime.now().hour == 9: | |
| with open('newstime-9', 'w+') as source_file: | |
| with open('newstime-9', 'wb') as dest_file: | |
| time1 = wiitimestamp1 + '00000001' + wiitimestamp2 \ | |
| + '00000002' + wiitimestamp3 + '00000003' \ | |
| + wiitimestamp4 + '00000004' | |
| dest_file.write(time1) | |
| elif datetime.now().hour == 10: | |
| with open('newstime-10', 'w+') as source_file: | |
| with open('newstime-10', 'wb') as dest_file: | |
| time1 = wiitimestamp1 + '00000001' + wiitimestamp2 \ | |
| + '00000002' + wiitimestamp3 + '00000003' \ | |
| + wiitimestamp4 + '00000004' | |
| dest_file.write(time1) | |
| elif datetime.now().hour == 11: | |
| with open('newstime-11', 'w+') as source_file: | |
| with open('newstime-11', 'wb') as dest_file: | |
| time1 = wiitimestamp1 + '00000001' + wiitimestamp2 \ | |
| + '00000002' + wiitimestamp3 + '00000003' \ | |
| + wiitimestamp4 + '00000004' | |
| dest_file.write(time1) | |
| elif datetime.now().hour == 12: | |
| with open('newstime-12', 'w+') as source_file: | |
| with open('newstime-12', 'wb') as dest_file: | |
| time1 = wiitimestamp1 + '00000001' + wiitimestamp2 \ | |
| + '00000002' + wiitimestamp3 + '00000003' \ | |
| + wiitimestamp4 + '00000004' | |
| dest_file.write(time1) | |
| elif datetime.now().hour == 13: | |
| with open('newstime-13', 'w+') as source_file: | |
| with open('newstime-13', 'wb') as dest_file: | |
| time1 = wiitimestamp1 + '00000001' + wiitimestamp2 \ | |
| + '00000002' + wiitimestamp3 + '00000003' \ | |
| + wiitimestamp4 + '00000004' | |
| dest_file.write(time1) | |
| elif datetime.now().hour == 14: | |
| with open('newstime-14', 'w+') as source_file: | |
| with open('newstime-14', 'wb') as dest_file: | |
| time1 = wiitimestamp1 + '00000001' + wiitimestamp2 \ | |
| + '00000002' + wiitimestamp3 + '00000003' \ | |
| + wiitimestamp4 + '00000004' | |
| dest_file.write(time1) | |
| elif datetime.now().hour == 15: | |
| with open('newstime-15', 'w+') as source_file: | |
| with open('newstime-15', 'wb') as dest_file: | |
| time1 = wiitimestamp1 + '00000001' + wiitimestamp2 \ | |
| + '00000002' + wiitimestamp3 + '00000003' \ | |
| + wiitimestamp4 + '00000004' | |
| dest_file.write(time1) | |
| elif datetime.now().hour == 16: | |
| with open('newstime-16', 'w+') as source_file: | |
| with open('newstime-16', 'wb') as dest_file: | |
| time1 = wiitimestamp1 + '00000001' + wiitimestamp2 \ | |
| + '00000002' + wiitimestamp3 + '00000003' \ | |
| + wiitimestamp4 + '00000004' | |
| dest_file.write(time1) | |
| elif datetime.now().hour == 17: | |
| with open('newstime-17', 'w+') as source_file: | |
| with open('newstime-17', 'wb') as dest_file: | |
| time1 = wiitimestamp1 + '00000001' + wiitimestamp2 \ | |
| + '00000002' + wiitimestamp3 + '00000003' \ | |
| + wiitimestamp4 + '00000004' | |
| dest_file.write(time1) | |
| elif datetime.now().hour == 18: | |
| with open('newstime-18', 'w+') as source_file: | |
| with open('newstime-18', 'wb') as dest_file: | |
| time1 = wiitimestamp1 + '00000001' + wiitimestamp2 \ | |
| + '00000002' + wiitimestamp3 + '00000003' \ | |
| + wiitimestamp4 + '00000004' | |
| dest_file.write(time1) | |
| elif datetime.now().hour == 19: | |
| with open('newstime-19', 'w+') as source_file: | |
| with open('newstime-19', 'wb') as dest_file: | |
| time1 = wiitimestamp1 + '00000001' + wiitimestamp2 \ | |
| + '00000002' + wiitimestamp3 + '00000003' \ | |
| + wiitimestamp4 + '00000004' | |
| dest_file.write(time1) | |
| elif datetime.now().hour == 20: | |
| with open('newstime-20', 'w+') as source_file: | |
| with open('newstime-20', 'wb') as dest_file: | |
| time1 = wiitimestamp1 + '00000001' + wiitimestamp2 \ | |
| + '00000002' + wiitimestamp3 + '00000003' \ | |
| + wiitimestamp4 + '00000004' | |
| dest_file.write(time1) | |
| elif datetime.now().hour == 21: | |
| with open('newstime-21', 'w+') as source_file: | |
| with open('newstime-21', 'wb') as dest_file: | |
| time1 = wiitimestamp1 + '00000001' + wiitimestamp2 \ | |
| + '00000002' + wiitimestamp3 + '00000003' \ | |
| + wiitimestamp4 + '00000004' | |
| dest_file.write(time1) | |
| elif datetime.now().hour == 22: | |
| with open('newstime-22', 'w+') as source_file: | |
| with open('newstime-22', 'wb') as dest_file: | |
| time1 = wiitimestamp1 + '00000001' + wiitimestamp2 \ | |
| + '00000002' + wiitimestamp3 + '00000003' \ | |
| + wiitimestamp4 + '00000004' | |
| dest_file.write(time1) | |
| elif datetime.now().hour == 23: | |
| with open('newstime-23', 'w+') as source_file: | |
| with open('newstime-23', 'wb') as dest_file: | |
| time1 = wiitimestamp1 + '00000001' + wiitimestamp2 \ | |
| + '00000002' + wiitimestamp3 + '00000003' \ | |
| + wiitimestamp4 + '00000004' | |
| dest_file.write(time1) | |
| if datetime.now().hour == 0: | |
| with open('newsarticlenumbers-0', 'w+') as source_file: | |
| with open('newsarticlenumbers-0', 'wb') as dest_file: | |
| articlenumbers1 = timestamps4 + '\n' + timestamps7 + '\n' \ | |
| + timestamps10 + '\n' + timestamps13 + '\n' \ | |
| + timestamps16 + '\n' + timestamps19 + '\n' \ | |
| + timestamps22 + '\n' + timestamps25 + '\n' \ | |
| + timestamps28 + '\n' + timestamps31 + '\n' | |
| dest_file.write(articlenumbers1) | |
| elif datetime.now().hour == 1: | |
| with open('newsarticlenumbers-1', 'w+') as source_file: | |
| with open('newsarticlenumbers-01', 'wb') as dest_file: | |
| articlenumbers1 = timestamps4 + '\n' + timestamps7 + '\n' \ | |
| + timestamps10 + '\n' + timestamps13 + '\n' \ | |
| + timestamps16 + '\n' + timestamps19 + '\n' \ | |
| + timestamps22 + '\n' + timestamps25 + '\n' \ | |
| + timestamps28 + '\n' + timestamps31 + '\n' | |
| dest_file.write(articlenumbers1) | |
| elif datetime.now().hour == 2: | |
| with open('newsarticlenumbers-2', 'w+') as source_file: | |
| with open('newsarticlenumbers-2', 'wb') as dest_file: | |
| articlenumbers1 = timestamps4 + '\n' + timestamps7 + '\n' \ | |
| + timestamps10 + '\n' + timestamps13 + '\n' \ | |
| + timestamps16 + '\n' + timestamps19 + '\n' \ | |
| + timestamps22 + '\n' + timestamps25 + '\n' \ | |
| + timestamps28 + '\n' + timestamps31 + '\n' | |
| dest_file.write(articlenumbers1) | |
| elif datetime.now().hour == 3: | |
| with open('newsarticlenumbers-3', 'w+') as source_file: | |
| with open('newsarticlenumbers-3', 'wb') as dest_file: | |
| articlenumbers1 = timestamps4 + '\n' + timestamps7 + '\n' \ | |
| + timestamps10 + '\n' + timestamps13 + '\n' \ | |
| + timestamps16 + '\n' + timestamps19 + '\n' \ | |
| + timestamps22 + '\n' + timestamps25 + '\n' \ | |
| + timestamps28 + '\n' + timestamps31 + '\n' | |
| dest_file.write(articlenumbers1) | |
| elif datetime.now().hour == 4: | |
| with open('newsarticlenumbers-4', 'w+') as source_file: | |
| with open('newsarticlenumbers-4', 'wb') as dest_file: | |
| articlenumbers1 = timestamps4 + '\n' + timestamps7 + '\n' \ | |
| + timestamps10 + '\n' + timestamps13 + '\n' \ | |
| + timestamps16 + '\n' + timestamps19 + '\n' \ | |
| + timestamps22 + '\n' + timestamps25 + '\n' \ | |
| + timestamps28 + '\n' + timestamps31 + '\n' | |
| dest_file.write(articlenumbers1) | |
| elif datetime.now().hour == 5: | |
| with open('newsarticlenumbers-5', 'w+') as source_file: | |
| with open('newsarticlenumbers-5', 'wb') as dest_file: | |
| articlenumbers1 = timestamps4 + '\n' + timestamps7 + '\n' \ | |
| + timestamps10 + '\n' + timestamps13 + '\n' \ | |
| + timestamps16 + '\n' + timestamps19 + '\n' \ | |
| + timestamps22 + '\n' + timestamps25 + '\n' \ | |
| + timestamps28 + '\n' + timestamps31 + '\n' | |
| dest_file.write(articlenumbers1) | |
| elif datetime.now().hour == 6: | |
| with open('newsarticlenumbers-6', 'w+') as source_file: | |
| with open('newsarticlenumbers-6', 'wb') as dest_file: | |
| articlenumbers1 = timestamps4 + '\n' + timestamps7 + '\n' \ | |
| + timestamps10 + '\n' + timestamps13 + '\n' \ | |
| + timestamps16 + '\n' + timestamps19 + '\n' \ | |
| + timestamps22 + '\n' + timestamps25 + '\n' \ | |
| + timestamps28 + '\n' + timestamps31 + '\n' | |
| dest_file.write(articlenumbers1) | |
| elif datetime.now().hour == 7: | |
| with open('newsarticlenumbers-7', 'w+') as source_file: | |
| with open('newsarticlenumbers-7', 'wb') as dest_file: | |
| articlenumbers1 = timestamps4 + '\n' + timestamps7 + '\n' \ | |
| + timestamps10 + '\n' + timestamps13 + '\n' \ | |
| + timestamps16 + '\n' + timestamps19 + '\n' \ | |
| + timestamps22 + '\n' + timestamps25 + '\n' \ | |
| + timestamps28 + '\n' + timestamps31 + '\n' | |
| dest_file.write(articlenumbers1) | |
| elif datetime.now().hour == 8: | |
| with open('newsarticlenumbers-8', 'w+') as source_file: | |
| with open('newsarticlenumbers-8', 'wb') as dest_file: | |
| time1 = wiitimestamp1 + '00000001' + wiitimestamp2 \ | |
| + '00000002' + wiitimestamp3 + '00000003' \ | |
| + wiitimestamp4 + '00000004' | |
| dest_file.write(time8) | |
| elif datetime.now().hour == 9: | |
| with open('newsarticlenumbers-9', 'w+') as source_file: | |
| with open('newsarticlenumbers-9', 'wb') as dest_file: | |
| articlenumbers1 = timestamps4 + '\n' + timestamps7 + '\n' \ | |
| + timestamps10 + '\n' + timestamps13 + '\n' \ | |
| + timestamps16 + '\n' + timestamps19 + '\n' \ | |
| + timestamps22 + '\n' + timestamps25 + '\n' \ | |
| + timestamps28 + '\n' + timestamps31 + '\n' | |
| dest_file.write(articlenumbers1) | |
| elif datetime.now().hour == 10: | |
| with open('newsarticlenumbers-10', 'w+') as source_file: | |
| with open('newsarticlenumbers-10', 'wb') as dest_file: | |
| articlenumbers1 = timestamps4 + '\n' + timestamps7 + '\n' \ | |
| + timestamps10 + '\n' + timestamps13 + '\n' \ | |
| + timestamps16 + '\n' + timestamps19 + '\n' \ | |
| + timestamps22 + '\n' + timestamps25 + '\n' \ | |
| + timestamps28 + '\n' + timestamps31 + '\n' | |
| dest_file.write(articlenumbers1) | |
| elif datetime.now().hour == 11: | |
| with open('newsarticlenumbers-11', 'w+') as source_file: | |
| with open('newsarticlenumbers-11', 'wb') as dest_file: | |
| articlenumbers1 = timestamps4 + '\n' + timestamps7 + '\n' \ | |
| + timestamps10 + '\n' + timestamps13 + '\n' \ | |
| + timestamps16 + '\n' + timestamps19 + '\n' \ | |
| + timestamps22 + '\n' + timestamps25 + '\n' \ | |
| + timestamps28 + '\n' + timestamps31 + '\n' | |
| dest_file.write(articlenumbers1) | |
| elif datetime.now().hour == 12: | |
| with open('newsarticlenumbers-12', 'w+') as source_file: | |
| with open('newsarticlenumbers-12', 'wb') as dest_file: | |
| articlenumbers1 = timestamps4 + '\n' + timestamps7 + '\n' \ | |
| + timestamps10 + '\n' + timestamps13 + '\n' \ | |
| + timestamps16 + '\n' + timestamps19 + '\n' \ | |
| + timestamps22 + '\n' + timestamps25 + '\n' \ | |
| + timestamps28 + '\n' + timestamps31 + '\n' | |
| dest_file.write(articlenumbers1) | |
| elif datetime.now().hour == 13: | |
| with open('newsarticlenumbers-13', 'w+') as source_file: | |
| with open('newsarticlenumbers-13', 'wb') as dest_file: | |
| articlenumbers1 = timestamps4 + '\n' + timestamps7 + '\n' \ | |
| + timestamps10 + '\n' + timestamps13 + '\n' \ | |
| + timestamps16 + '\n' + timestamps19 + '\n' \ | |
| + timestamps22 + '\n' + timestamps25 + '\n' \ | |
| + timestamps28 + '\n' + timestamps31 + '\n' | |
| dest_file.write(articlenumbers1) | |
| elif datetime.now().hour == 14: | |
| with open('newsarticlenumbers-14', 'w+') as source_file: | |
| with open('newsarticlenumbers-14', 'wb') as dest_file: | |
| articlenumbers1 = timestamps4 + '\n' + timestamps7 + '\n' \ | |
| + timestamps10 + '\n' + timestamps13 + '\n' \ | |
| + timestamps16 + '\n' + timestamps19 + '\n' \ | |
| + timestamps22 + '\n' + timestamps25 + '\n' \ | |
| + timestamps28 + '\n' + timestamps31 + '\n' | |
| dest_file.write(articlenumbers1) | |
| elif datetime.now().hour == 15: | |
| with open('newsarticlenumbers-15', 'w+') as source_file: | |
| with open('newsarticlenumbers-15', 'wb') as dest_file: | |
| articlenumbers1 = timestamps4 + '\n' + timestamps7 + '\n' \ | |
| + timestamps10 + '\n' + timestamps13 + '\n' \ | |
| + timestamps16 + '\n' + timestamps19 + '\n' \ | |
| + timestamps22 + '\n' + timestamps25 + '\n' \ | |
| + timestamps28 + '\n' + timestamps31 + '\n' | |
| dest_file.write(articlenumbers1) | |
| elif datetime.now().hour == 16: | |
| with open('newsarticlenumbers-16', 'w+') as source_file: | |
| with open('newsarticlenumbers-16', 'wb') as dest_file: | |
| articlenumbers1 = timestamps4 + '\n' + timestamps7 + '\n' \ | |
| + timestamps10 + '\n' + timestamps13 + '\n' \ | |
| + timestamps16 + '\n' + timestamps19 + '\n' \ | |
| + timestamps22 + '\n' + timestamps25 + '\n' \ | |
| + timestamps28 + '\n' + timestamps31 + '\n' | |
| dest_file.write(articlenumbers1) | |
| elif datetime.now().hour == 17: | |
| with open('newsarticlenumbers-17', 'w+') as source_file: | |
| with open('newsarticlenumbers-17', 'wb') as dest_file: | |
| articlenumbers1 = timestamps4 + '\n' + timestamps7 + '\n' \ | |
| + timestamps10 + '\n' + timestamps13 + '\n' \ | |
| + timestamps16 + '\n' + timestamps19 + '\n' \ | |
| + timestamps22 + '\n' + timestamps25 + '\n' \ | |
| + timestamps28 + '\n' + timestamps31 + '\n' | |
| dest_file.write(articlenumbers1) | |
| elif datetime.now().hour == 18: | |
| with open('newsarticlenumbers-18', 'w+') as source_file: | |
| with open('newsarticlenumbers-18', 'wb') as dest_file: | |
| articlenumbers1 = timestamps4 + '\n' + timestamps7 + '\n' \ | |
| + timestamps10 + '\n' + timestamps13 + '\n' \ | |
| + timestamps16 + '\n' + timestamps19 + '\n' \ | |
| + timestamps22 + '\n' + timestamps25 + '\n' \ | |
| + timestamps28 + '\n' + timestamps31 + '\n' | |
| dest_file.write(articlenumbers1) | |
| elif datetime.now().hour == 19: | |
| with open('newsarticlenumbers-19', 'w+') as source_file: | |
| with open('newsarticlenumbers-19', 'wb') as dest_file: | |
| articlenumbers1 = timestamps4 + '\n' + timestamps7 + '\n' \ | |
| + timestamps10 + '\n' + timestamps13 + '\n' \ | |
| + timestamps16 + '\n' + timestamps19 + '\n' \ | |
| + timestamps22 + '\n' + timestamps25 + '\n' \ | |
| + timestamps28 + '\n' + timestamps31 + '\n' | |
| dest_file.write(articlenumbers1) | |
| elif datetime.now().hour == 20: | |
| with open('newsarticlenumbers-20', 'w+') as source_file: | |
| with open('newsarticlenumbers-20', 'wb') as dest_file: | |
| articlenumbers1 = timestamps4 + '\n' + timestamps7 + '\n' \ | |
| + timestamps10 + '\n' + timestamps13 + '\n' \ | |
| + timestamps16 + '\n' + timestamps19 + '\n' \ | |
| + timestamps22 + '\n' + timestamps25 + '\n' \ | |
| + timestamps28 + '\n' + timestamps31 + '\n' | |
| dest_file.write(articlenumbers1) | |
| elif datetime.now().hour == 21: | |
| with open('newsarticlenumbers-21', 'w+') as source_file: | |
| with open('newsarticlenumbers-21', 'wb') as dest_file: | |
| articlenumbers1 = timestamps4 + '\n' + timestamps7 + '\n' \ | |
| + timestamps10 + '\n' + timestamps13 + '\n' \ | |
| + timestamps16 + '\n' + timestamps19 + '\n' \ | |
| + timestamps22 + '\n' + timestamps25 + '\n' \ | |
| + timestamps28 + '\n' + timestamps31 + '\n' | |
| dest_file.write(articlenumbers1) | |
| elif datetime.now().hour == 22: | |
| with open('newsarticlenumbers-22', 'w+') as source_file: | |
| with open('newsarticlenumbers-22', 'wb') as dest_file: | |
| articlenumbers1 = timestamps4 + '\n' + timestamps7 + '\n' \ | |
| + timestamps10 + '\n' + timestamps13 + '\n' \ | |
| + timestamps16 + '\n' + timestamps19 + '\n' \ | |
| + timestamps22 + '\n' + timestamps25 + '\n' \ | |
| + timestamps28 + '\n' + timestamps31 + '\n' | |
| dest_file.write(articlenumbers1) | |
| elif datetime.now().hour == 23: | |
| with open('newsarticlenumbers-23', 'w+') as source_file: | |
| with open('newsarticlenumbers-23', 'wb') as dest_file: | |
| articlenumbers1 = timestamps4 + '\n' + timestamps7 + '\n' \ | |
| + timestamps10 + '\n' + timestamps13 + '\n' \ | |
| + timestamps16 + '\n' + timestamps19 + '\n' \ | |
| + timestamps22 + '\n' + timestamps25 + '\n' \ | |
| + timestamps28 + '\n' + timestamps31 + '\n' | |
| dest_file.write(articlenumbers1) | |
| newstime1 = 'newstime-' + str(datetime.now().hour) | |
| newstime2 = 'newstime-' + str(datetime.now().hour + 1) | |
| newstime3 = 'newstime-' + str(datetime.now().hour + 2) | |
| newstime4 = 'newstime-' + str(datetime.now().hour + 3) | |
| newstime5 = 'newstime-' + str(datetime.now().hour + 4) | |
| newstime6 = 'newstime-' + str(datetime.now().hour + 5) | |
| newstime7 = 'newstime-' + str(datetime.now().hour + 6) | |
| newstime8 = 'newstime-' + str(datetime.now().hour + 7) | |
| newstime9 = 'newstime-' + str(datetime.now().hour + 8) | |
| newstime10 = 'newstime-' + str(datetime.now().hour + 9) | |
| newstime11 = 'newstime-' + str(datetime.now().hour + 10) | |
| newstime12 = 'newstime-' + str(datetime.now().hour + 11) | |
| newstime13 = 'newstime-' + str(datetime.now().hour + 12) | |
| newstime14 = 'newstime-' + str(datetime.now().hour + 13) | |
| newstime15 = 'newstime-' + str(datetime.now().hour + 14) | |
| newstime16 = 'newstime-' + str(datetime.now().hour + 15) | |
| newstime17 = 'newstime-' + str(datetime.now().hour + 16) | |
| newstime18 = 'newstime-' + str(datetime.now().hour + 17) | |
| newstime19 = 'newstime-' + str(datetime.now().hour + 18) | |
| newstime20 = 'newstime-' + str(datetime.now().hour + 19) | |
| newstime21 = 'newstime-' + str(datetime.now().hour + 20) | |
| newstime22 = 'newstime-' + str(datetime.now().hour + 21) | |
| newstime23 = 'newstime-' + str(datetime.now().hour + 22) | |
| newstime24 = 'newstime-' + str(datetime.now().hour + 23) | |
| newstimes = [ | |
| newstime1, | |
| newstime2, | |
| newstime3, | |
| newstime4, | |
| newstime5, | |
| newstime6, | |
| newstime7, | |
| newstime8, | |
| newstime9, | |
| newstime10, | |
| newstime11, | |
| newstime12, | |
| newstime13, | |
| newstime14, | |
| newstime15, | |
| newstime16, | |
| newstime17, | |
| newstime18, | |
| newstime19, | |
| newstime20, | |
| newstime21, | |
| newstime22, | |
| newstime23, | |
| newstime24, | |
| ] | |
| newsarticlenumbers1 = 'newsarticlenumbers-' + str(datetime.now().hour) | |
| newsarticlenumbers2 = 'newsarticlenumbers-' + str(datetime.now().hour | |
| + 1) | |
| newsarticlenumbers3 = 'newsarticlenumbers-' + str(datetime.now().hour | |
| + 2) | |
| newsarticlenumbers4 = 'newsarticlenumbers-' + str(datetime.now().hour | |
| + 3) | |
| newsarticlenumbers5 = 'newsarticlenumbers-' + str(datetime.now().hour | |
| + 4) | |
| newsarticlenumbers6 = 'newsarticlenumbers-' + str(datetime.now().hour | |
| + 5) | |
| newsarticlenumbers7 = 'newsarticlenumbers-' + str(datetime.now().hour | |
| + 6) | |
| newsarticlenumbers8 = 'newsarticlenumbers-' + str(datetime.now().hour | |
| + 7) | |
| newsarticlenumbers9 = 'newsarticlenumbers-' + str(datetime.now().hour | |
| + 8) | |
| newsarticlenumbers10 = 'newsarticlenumbers-' + str(datetime.now().hour | |
| + 9) | |
| newsarticlenumbers11 = 'newsarticlenumbers-' + str(datetime.now().hour | |
| + 10) | |
| newsarticlenumbers12 = 'newsarticlenumbers-' + str(datetime.now().hour | |
| + 11) | |
| newsarticlenumbers13 = 'newsarticlenumbers-' + str(datetime.now().hour | |
| + 12) | |
| newsarticlenumbers14 = 'newsarticlenumbers-' + str(datetime.now().hour | |
| + 13) | |
| newsarticlenumbers15 = 'newsarticlenumbers-' + str(datetime.now().hour | |
| + 14) | |
| newsarticlenumbers16 = 'newsarticlenumbers-' + str(datetime.now().hour | |
| + 15) | |
| newsarticlenumbers17 = 'newsarticlenumbers-' + str(datetime.now().hour | |
| + 16) | |
| newsarticlenumbers18 = 'newsarticlenumbers-' + str(datetime.now().hour | |
| + 17) | |
| newsarticlenumbers19 = 'newsarticlenumbers-' + str(datetime.now().hour | |
| + 18) | |
| newsarticlenumbers20 = 'newsarticlenumbers-' + str(datetime.now().hour | |
| + 19) | |
| newsarticlenumbers21 = 'newsarticlenumbers-' + str(datetime.now().hour | |
| + 20) | |
| newsarticlenumbers22 = 'newsarticlenumbers-' + str(datetime.now().hour | |
| + 21) | |
| newsarticlenumbers23 = 'newsarticlenumbers-' + str(datetime.now().hour | |
| + 22) | |
| newsarticlenumbers24 = 'newsarticlenumbers-' + str(datetime.now().hour | |
| + 23) | |
| newsarticlenumbers = [ | |
| newsarticlenumbers1, | |
| newsarticlenumbers2, | |
| newsarticlenumbers3, | |
| newsarticlenumbers4, | |
| newsarticlenumbers5, | |
| newsarticlenumbers6, | |
| newsarticlenumbers7, | |
| newsarticlenumbers8, | |
| newsarticlenumbers9, | |
| newsarticlenumbers10, | |
| newsarticlenumbers11, | |
| newsarticlenumbers12, | |
| newsarticlenumbers13, | |
| newsarticlenumbers14, | |
| newsarticlenumbers15, | |
| newsarticlenumbers16, | |
| newsarticlenumbers17, | |
| newsarticlenumbers18, | |
| newsarticlenumbers19, | |
| newsarticlenumbers20, | |
| newsarticlenumbers21, | |
| newsarticlenumbers22, | |
| newsarticlenumbers23, | |
| newsarticlenumbers24, | |
| ] | |
| for times in newstimes: | |
| if os.path.exists(times): | |
| with open('newstimesall', 'w+') as dest_file: | |
| with open(times) as source_file: | |
| dest_file.write(source_file.read()) | |
| with open('newstimesall', 'rb') as source_file: | |
| times1 = source_file.read() | |
| times2 = os.path.getsize('newstimesall') | |
| for articlenumbers in newsarticlenumbers: | |
| if os.path.exists(articlenumbers): | |
| with open('newsarticlenumbersall', 'w+') as dest_file: | |
| with open(articlenumbers) as source_file: | |
| dest_file.write(source_file.read()) | |
| with open('newsarticlenumbersall', 'rb') as source_file: | |
| articlenumbers1 = source_file.read() | |
| articlenumbers2a = articlenumbers1.count('national') | |
| articlenumbers2b = hex(articlenumbers2a)[2:].zfill(8) | |
| articlenumbers3a = articlenumbers1.count('international') | |
| articlenumbers3b = hex(articlenumbers3a)[2:].zfill(8) | |
| articlenumbers4a = articlenumbers1.count('sports') | |
| articlenumbers4b = hex(articlenumbers4a)[2:].zfill(8) | |
| articlenumbers5a = articlenumbers1.count('entertainment') | |
| articlenumbers5b = hex(articlenumbers5a)[2:].zfill(8) | |
| articlenumbers6a = articlenumbers1.count('business') | |
| articlenumbers6b = hex(articlenumbers6a)[2:].zfill(8) | |
| articlenumbers7a = articlenumbers1.count('science') | |
| articlenumbers7b = hex(articlenumbers7a)[2:].zfill(8) | |
| articlenumbers8a = articlenumbers1.count('health') | |
| articlenumbers8b = hex(articlenumbers8a)[2:].zfill(8) | |
| articlenumbers9a = articlenumbers1.count('technology') | |
| articlenumbers9b = hex(articlenumbers9a)[2:].zfill(8) | |
| padding1 = '00' | |
| padding2 = padding1 * 4 | |
| padding3 = 'FF' | |
| padding4 = padding3 * 10 | |
| padding5 = padding1 * 7 | |
| padding6 = padding1 * 14 | |
| padding7 = padding1 * 15 | |
| padding8 = padding1 * 2 | |
| wiitimestamptype1 = wiitimestamp1[:-2] | |
| wiitimestamptype2 = wiitimestamp11[:-2] | |
| countrycode = '31' | |
| sequentialnumbers = '010203040506' | |
| unknownbytes1 = '0100001E' | |
| unknownbytes2 = '0C' | |
| u32_1a = 192 + titlesize1b + titlesize2b + titlesize3b + titlesize4b \ | |
| + titlesize5b + titlesize6b + titlesize7b + titlesize8b \ | |
| + titlesize9b + titlesize10b + titlesize11b # u32 offset after the titles. | |
| u32_1b = hex(u32_1a)[2:].zfill(8) | |
| u32_2a = len(glob.glob('*-3')) # u32 number of JPGs I think. If this article has been updated before and also has a JPG, this number includes those as well. | |
| u32_2b = hex(u32_2a)[2:].zfill(8) | |
| u32_3a = int(1) # Unknown (01) | |
| u32_3b = hex(u32_3a)[2:].zfill(8) | |
| u32_4a = int(1) # Unknown (01) | |
| u32_4b = hex(u32_3a)[2:].zfill(8) | |
| u32_6a = len(glob.glob('*-13')) # u32 number of locations. | |
| u32_6b = hex(u32_6a)[2:].zfill(8) | |
| u32_10a = int(31457280) # Unknown (01E00000) | |
| u32_10b = hex(u32_10a)[2:].zfill(8) | |
| u32_10c = int(0) | |
| u32_10d = hex(u32_10c)[2:].zfill(8) | |
| u32_10e = u32_10d + u32_10b | |
| u32_11a = int(11) # Unknown (0B) | |
| u32_11b = hex(u32_11a)[2:].zfill(8) | |
| u32_12a = int(104) # Unknown (68) | |
| u32_12b = hex(u32_12a)[2:].zfill(8) | |
| u32_13a = titlesize1b # u32 for the size of the 1st headline. | |
| u32_13b = hex(u32_13a)[2:].zfill(8) | |
| u32_14a = int(192) # u32 offset for the 1st headline. Should always be C0. | |
| u32_14b = hex(u32_14a)[2:].zfill(8) | |
| u32_15a = titlesize2b # u32 for the size of the 2nd headline. | |
| u32_15b = hex(u32_15a)[2:].zfill(8) | |
| u32_16a = 192 + titlesize1b # u32 offset for the 2nd headline. | |
| u32_16b = hex(u32_16a)[2:].zfill(8) | |
| u32_17a = titlesize3b # u32 for the size of the 3rd headline. | |
| u32_17b = hex(u32_17a)[2:].zfill(8) | |
| u32_18a = u32_16a + titlesize2b # u32 offset for the 3rd headline. | |
| u32_18b = hex(u32_18a)[2:].zfill(8) | |
| u32_19a = titlesize4b # u32 for the size of the 4th headline. | |
| u32_19b = hex(u32_19a)[2:].zfill(8) | |
| u32_20a = u32_17a + titlesize3b # u32 offset for the 4th headline. | |
| u32_20b = hex(u32_20a)[2:].zfill(8) | |
| u32_21a = titlesize5b # u32 for the size of the 5th headline. | |
| u32_21b = hex(u32_21a)[2:].zfill(8) | |
| u32_22a = u32_20a + titlesize4b # u32 offset for the 5th headline. | |
| u32_22b = hex(u32_22a)[2:].zfill(8) | |
| u32_23a = titlesize6b # u32 for the size of the 6th headline. | |
| u32_23b = hex(u32_23a)[2:].zfill(8) | |
| u32_24a = u32_22a + titlesize5b # u32 offset for the 6th headline. | |
| u32_24b = hex(u32_24a)[2:].zfill(8) | |
| u32_25a = titlesize7b # u32 for the size of the 7th headline. | |
| u32_25b = hex(u32_25a)[2:].zfill(8) | |
| u32_26a = u32_24a + titlesize6b # u32 offset for the 7th headline. | |
| u32_26b = hex(u32_26a)[2:].zfill(8) | |
| u32_27a = titlesize8b # u32 for the size of the 8th headline. | |
| u32_27b = hex(u32_27a)[2:].zfill(8) | |
| u32_28a = u32_26a + titlesize7b # u32 offset for the 8th headline. | |
| u32_28b = hex(u32_28a)[2:].zfill(8) | |
| u32_29a = titlesize9b # u32 for the size of the 9th headline. | |
| u32_29b = hex(u32_29a)[2:].zfill(8) | |
| u32_30a = u32_28a + titlesize8b # u32 offset for the 9th headline. | |
| u32_30b = hex(u32_30a)[2:].zfill(8) | |
| u32_31a = titlesize10b # u32 for the size of the 10th headline. | |
| u32_31b = hex(u32_31a)[2:].zfill(8) | |
| u32_32a = u32_30a + titlesize9b # u32 offset for the 10th headline. | |
| u32_32b = hex(u32_32a)[2:].zfill(8) | |
| u32_33a = titlesize11b # u32 for the size of the 11th headline. | |
| u32_33b = hex(u32_33a)[2:].zfill(8) | |
| u32_34a = u32_32a + titlesize10b # u32 offset for the 11th headline. | |
| u32_34b = hex(u32_34a)[2:].zfill(8) | |
| u32_3a = u32_34a + 146 + times2 # u32 offset after the timestamp list 1. | |
| u32_3b = hex(u32_3a)[2:].zfill(8) | |
| year = date.today().year | |
| copyright1 = \ | |
| 'Copyright %s The Associated Press. All rights reserved. This material may not be published, broadcast, rewritten or redistributed.' \ | |
| % year | |
| copyright2 = copyright1.encode('utf-16be') | |
| copyright3 = len(copyright2) | |
| copyright4 = hex(copyright3)[2:].zfill(8) | |
| with open('newslocations', 'w+') as source_file: | |
| with open('newslocations', 'wb') as dest_file: | |
| for fname in glob.glob('*-13'): | |
| with open(fname, 'rb') as source_file: | |
| withlocations1 = "\n" | |
| dest_file.write(source_file.read()) | |
| dest_file.write(withlocations1) | |
| with open('newslocations', 'rb') as source_file: | |
| locationsread1 = source_file.readlines() | |
| locationsread2 = len(locationsread1) | |
| locationsread3 = locationsread2 * 16 | |
| countoffset1 = u32_34a + u32_33a + 14 + 132 + 660 + times2 + 484 + 192 \ | |
| + titlesize1b + titlesize2b + titlesize3b + titlesize4b \ | |
| + titlesize5b + titlesize6b + titlesize7b + titlesize8b \ | |
| + titlesize9b + titlesize10b + titlesize11b + locationsread3 + 20 \ | |
| + titlesize1b + articlesize1b + captionssize1c + copyright3 \ | |
| + titlesize2b + articlesize2b + captionssize2c + copyright3 \ | |
| + titlesize3b + articlesize3b + captionssize3c + copyright3 \ | |
| + titlesize4b + articlesize4b + captionssize4c + copyright3 \ | |
| + titlesize5b + articlesize5b + captionssize5c + copyright3 \ | |
| + titlesize6b + articlesize6b + captionssize6c + copyright3 \ | |
| + titlesize7b + articlesize7b + captionssize7c + copyright3 \ | |
| + titlesize8b + articlesize8b + captionssize8c + copyright3 \ | |
| + titlesize9b + articlesize9b + captionssize9c + copyright3 \ | |
| + titlesize10b + articlesize10b + captionssize10c + copyright3 \ | |
| + titlesize11b + articlesize11b + captionssize11c | |
| countoffset1a = u32_34a + u32_33a + 14 + 132 + 660 + times2 + 192 \ | |
| + locationsread3 # This is to build the first article offset. | |
| with open('newslocations', 'rb') as source_file: | |
| locationsread1a = source_file.readlines() | |
| locationsread1b = len(locationsread1a) | |
| if locationsread1b >= 1: | |
| locationsreadline1a = locationsread1a[0] | |
| locationsreadline1b = countoffset1 | |
| locationsreadline1c = hex(locationsreadline1b)[2:].zfill(8) | |
| else: | |
| locationsreadline1b = int(0) | |
| locationsreadline1c = int(0) | |
| if locationsread1b >= 2: | |
| locationsreadline2a = locationsread1a[1] | |
| locationsreadline2b = locationsreadline1b + 12 \ | |
| + len(locationsreadline1a) | |
| locationsreadline2c = hex(locationsreadline2b)[2:].zfill(8) | |
| else: | |
| locationsreadline2b = int(0) | |
| locationsreadline2c = int(0) | |
| if locationsread1b >= 3: | |
| locationsreadline3a = locationsread1a[2] | |
| locationsreadline3b = locationsreadline2b + 12 \ | |
| + len(locationsreadline2a) | |
| locationsreadline3c = hex(locationsreadline3b)[2:].zfill(8) | |
| else: | |
| locationsreadline3b = int(0) | |
| locationsreadline3c = int(0) | |
| if locationsread1b >= 4: | |
| locationsreadline4a = locationsread1a[3] | |
| locationsreadline4b = locationsreadline3b + 12 \ | |
| + len(locationsreadline3a) | |
| locationsreadline4c = hex(locationsreadline4b)[2:].zfill(8) | |
| else: | |
| locationsreadline4b = int(0) | |
| locationsreadline4c = int(0) | |
| if locationsread1b >= 5: | |
| locationsreadline5a = locationsread1a[4] | |
| locationsreadline5b = locationsreadline4b + 12 \ | |
| + len(locationsreadline4a) | |
| locationsreadline5c = hex(locationsreadline5b)[2:].zfill(8) | |
| else: | |
| locationsreadline5b = int(0) | |
| locationsreadline5c = int(0) | |
| if locationsread1b >= 6: | |
| locationsreadline6a = locationsread1a[5] | |
| locationsreadline6b = locationsreadline5b + 12 \ | |
| + len(locationsreadline5a) | |
| locationsreadline6c = hex(locationsreadline6b)[2:].zfill(8) | |
| else: | |
| locationsreadline6b = int(0) | |
| locationsreadline6c = int(0) | |
| if locationsread1b >= 7: | |
| locationsreadline7a = locationsread1a[6] | |
| locationsreadline7b = locationsreadline6b + 12 \ | |
| + len(locationsreadline6a) | |
| locationsreadline7c = hex(locationsreadline7b)[2:].zfill(8) | |
| else: | |
| locationsreadline7b = int(0) | |
| locationsreadline7c = int(0) | |
| if locationsread1b >= 8: | |
| locationsreadline8a = locationsread1a[7] | |
| locationsreadline8b = locationsreadline7b + 12 \ | |
| + len(locationsreadline7a) | |
| locationsreadline8c = hex(locationsreadline8b)[2:].zfill(8) | |
| else: | |
| locationsreadline8b = int(0) | |
| locationsreadline8c = int(0) | |
| if locationsread1b >= 9: | |
| locationsreadline9a = locationsread1a[8] | |
| locationsreadline9b = locationsreadline8b + 12 \ | |
| + len(locationsreadline8a) | |
| locationsreadline9c = hex(locationsreadline9b)[2:].zfill(8) | |
| else: | |
| locationsreadline9b = int(0) | |
| locationsreadline9c = int(0) | |
| if locationsread1b >= 10: | |
| locationsreadline10a = locationsread1a[9] | |
| locationsreadline10b = locationsreadline9b + 12 \ | |
| + len(locationsreadline9a) | |
| locationsreadline10c = hex(locationsreadline10b)[2:].zfill(8) | |
| else: | |
| locationsreadline10b = int(0) | |
| locationsreadline10c = int(0) | |
| if locationsread1b >= 11: | |
| locationsreadline11a = locationsread1a[10] | |
| locationsreadline11b = locationsreadline10b + 12 \ | |
| + len(locationsreadline10a) | |
| locationsreadline11c = hex(locationsreadline11b)[2:].zfill(8) | |
| else: | |
| locationsreadline11b = int(0) | |
| locationsreadline11c = int(0) | |
| countoffset2 = hex(countoffset1)[2:].zfill(8) | |
| countoffset3 = countoffset1 + len(topicsap1b) | |
| countoffset4 = hex(countoffset3)[2:].zfill(8) | |
| countoffset5 = countoffset3 + len(topicsap2b) | |
| countoffset6 = hex(countoffset5)[2:].zfill(8) | |
| countoffset7 = countoffset5 + len(topicsap3b) | |
| countoffset8 = hex(countoffset7)[2:].zfill(8) | |
| countoffset9 = countoffset7 + len(topicsap4b) | |
| countoffset10 = hex(countoffset9)[2:].zfill(8) | |
| countoffset11 = countoffset9 + len(topicsap5b) | |
| countoffset12 = hex(countoffset11)[2:].zfill(8) | |
| countoffset13 = countoffset11 + len(topicsap6b) | |
| countoffset14 = hex(countoffset13)[2:].zfill(8) | |
| countoffset15 = countoffset13 + len(topicsap7b) | |
| countoffset16 = hex(countoffset15)[2:].zfill(8) | |
| countoffset17 = u32_34a + u32_33a + 14 + 132 + 660 + times2 | |
| countoffset18 = countoffset17 + titlesize1b | |
| countoffset19 = countoffset18 + articlesize1b | |
| countoffset20 = countoffset19 + titlesize2b | |
| countoffset21 = countoffset20 + articlesize2b | |
| countoffset22 = countoffset21 + titlesize3b | |
| countoffset23 = countoffset22 + articlesize3b | |
| countoffset24 = countoffset23 + titlesize4b | |
| countoffset25 = countoffset24 + articlesize4b | |
| countoffset26 = countoffset25 + titlesize5b | |
| countoffset27 = countoffset26 + articlesize5b | |
| countoffset28 = countoffset27 + titlesize6b | |
| countoffset29 = countoffset28 + articlesize6b | |
| countoffset30 = countoffset29 + titlesize7b | |
| countoffset31 = countoffset30 + articlesize7b | |
| countoffset32 = countoffset31 + titlesize8b | |
| countoffset33 = countoffset32 + articlesize8b | |
| countoffset34 = countoffset33 + titlesize9b | |
| countoffset35 = countoffset34 + articlesize9b | |
| countoffset36 = countoffset35 + titlesize10b | |
| countoffset37 = countoffset36 + articlesize10b | |
| countoffset38 = countoffset37 + titlesize11b | |
| countoffset39 = countoffset38 + articlesize11b | |
| countoffset40 = countoffset1 + len(topicsap1b) + len(topicsap3b) \ | |
| + len(topicsap4b) + len(topicsap5b) + len(topicsap6b) \ | |
| + len(topicsap7b) + len(topicsap8b) + locationsreadline1b \ | |
| + locationsreadline2b + locationsreadline3b \ | |
| + locationsreadline4b + locationsreadline5b \ | |
| + locationsreadline6b + locationsreadline7b \ | |
| + locationsreadline8b + locationsreadline9b \ | |
| + locationsreadline10b + locationsreadline11b + copyright3 | |
| buildfile5 = wiitimestamp1 + '00000100' + wiitimestamp1 \ | |
| + wiitimestamp1[:-2] + hex(titlesize1b)[2:].zfill(8) + hex(articlesize1b)[2:].zfill(8) + hex(countoffset18)[2:].zfill(8) + '00000100' + '00000000' + '00000100' \ | |
| + wiitimestamp2 + '00000200' + wiitimestamp2 + wiitimestamp2[:-2] + hex(titlesize2b)[2:].zfill(8) + hex(articlesize2b)[2:].zfill(8) + hex(countoffset18)[2:].zfill(8) + '00000200' + '00000000' + '00000200' \ | |
| + wiitimestamp3 + '00000300' + wiitimestamp3 + wiitimestamp3[:-2] + hex(titlesize3b)[2:].zfill(8) + hex(articlesize3b)[2:].zfill(8) + hex(countoffset20)[2:].zfill(8) + '00000300' + '00000000' + '00000300' \ | |
| + wiitimestamp4 + '00000400' + wiitimestamp4 + wiitimestamp4[:-2] + hex(titlesize4b)[2:].zfill(8) + hex(articlesize4b)[2:].zfill(8) + hex(countoffset22)[2:].zfill(8) + '00000400' + '00000000' + '00000400' \ | |
| + wiitimestamp5 + '00000500' + wiitimestamp5 + wiitimestamp5[:-2] + hex(titlesize5b)[2:].zfill(8) + hex(articlesize5b)[2:].zfill(8) + hex(countoffset24)[2:].zfill(8) + '00000500' + '00000000' + '00000500' \ | |
| + wiitimestamp6 + '00000600' + wiitimestamp6 + wiitimestamp6[:-2] + hex(titlesize6b)[2:].zfill(8) + hex(articlesize6b)[2:].zfill(8) + hex(countoffset26)[2:].zfill(8) + '00000600' + '00000000' + '00000600' \ | |
| + wiitimestamp7 + '00000700' + wiitimestamp7 + wiitimestamp7[:-2] + hex(titlesize7b)[2:].zfill(8) + hex(articlesize7b)[2:].zfill(8) + hex(countoffset28)[2:].zfill(8) + '00000700' + '00000000' + '00000700' \ | |
| + wiitimestamp8 + '00000800' + wiitimestamp8 + wiitimestamp8[:-2] + hex(titlesize8b)[2:].zfill(8) + hex(articlesize8b)[2:].zfill(8) + hex(countoffset30)[2:].zfill(8) + '00000800' + '00000000' + '00000800' \ | |
| + wiitimestamp9 + '00000900' + wiitimestamp9 + wiitimestamp9[:-2] + hex(titlesize9b)[2:].zfill(8) + hex(articlesize9b)[2:].zfill(8) + hex(countoffset32)[2:].zfill(8) + '00000900' + '00000000' + '00000900' \ | |
| + wiitimestamp10 + '00000A00' + wiitimestamp10 + wiitimestamp10[:-2] + hex(titlesize10b)[2:].zfill(8) + hex(articlesize10b)[2:].zfill(8) + hex(countoffset34)[2:].zfill(8) + '00000A00' + '00000000' + '00000A00' \ | |
| + wiitimestamp11 + '00000B00' + wiitimestamp11 + wiitimestamp11[:-2] + hex(titlesize11b)[2:].zfill(8) + hex(articlesize11b)[2:].zfill(8) + hex(countoffset36)[2:].zfill(8) + '00000B00' + '00000000' + '00000B00' | |
| u32_5a = u32_4a + len(buildfile5) # u32 offset after the timestamp list 2. | |
| u32_5b = hex(u32_5a)[2:].zfill(8) | |
| u32_7a = u32_5a + 24 # u32 offset before the location offset list. | |
| u32_7b = hex(u32_7a)[2:].zfill(8) | |
| u32_8a = int(11) # u32 number of article entries. | |
| u32_8b = hex(u32_8a)[2:].zfill(8) | |
| unknown = '0404000000000000000000000000000000000000A0' | |
| u32_9a = u32_6a * 16 # u32 offset before the entries list. | |
| u32_9a = u32_9a + u32_5a | |
| u32_9b = hex(u32_9a)[2:].zfill(8) | |
| if os.path.exists(captionssize1a): | |
| countoffset41a = u32_34a + u32_33a + 14 + 132 + 660 + times2 \ | |
| + 192 + locationsread3 + titlesize1b \ | |
| + articlesize1b # This is to build the 1st copyright offset. | |
| countoffset41b = hex(countoffset41a)[2:].zfill(8) | |
| countoffset42a = countoffset41a + copyright3 # This is to build the 1st caption offset. | |
| countoffset42b = hex(countoffset42a)[2:].zfill(8) | |
| countoffset43a = countoffset1 + copyright3 + locationsize1b \ | |
| + locationsize2b + locationsize3b + locationsize4b \ | |
| + locationsize5b + locationsize6b + locationsize7b \ | |
| + locationsize8b + locationsize9b + locationsize10b \ | |
| + locationsize11b # This is to build the 1st picture offset. | |
| countoffset43b = hex(countoffset43a)[2:].zfill(8) | |
| else: | |
| countoffset41b = int(0) | |
| countoffset42b = int(0) | |
| countoffset43b = int(0) | |
| if os.path.exists(captionssize2a): | |
| countoffset44a = countoffset42a + captionssize1a + titlesize2b \ | |
| + articlesize2b # This is to build the 2nd copyright offset. | |
| countoffset44b = hex(countoffset44a)[2:].zfill(8) | |
| countoffset45a = countoffset44a + copyright3 # This is to build the 2nd caption offset. | |
| countoffset45b = hex(countoffset45a)[2:].zfill(8) | |
| countoffset46a = countoffset43a + 2 + picturessize1c # This is to build the 2nd picture offset. | |
| countoffset46b = hex(countoffset46a)[2:].zfill(8) | |
| else: | |
| countoffset44b = int(0) | |
| countoffset45b = int(0) | |
| countoffset46b = int(0) | |
| if os.path.exists(captionssize3a): | |
| countoffset47a = countoffset45a + captionssize2a + titlesize3b \ | |
| + articlesize3b # This is to build the 3rd copyright offset. | |
| countoffset47b = hex(countoffset47a)[2:].zfill(8) | |
| countoffset48a = countoffset47a + copyright3 # This is to build the 2nd caption offset. | |
| countoffset48b = hex(countoffset48a)[2:].zfill(8) | |
| countoffset49a = countoffset46a + 2 + picturessize2c # This is to build the 3rd picture offset. | |
| countoffset49b = hex(countoffset49a)[2:].zfill(8) | |
| else: | |
| countoffset47b = int(0) | |
| countoffset48b = int(0) | |
| countoffset49b = int(0) | |
| if os.path.exists(captionssize4a): | |
| countoffset50a = countoffset48a + captionssize3a + titlesize4b \ | |
| + articlesize4b # This is to build the 4th copyright offset. | |
| countoffset50b = hex(countoffset50a)[2:].zfill(8) | |
| countoffset51a = countoffset50a + copyright3 # This is to build the 4th caption offset. | |
| countoffset51b = hex(countoffset51a)[2:].zfill(8) | |
| countoffset52a = countoffset49a + 2 + picturessize3c # This is to build the 4th picture offset. | |
| countoffset52b = hex(countoffset52a)[2:].zfill(8) | |
| else: | |
| countoffset50b = int(0) | |
| countoffset51b = int(0) | |
| countoffset52b = int(0) | |
| if os.path.exists(captionssize5a): | |
| countoffset53a = countoffset51a + captionssize4a + titlesize5b \ | |
| + articlesize5b # This is to build the 5th copyright offset. | |
| countoffset53b = hex(countoffset53a)[2:].zfill(8) | |
| countoffset54a = countoffset53a + copyright3 # This is to build the 5th caption offset. | |
| countoffset54b = hex(countoffset54a)[2:].zfill(8) | |
| countoffset55a = countoffset52a + 2 + picturessize4c # This is to build the 5th picture offset. | |
| countoffset55b = hex(countoffset55a)[2:].zfill(8) | |
| else: | |
| countoffset53b = int(0) | |
| countoffset54b = int(0) | |
| countoffset55b = int(0) | |
| if os.path.exists(captionssize6a): | |
| countoffset56a = countoffset54a + captionssize5a + titlesize6b \ | |
| + articlesize6b # This is to build the 6th copyright offset. | |
| countoffset56b = hex(countoffset56a)[2:].zfill(8) | |
| countoffset57a = countoffset56a + copyright3 # This is to build the 6th caption offset. | |
| countoffset57b = hex(countoffset57a)[2:].zfill(8) | |
| countoffset58a = countoffset55a + 2 + picturessize5c # This is to build the 6th picture offset. | |
| countoffset58b = hex(countoffset58a)[2:].zfill(8) | |
| else: | |
| countoffset56b = int(0) | |
| countoffset57b = int(0) | |
| countoffset58b = int(0) | |
| if os.path.exists(captionssize7a): | |
| countoffset59a = countoffset57a + captionssize6a + titlesize7b \ | |
| + articlesize7b # This is to build the 7th copyright offset. | |
| countoffset59b = hex(countoffset59a)[2:].zfill(8) | |
| countoffset60a = countoffset59a + copyright3 # This is to build the 7th caption offset. | |
| countoffset60b = hex(countoffset60a)[2:].zfill(8) | |
| countoffset61a = countoffset58a + 2 + picturessize6c # This is to build the 7th picture offset. | |
| countoffset61b = hex(countoffset61a)[2:].zfill(8) | |
| else: | |
| countoffset59b = int(0) | |
| countoffset60b = int(0) | |
| countoffset61b = int(0) | |
| if os.path.exists(captionssize8a): | |
| countoffset62a = countoffset60a + captionssize7a + titlesize8b \ | |
| + articlesize8b # This is to build the 8th copyright offset. | |
| countoffset62b = hex(countoffset62a)[2:].zfill(8) | |
| countoffset63a = countoffset62a + copyright3 # This is to build the 8th caption offset. | |
| countoffset63b = hex(countoffset63a)[2:].zfill(8) | |
| countoffset64a = countoffset61a + 2 + picturessize7c # This is to build the 8th picture offset. | |
| countoffset64b = hex(countoffset64a)[2:].zfill(8) | |
| else: | |
| countoffset62b = int(0) | |
| countoffset63b = int(0) | |
| countoffset64b = int(0) | |
| if os.path.exists(captionssize9a): | |
| countoffset65a = countoffset63a + captionssize8a + titlesize9b \ | |
| + articlesize9b # This is to build the 9th copyright offset. | |
| countoffset65b = hex(countoffset65a)[2:].zfill(8) | |
| countoffset66a = countoffset65a + copyright3 # This is to build the 9th caption offset. | |
| countoffset66b = hex(countoffset66a)[2:].zfill(8) | |
| countoffset67a = countoffset64a + 2 + picturessize8c # This is to build the 9th picture offset. | |
| countoffset67b = hex(countoffset67a)[2:].zfill(8) | |
| else: | |
| countoffset65b = int(0) | |
| countoffset66b = int(0) | |
| countoffset67b = int(0) | |
| if os.path.exists(captionssize10a): | |
| countoffset68a = countoffset66a + captionssize9a + titlesize10b \ | |
| + articlesize10b # This is to build the 10th copyright offset. | |
| countoffset68b = hex(countoffset68a)[2:].zfill(8) | |
| countoffset69a = countoffset68a + copyright3 # This is to build the 10th caption offset. | |
| countoffset69b = hex(countoffset69a)[2:].zfill(8) | |
| countoffset70a = countoffset67a + 2 + picturessize9c # This is to build the 10th picture offset. | |
| countoffset70b = hex(countoffset70a)[2:].zfill(8) | |
| else: | |
| countoffset68b = int(0) | |
| countoffset69b = int(0) | |
| countoffset70b = int(0) | |
| if os.path.exists(captionssize11a): | |
| countoffset71a = countoffset69a + captionssize10a + titlesize11b \ | |
| + articlesize11b # This is to build the 11th copyright offset. | |
| countoffset71b = hex(countoffset71a)[2:].zfill(8) | |
| countoffset72a = countoffset71a + copyright3 # This is to build the 11th caption offset. | |
| countoffset72b = hex(countoffset72a)[2:].zfill(8) | |
| countoffset73a = countoffset70a + 2 + picturessize10c # This is to build the 11th picture offset. | |
| countoffset73b = hex(countoffset73a)[2:].zfill(8) | |
| else: | |
| countoffset71b = int(0) | |
| countoffset72b = int(0) | |
| countoffset73b = int(0) | |
| countoffset74 = countoffset1 + len(topicsap1b) | |
| countoffset75 = countoffset74 + len(topicsap3b) | |
| countoffset76 = countoffset75 + len(topicsap4b) | |
| countoffset77 = countoffset76 + len(topicsap5b) | |
| countoffset78 = countoffset77 + len(topicsap6b) | |
| countoffset79 = countoffset78 + len(topicsap7b) | |
| countoffset80 = countoffset79 + len(topicsap8b) | |
| def buildfiletable2( | |
| number1, | |
| number2, | |
| number3, | |
| number4, | |
| number5, | |
| number6, | |
| ): | |
| buildfile1 = wiitimestamptype1 + '00000000' + wiitimestamp1 \ | |
| + wiitimestamp1[-2:] + u32_ % sb % number1 + countoffset % s \ | |
| % number2 + articlesize % sb % number3 + countoffset % s \ | |
| % number4 + '%s' % number5 + '00000000' + '0%s000000' % number6 | |
| buildfile2 = 'newsbuildfile-' + number3 | |
| with open(buildfile2, 'w+') as source_file: | |
| with open(buildfile2, 'wb') as dest_file: | |
| dest_file.write(buildfile1) | |
| buildfiletable2( | |
| '13', | |
| '17', | |
| '1', | |
| '18', | |
| '00000200', | |
| '1', | |
| ) | |
| buildfiletable2( | |
| '15', | |
| '19', | |
| '2', | |
| '20', | |
| '00000300', | |
| '2', | |
| ) | |
| buildfiletable2( | |
| '17', | |
| '21', | |
| '3', | |
| '22', | |
| '00000400', | |
| '3', | |
| ) | |
| buildfiletable2( | |
| '19', | |
| '23', | |
| '4', | |
| '24', | |
| '00000500', | |
| '4', | |
| ) | |
| buildfiletable2( | |
| '21', | |
| '25', | |
| '5', | |
| '26', | |
| '00000600', | |
| '5', | |
| ) | |
| buildfiletable2( | |
| '23', | |
| '27', | |
| '6', | |
| '28', | |
| '00000700', | |
| '6', | |
| ) | |
| buildfiletable2( | |
| '25', | |
| '29', | |
| '7', | |
| '30', | |
| '00000800', | |
| '7', | |
| ) | |
| buildfiletable2( | |
| '27', | |
| '31', | |
| '8', | |
| '32', | |
| '00000900', | |
| '8', | |
| ) | |
| buildfiletable2( | |
| '29', | |
| '33', | |
| '9', | |
| '34', | |
| '00000A00', | |
| '9', | |
| ) | |
| buildfiletable2( | |
| '31', | |
| '35', | |
| '10', | |
| '36', | |
| '00000B00', | |
| 'A', | |
| ) | |
| buildfiletable2( | |
| '33', | |
| '37', | |
| '11', | |
| '38', | |
| '04000000', | |
| 'B', | |
| ) | |
| buildfiles = [ | |
| 'newsbuildfile-1', | |
| 'newsbuildfile-2', | |
| 'newsbuildfile-3', | |
| 'newsbuildfile-4', | |
| 'newsbuildfile-5', | |
| 'newsbuildfile-6', | |
| 'newsbuildfile-7', | |
| 'newsbuildfile-8', | |
| 'newsbuildfile-9', | |
| 'newsbuildfile-10', | |
| 'newsbuildfile-11', | |
| ] | |
| with open('newsbuildfiles', 'w+') as dest_file: | |
| for buildfilesname in buildfiles: | |
| with open(buildfilesname, 'rb') as source_file: | |
| dest_file.write(source_file.read()) | |
| with open('newsbuildfiles', 'rb') as source_file: | |
| buildfiles1 = os.path.getsize('newsbuildfiles') | |
| buildfiles2 = source_file.read() | |
| with open('titles', 'rb') as source_file: | |
| titles1 = source_file.read() | |
| buildfilething = countoffset1 - copyright3 | |
| buildfile1 = chr(int(padding1)) + chr(int(wiitimestamp1)) + chr(int(wiitimestamptype2)) + chr(int(countrycode)) \ | |
| + chr(int(padding2)) + chr(int(wiitimestamptype1)) + chr(int(sequentialnumbers)) + chr(int(padding4)) \ | |
| + chr(int(unknownbytes1)) + chr(int(padding5)) + chr(int(unknownbytes2)) + chr(int(u32_1b)) + chr(int(u32_2b)) \ | |
| + chr(int(u32_3b)) + chr(int(u32_4b)) + chr(int(u32_5b)) + chr(int(u32_6b)) + chr(int(u32_7b)) + chr(int(u32_8b)) + chr(int(u32_9b)) \ | |
| + chr(int(u32_10e)) + chr(int(u32_11b)) + chr(int(u32_12b)) + chr(int(u32_13b)) + chr(int(u32_14b)) + chr(int(u32_15b)) \ | |
| + chr(int(u32_16b)) + chr(int(u32_17b)) + chr(int(u32_18b)) + chr(int(u32_19b)) + chr(int(u32_20b)) + chr(int(u32_21b)) \ | |
| + chr(int(u32_22b)) + chr(int(u32_23b)) + chr(int(u32_24b)) + chr(int(u32_25b)) + chr(int(u32_26b)) + chr(int(u32_27b)) \ | |
| + chr(int(u32_28b)) + chr(int(u32_29b)) + chr(int(u32_30b)) + chr(int(u32_31b)) + chr(int(u32_32b)) + chr(int(u32_33b)) \ | |
| + chr(int(u32_34b)) # This is to build the header. | |
| buildfile2 = titles1 + chr(int(padding6)) # This is to build the titles. | |
| buildfile3 = chr(int(padding2)) + chr(int(countoffset1)) + chr(int(articlenumbers2b)) \ | |
| + chr(int(countoffset74)) + chr(int(articlenumbers3b)) + chr(int(countoffset75)) \ | |
| + chr(int(articlenumbers4b)) + chr(int(countoffset76)) + chr(int(articlenumbers5b)) \ | |
| + chr(int(countoffset77)) + chr(int(articlenumbers6b)) + chr(int(countoffset78)) \ | |
| + chr(int(countoffset79)) + chr(int(articlenumbers7b)) + chr(int(articlenumbers8b)) \ | |
| + chr(int(articlenumbers9b)) + chr(int(countoffset80)) # This is to build the topics list. | |
| buildfile4 = chr(int(countoffset2)) + chr(int(times1)) # This is to build the 1st table for time. | |
| buildfile6 = chr(int(locationsreadline1c)) + chr(int(padding2)) + chr(int(locationsreadline2c)) \ | |
| + chr(int(padding2)) + chr(int(locationsreadline3c)) + chr(int(padding2)) + chr(int(locationsreadline4c)) \ | |
| + chr(int(padding2)) + chr(int(locationsreadline5c)) + chr(int(padding2)) + chr(int(locationsreadline6c)) \ | |
| + chr(int(padding2)) + chr(int(locationsreadline7c)) + chr(int(padding2)) + chr(int(locationsreadline8c)) \ | |
| + chr(int(padding2)) + chr(int(locationsreadline9c)) + chr(int(padding2)) + chr(int(locationsreadline10c)) \ | |
| + chr(int(padding2)) + chr(int(locationsreadline11c)) + chr(int(padding2)) # This is to build the locations table. | |
| buildfile7 = copyright4 + chr(int(countoffset41b)) + chr(int(captionssize1c)) \ | |
| + chr(int(countoffset42b)) + chr(int(picturessize1c)) + chr(int(countoffset43b)) + copyright4 \ | |
| + chr(int(countoffset44b)) + chr(int(captionssize2c)) + chr(int(countoffset45b)) + chr(int(picturessize2c)) \ | |
| + chr(int(countoffset46b)) + copyright4 + chr(int(countoffset47b)) + chr(int(captionssize3c)) \ | |
| + chr(int(countoffset48b)) + chr(int(picturessize3c)) + chr(int(countoffset49b)) + copyright4 \ | |
| + chr(int(countoffset50b)) + chr(int(captionssize4c)) + chr(int(countoffset51b)) + chr(int(picturessize4c)) \ | |
| + chr(int(countoffset52b)) + copyright4 + chr(int(countoffset53b)) + chr(int(captionssize5c)) \ | |
| + chr(int(countoffset54b)) + chr(int(picturessize5c)) + chr(int(countoffset55b)) + copyright4 \ | |
| + chr(int(countoffset56b)) + chr(int(captionssize6c)) + chr(int(countoffset57b)) + chr(int(picturessize6c)) \ | |
| + chr(int(countoffset58b)) + copyright4 + chr(int(countoffset59b)) + chr(int(captionssize7c)) \ | |
| + chr(int(countoffset60b)) + chr(int(picturessize7c)) + chr(int(countoffset61b)) + copyright4 \ | |
| + chr(int(countoffset62b)) + chr(int(captionssize8c)) + chr(int(countoffset63b)) + chr(int(picturessize8c)) \ | |
| + chr(int(countoffset64b)) + copyright4 + chr(int(countoffset65b)) + chr(int(captionssize9c)) \ | |
| + chr(int(countoffset66b)) + chr(int(picturessize9c)) + chr(int(countoffset67b)) + copyright4 \ | |
| + chr(int(countoffset68b)) + chr(int(captionssize10c)) + chr(int(countoffset69b)) \ | |
| + chr(int(picturessize10c)) + chr(int(countoffset70b)) + copyright4 + chr(int(countoffset71b)) \ | |
| + chr(int(captionssize11c)) + chr(int(countoffset72b)) + chr(int(picturessize11c)) \ | |
| + chr(int(countoffset73b)) # This is to build the article table. | |
| buildfile8 = titleopen1a + articleopen1a + captionssize1b \ | |
| + creditssize1b + titleopen2a + articleopen2a + captionssize2b \ | |
| + creditssize2b + titleopen3a + articleopen3a + captionssize3b \ | |
| + creditssize3b + titleopen4a + articleopen4a + captionssize4b \ | |
| + creditssize4b + titleopen5a + articleopen5a + captionssize5b \ | |
| + creditssize5b + titleopen6a + articleopen6a + captionssize6b \ | |
| + creditssize6b + titleopen7a + articleopen7a + captionssize7b \ | |
| + creditssize7b + titleopen8a + articleopen8a + captionssize8b \ | |
| + creditssize8b + titleopen9a + articleopen9a + captionssize9b \ | |
| + creditssize9b + titleopen10a + articleopen10a + captionssize10b \ | |
| + creditssize10b + titleopen11a + articleopen11a + captionssize11b # This is to build the articles. | |
| buildfile9 = copyright2 + topicsa1b + topicsa3b + topicsa4b + topicsa5b \ | |
| + topicsa6b + topicsa7b + topicsa8b # This is to build the topics and copyright. | |
| buildfile10 = locationsize1b + locationsize2b + locationsize3b \ | |
| + locationsize4b + locationsize5b + locationsize6b + locationsize7b \ | |
| + locationsize8b + locationsize9b + locationsize10b \ | |
| + locationsize11b # This is to build the locations. | |
| if os.path.exists(picturessize1a): | |
| buildfile11 = picturessize1b + '00' | |
| else: | |
| pass # This is to build the 1st picture. | |
| if os.path.exists(picturessize2a): | |
| buildfile12 = picturessize2b + '00' | |
| else: | |
| pass # This is to build the 2nd picture. | |
| if os.path.exists(picturessize3a): | |
| buildfile13 = picturessize3b + '00' | |
| else: | |
| pass # This is to build the 3rd picture. | |
| if os.path.exists(picturessize4a): | |
| buildfile14 = picturessize4b + '00' | |
| else: | |
| pass # This is to build the 4th picture. | |
| if os.path.exists(picturessize5a): | |
| buildfile15 = picturessize5b + '00' | |
| else: | |
| pass # This is to build the 5th picture. | |
| if os.path.exists(picturessize6a): | |
| buildfile16 = picturessize6b + '00' | |
| else: | |
| pass # This is to build the 6th picture. | |
| if os.path.exists(picturessize7a): | |
| buildfile17 = picturessize7b + '00' | |
| else: | |
| pass # This is to build the 7th picture. | |
| if os.path.exists(picturessize8a): | |
| buildfile18 = picturessize8b + '00' | |
| else: | |
| pass # This is to build the 8th picture. | |
| if os.path.exists(picturessize9a): | |
| buildfile19 = picturessize9b + '00' | |
| else: | |
| pass # This is to build the 9th picture. | |
| if os.path.exists(picturessize10a): | |
| buildfile20 = picturessize10b + '00' | |
| else: | |
| pass # This is to build the 10th picture. | |
| if os.path.exists(picturessize11a): | |
| buildfile21 = picturessize11b + '00' | |
| else: | |
| pass # This is to build the 11th picture. | |
| buildfileslist = buildfile1 + buildfile2 + buildfile3 + buildfile4 + buildfile6 + buildfile7 + buildfile8 + buildfile9 + buildfile10 + buildfile11 + buildfile12 + buildfile13 + buildfile14 + buildfile15 + buildfile16 + buildfile17 + buildfile18 + buildfile19 + buildfile20 + buildfile21 | |
| newsfilename = 'news.bin.' + str(datetime.now().hour)[2:].zfill(2) + '-1' | |
| newsfilename2 = 'news.bin.' + str(datetime.now().hour)[2:].zfill(2) | |
| with open(newsfilename, 'w+') as source_file: | |
| with open(newsfilename, 'wb') as dest_file: | |
| dest_file.write(chr(buildfiles1)) | |
| with open(newsfilename, 'rb') as source_file: | |
| newsfilecrc32read1a = source_file.read() | |
| newsfilecrc32read1b = binascii.crc32(newsfilecrc32read1a) | |
| newsfilecrc32read1c = hex(newsfilecrc32read1b)[2:].zfill(8) | |
| newswritefilesize1a = os.path.getsize(newsfilename) | |
| newswritefilesize1b = newswritefilesize1a + 8 | |
| newswritefilesize1c = hex(newswritefilesize1b)[2:].zfill(8) | |
| with open(newsfilename, 'rb') as source_file: | |
| with open(newsfilename, 'wb') as dest_file: | |
| newswrite1a = source_file.read() | |
| newswrite1b = '00000200' | |
| newswrite1c = newswrite1b + newswritefilesize1c + newsfilecrc32read1c + newswrite1a | |
| dest_file.write(newswrite1c) | |
| filesize1a = len(buildfileslist) + 8 | |
| filesize1b = hex(filesize1a).zfill(8) | |
| """Remove files we don't need anymore.""" | |
| for files in glob.glob('technology*'): | |
| os.remove(files) | |
| for files in glob.glob('sports*'): | |
| os.remove(files) | |
| for files in glob.glob('science*'): | |
| os.remove(files) | |
| for files in glob.glob('national*'): | |
| os.remove(files) | |
| for files in glob.glob('international*'): | |
| os.remove(files) | |
| for files in glob.glob('health*'): | |
| os.remove(files) | |
| for files in glob.glob('entertainment*'): | |
| os.remove(files) | |
| for files in glob.glob('business*'): | |
| os.remove(files) | |
| """Compress the file with LZ Compression.""" | |
| print '\n' | |
| print 'Compressing the file with LZ Compression...' | |
| if platform.system() == Windows: | |
| if os.path.exists('DSDecmp.exe'): | |
| subprocess.call(["DSDecmp.exe", "-c", "lz10", newsfilename, newsfilename2]) | |
| else: | |
| print 'Could not find DSDecmp. Please download it and try again.' | |
| elif platform.system() == Linux: | |
| if os.path.exists('DSDecmp.exe'): | |
| subprocess.call(["mono", "DSDecmp.exe", "-c", "lz10", newsfilename, newsfilename2]) | |
| else: | |
| print 'Could not find DSDecmp. Please download it and try again.' | |
| elif platform.system() == Darwin: | |
| if os.path.exists('DSDecmp.exe'): | |
| subprocess.call(["mono", "DSDecmp.exe", "-c", "lz10", newsfilename, newsfilename2]) | |
| else: | |
| print 'Could not find DSDecmp. Please download it and try again.' | |
| """Make the SHA1 and RSA Signature.""" | |
| print '\n' | |
| print 'Making the SHA1 and RSA Signature...' | |
| if platform.system() == Windows: | |
| if os.path.exists(newsfilename2): | |
| pass | |
| else: | |
| print "The LZ Compressed File doesn't exist." | |
| elif platform.system() == Linux: | |
| if os.path.exists(newsfilename2): | |
| pass | |
| else: | |
| print "The LZ Compressed File doesn't exist. You probably didn't install Mono. Please install Mono and try again." | |
| elif platform.system() == Darwin: | |
| if os.path.exists(newsfilename2): | |
| pass | |
| else: | |
| print "The LZ Compressed File doesn't exist. You probably didn't install Mono. Please install Mono and try again." | |
| if platform.system() == Windows: | |
| subprocess.call(["openssl", "sha1", newsfilename2, ">", "newssha1"]) | |
| elif platform.system() == Linux: | |
| subprocess.call(["openssl", "sha1", newsfilename2, ">", "newssha1"]) | |
| elif platform.system() == Darwin: | |
| subprocess.call(["openssl", "sha1", newsfilename2, ">", "newssha1"]) | |
| if platform.system() == Windows: | |
| if os.path.exists('newssha1'): | |
| pass | |
| else: | |
| print "The SHA1 Signature doesn't exist. You probably didn't install Cygwin. Please install Cygwin and try again." | |
| elif platform.system() == Linux: | |
| if os.path.exists('newssha1'): | |
| pass | |
| else: | |
| print "The SHA1 Signature doesn't exist." | |
| elif platform.system() == Darwin: | |
| if os.path.exists('newssha1'): | |
| pass | |
| else: | |
| print "The SHA1 Signature doesn't exist." | |
| with open('newssha1', 'rb') as source_file: | |
| with open('newssha1', 'wb') as dest_file: | |
| sha11 = source_file.read() | |
| sha12 = sha11[18:] | |
| dest_file.write(sha12) | |
| if platform.system() == Windows: | |
| if os.path.exists('Private.pem'): | |
| subprocess.call(["openssl", "rsautl", "-sign", "-inkey", "Private.pem", "-in", "newssha1", "-out", "newsrsa"]) | |
| else: | |
| print "Couldn't find the RSA Private Key. Please ask Larsenv for it." | |
| elif platform.system() == Linux: | |
| if os.path.exists('Private.pem'): | |
| subprocess.call(["openssl", "rsautl", "-sign", "-inkey", "Private.pem", "-in", "newssha1", "-out", "newsrsa"]) | |
| else: | |
| print "Couldn't find the RSA Private Key. Please ask Larsenv for it." | |
| elif platform.system() == Darwin: | |
| if os.path.exists('Private.pem'): | |
| subprocess.call(["openssl", "rsautl", "-sign", "-inkey", "Private.pem", "-in", "newssha1", "-out", "newsrsa"]) | |
| else: | |
| print "Couldn't find the RSA Private Key. Please ask Larsenv for it." | |
| if platform.system() == Windows: | |
| if os.path.exists('newssha1'): | |
| pass | |
| else: | |
| print "The RSA Signature doesn't exist. You probably didn't install Cygwin. Please install Cygwin and try again." | |
| elif platform.system() == Linux: | |
| if os.path.exists('newssha1'): | |
| pass | |
| else: | |
| print "The RSA Signature doesn't exist." | |
| elif platform.system() == Darwin: | |
| if os.path.exists('newssha1'): | |
| pass | |
| else: | |
| print "The RSA Signature doesn't exist." | |
| with open('newsrsa', 'rb') as source_file: | |
| rsa1 = source_file.read() | |
| with open(newsfilename2, 'rb') as source_file: | |
| with open(newsfilename2, 'wb') as dest_file: | |
| newsstuffyetonceagain1 = source_file.read() | |
| newsstuffyetonceagain2 = '00' | |
| newsstuffyetonceagain3 = newsstuffyetonceagain2.zfill(128) | |
| newsstuffyetonceagain4 = newsstuffyetonceagain3 + rsa1 + newsstuffyetonceagain1 | |
| dest_file.write(newsstuffyetonceagain4) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment