-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathmake.py
executable file
·201 lines (136 loc) · 5.14 KB
/
make.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
#!/usr/bin/env python
# -*- coding: UTF-8 -*-
from BeautifulSoup import BeautifulSoup
from htmlmin.minify import html_minify
import simplejson as json
import urllib2
import string
def curl(str):
return urllib2.urlopen(str).read()
def decode(str):
return json.JSONDecoder().decode(curl(str))
def facebook(str=''):
return decode('https://graph.facebook.com/326419920716241/' + str + '?access_token=AAACEdEose0cBACdbvgkWyH39MymuCNYasl5UHSAcuzDgZC6z3qHZCYK2hkNW7qe9FPi7bUTxlmYeRvxtW6QTVioDRaSxUKetZBg7TTuuAZDZD')
def html(soup):
return html_minify(string.replace(soup.prettify(), '\\n', '<br>'))
home = BeautifulSoup(open('template.txt', 'r').read())
homeout = open('index.html', 'w')
videos = BeautifulSoup(open('template.txt', 'r').read())
videosout = open('videos.html', 'w')
videosframe = BeautifulSoup(curl('http://www.youtube.com/user/blotchryanismi/videos'))
#videosframe = BeautifulSoup(curl('http://www.youtube.com/user/skymilesthemovement/videos'))
videosframeout = open('youtube.html', 'w')
photos = BeautifulSoup(open('template.txt', 'r').read())
photosout = open('photos.html', 'w')
sky = BeautifulSoup(open('template.txt', 'r').read())
skyout = open('sky.html', 'w')
carpet = BeautifulSoup(open('template.txt', 'r').read())
carpetin = open('carpet.txt', 'r').read()
carpetout = open('carpet.html', 'w')
community = BeautifulSoup(open('template.txt', 'r').read())
communityin = open('community.txt', 'r').read()
communityout = open('community.html', 'w')
home.find(attrs={'href' : '/'}).parent['class'] = 'active'
videos.find(attrs={'href' : 'videos'}).parent['class'] = 'active'
photos.find(attrs={'href' : 'photos'}).parent['class'] = 'active'
sky.find(attrs={'href' : 'sky'}).parent['class'] = 'active'
carpet.find(attrs={'href' : 'carpet'}).parent['class'] = 'active'
community.find(attrs={'href' : 'community'}).parent['class'] = 'active'
page = facebook()
links = facebook('links')['data']
linkshtml = ''
linkshtmlcount = 1
for link in links:
if linkshtmlcount == 1:
linkshtml += '</div><div class="row">'
try:
message = link['message']
except:
message = ''
try:
description = link['description']
except:
description = message
linkshtml += '''
<div class="''' + ('span4' if linkshtmlcount == 2 else 'span5') + '''">
<h5><a href="''' + link['link'] + '''" title="''' + message + '''">''' + link['name'] + '''</a></h5>
<br>
<p>''' + description + '''</p>
</div>
'''
if linkshtmlcount == 3:
linkshtmlcount = 1
else:
linkshtmlcount += 1
home.find(attrs={'id' : 'content'}).replaceWith('''
<div id="content" class="content">
<div class="hero-unit">
<h1>''' + page['name'] + '''</h1>
<p>''' + page['description'] + '''</p>
''' + linkshtml + '''
</div>
</div>
''')
videos.find(attrs={'id' : 'content'}).replaceWith('''
<div id="content" class="content">
<iframe
src="youtube.html" scrolling="yes" frameborder="0" style="border:none; overflow:hidden; width: 100%; height: 860px;" allowTransparency="true"></iframe>
</div>
''')
videosframe.find(attrs={'id' : 'masthead-container'}).extract()
videosframe.find(attrs={'id' : 'footer-container'}).extract()
videosframe.find(attrs={'class' : 'channel-horizontal-menu ytg-box'}).extract()
videosframe.find(attrs={'class' : 'video-sort-btn yt-uix-button'}).extract()
videosframe.find(attrs={'class' : 'primary-filter-menu'}).extract()
videosframe.find(attrs={'class' : 'channel-filtered-page-head'}).extract()
videosframe.find(attrs={'role' : 'button'}).extract()
videosframe.style.replaceWith('''
<style>
.channel-filtered-page {
padding-top: 0px !important;
}
#branded-page-body-container > *, .ytg-wide {
width: auto !important;
margin-top: 0px !important;
}
body, #branded-page-body-container, .tab-content-body {
background: transparent !important;
}
* {
color: whiteSmoke !important;
}
.yt-uix-button-content * {
color: #111111 !important;
}
</style>
''')
curl('http://wordpress.heardmag.com/wordpress/wp-content/plugins/fotobook/cron.php?secret=1cfa130f1bdf&update')
photos.find(attrs={'id' : 'content'}).replaceWith('''
<div id="content" class="content">
<iframe
src="http://wordpress.heardmag.com/wordpress/?page_id=3" scrolling="yes" frameborder="0" style="border:none; overflow:hidden; width: 100%; height: 860px; border-radius:4px;'" allowTransparency="true"></iframe>
</div>
''')
sky.find(attrs={'id' : 'content'}).replaceWith('''
<div id="content" class="content">
<iframe
src="http://skymiles3.tumblr.com/" scrolling="yes" frameborder="0" style="border:none; overflow:hidden; width: 100%; height: 860px; border-radius:4px;'" allowTransparency="true"></iframe>
</div>
''')
carpet.find(attrs={'id' : 'content'}).replaceWith('''
<div id="content" class="content">
''' + carpetin + '''
</div>
''')
community.find(attrs={'id' : 'content'}).replaceWith('''
<div id="content" class="content">
''' + communityin + '''
</div>
''')
homeout.write(html(home))
videosout.write(html(videos))
videosframeout.write(string.replace(string.replace(html(videosframe), '"//', '"http://'), '"/', '"http://youtube.com/'))
photosout.write(html(photos))
skyout.write(html(sky))
carpetout.write(html(carpet))
communityout.write(html(community))