├── .idea
└── vcs.xml
├── AsciiArt
├── README.md
├── asciiart.py
├── cool-nike-logos.jpg
├── images
│ └── cool-nike-logos.jpg
├── main.py
└── templates
│ ├── display.html
│ └── index.html
├── AskStackOverFlow
├── LICENSE.txt
├── README.md
├── askstackoverflow
│ └── askstackoverflow.py
├── requirements.txt
└── setup.py
├── CarLoan Data Extractor
├── README.md
└── getcardata.py
├── CollegeProjectFinder
├── README.md
├── common.py
├── finder.py
├── requirements.txt
└── terminalsize.py
├── README.md
├── WhatsHotReddit
├── README.md
├── praw.ini
├── requirements.txt
└── whr.py
├── movie-streamer
├── .gitignore
├── LICENSE.txt
├── README.md
├── bin
│ └── mstream
├── mstream
│ └── __init__.py
├── requirements.txt
└── setup.py
└── webcam-streamer
├── README.md
├── camera.py
├── main.py
└── templates
└── index.html
/.idea/vcs.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
--------------------------------------------------------------------------------
/AsciiArt/README.md:
--------------------------------------------------------------------------------
1 | ## Logos to Ascii-Art
2 |
3 | Convert Bichrome logos to Ascii-Art
4 |
5 | ### Description
6 | Convert Bichrome logos to Ascii-Art. All sorts of images can be converted to Ascii,
7 | but looks good on bichrome images.
8 |
9 |
10 | ### Usage
11 | 1. Install Python dependencies: Flask, Pillow.
12 | 2. Run "python main.py".
13 | 3. Open http://0.0.0.0:5000/ in the browser.
14 | 4. Upload Bi-chrome logo.
15 | 5. Get Awesome Ascii-Art!
16 |
17 | ### Example
18 |
19 | Original Image:
20 | [](https://postimg.org/image/iu0bjl205/)
21 |
22 | Ascii-Art:
23 | [](https://postimg.org/image/3mwrz9f85/)
24 |
--------------------------------------------------------------------------------
/AsciiArt/asciiart.py:
--------------------------------------------------------------------------------
1 | from PIL import Image
2 |
3 | ASCII_CHARS = [ ':', '%', '%', ':', ':', ':', ':', ':', ':', ':', ':']
4 |
5 | def scale_image(image, new_width=100):
6 | """Resizes an image preserving the aspect ratio.
7 | """
8 | (original_width, original_height) = image.size
9 | aspect_ratio = original_height/float(original_width)
10 | new_height = int(aspect_ratio * new_width)
11 |
12 | new_image = image.resize((new_width, new_height))
13 | return new_image
14 |
15 | def convert_to_grayscale(image):
16 | return image.convert('L')
17 |
18 | def map_pixels_to_ascii_chars(image, range_width=30):
19 | """Maps each pixel to an ascii char based on the range
20 | in which it lies.
21 |
22 | 0-255 is divided into 11 ranges of 25 pixels each.
23 | """
24 |
25 | pixels_in_image = list(image.getdata())
26 | pixels_to_chars = [ASCII_CHARS[pixel_value/range_width] for pixel_value in
27 | pixels_in_image]
28 |
29 | return "".join(pixels_to_chars)
30 |
31 | def convert_image_to_ascii(image, new_width=100):
32 | image = scale_image(image)
33 | image = convert_to_grayscale(image)
34 |
35 | pixels_to_chars = map_pixels_to_ascii_chars(image)
36 | len_pixels_to_chars = len(pixels_to_chars)
37 |
38 | image_ascii = [pixels_to_chars[index: index + new_width] for index in
39 | xrange(0, len_pixels_to_chars, new_width)]
40 |
41 | return "\n".join(image_ascii)
42 |
43 | def handle_image_conversion(image_filepath):
44 | image = None
45 | try:
46 | image = Image.open(image_filepath)
47 | except Exception, e:
48 | print "Unable to open image file {image_filepath}.".format(image_filepath=image_filepath)
49 | print e
50 | return
51 |
52 | image_ascii = convert_image_to_ascii(image)
53 | return image_ascii
54 |
55 | if __name__=='__main__':
56 | import sys
57 |
58 | image_file_path = sys.argv[1]
59 | print handle_image_conversion(image_file_path)
60 |
--------------------------------------------------------------------------------
/AsciiArt/cool-nike-logos.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/vaulstein/7daysOfCode/e02b3a98a04753f0e60b8202f4a2f054837e57e0/AsciiArt/cool-nike-logos.jpg
--------------------------------------------------------------------------------
/AsciiArt/images/cool-nike-logos.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/vaulstein/7daysOfCode/e02b3a98a04753f0e60b8202f4a2f054837e57e0/AsciiArt/images/cool-nike-logos.jpg
--------------------------------------------------------------------------------
/AsciiArt/main.py:
--------------------------------------------------------------------------------
1 | from flask import Flask, render_template, Response, request, redirect, url_for
2 | from werkzeug.utils import secure_filename
3 | import os
4 | from asciiart import handle_image_conversion
5 |
6 | base_path = os.getcwd()
7 |
8 | UPLOAD_FOLDER = abs_path = os.path.join(base_path+'/images')
9 | ALLOWED_EXTENSIONS = set(['png', 'jpg', 'jpeg', 'gif'])
10 |
11 | app = Flask(__name__)
12 | app.config['UPLOAD_FOLDER'] = UPLOAD_FOLDER
13 |
14 |
15 | def allowed_file(filename):
16 | return '.' in filename and \
17 | filename.rsplit('.', 1)[1].lower() in ALLOWED_EXTENSIONS
18 |
19 | @app.route('/', methods=['GET', 'POST'])
20 | def upload_file():
21 | if request.method == 'POST':
22 | # check if the post request has the file part
23 | if 'file' not in request.files:
24 | #flash('No file part')
25 | return redirect(request.url)
26 | file = request.files['file']
27 | # if user does not select file, browser also
28 | # submit a empty part without filename
29 | if file.filename == '':
30 | #flash('No selected file')
31 | return redirect(request.url)
32 | if file and allowed_file(file.filename):
33 | filename = secure_filename(file.filename)
34 | file.save(os.path.join(app.config['UPLOAD_FOLDER'], filename))
35 | asciiart = handle_image_conversion(os.path.join(app.config['UPLOAD_FOLDER'], filename))
36 | return render_template('display.html', asciiart=asciiart)
37 | return render_template('index.html')
38 |
39 | if __name__ == '__main__':
40 | app.run(host='0.0.0.0', debug=True)
--------------------------------------------------------------------------------
/AsciiArt/templates/display.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | Ascii-Art
6 |
7 |
8 | {{ asciiart }}
9 |
10 |
--------------------------------------------------------------------------------
/AsciiArt/templates/index.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | Upload File
6 |
7 |
8 | Upload new File
9 |
13 |
14 |
--------------------------------------------------------------------------------
/AskStackOverFlow/LICENSE.txt:
--------------------------------------------------------------------------------
1 | MIT License
2 |
3 |
4 | Permission is hereby granted, free of charge, to any person obtaining a copy
5 | of this software and associated documentation files (the "Software"), to deal
6 | in the Software without restriction, including without limitation the rights
7 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
8 | copies of the Software, and to permit persons to whom the Software is
9 | furnished to do so, subject to the following conditions:
10 |
11 | The above copyright notice and this permission notice shall be included in all
12 | copies or substantial portions of the Software.
13 |
14 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
19 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
20 | SOFTWARE.
21 |
--------------------------------------------------------------------------------
/AskStackOverFlow/README.md:
--------------------------------------------------------------------------------
1 | # AskStackOverFlow
2 |
3 | Stackoverflow Q&A right from the command line!
4 |
5 |
6 | Inspired by https://github.com/Ritiek/AskQuora
7 |
8 | ## Usage:
9 |
10 | `git clone https://github.com/vaulstein/7daysOfCode.git`
11 |
12 | `cd 7daysOfCode/AskStackOverFlow/askstackoverflow`
13 |
14 | `python askstackoverflow.py `
15 |
16 |
17 | ## Contributing:
18 |
19 | Any PR's in bug fixes, features or even this documentation are most welcome!
20 |
21 |
22 | ## License:
23 |
24 | `The MIT License`
--------------------------------------------------------------------------------
/AskStackOverFlow/askstackoverflow/askstackoverflow.py:
--------------------------------------------------------------------------------
1 | #!/bin/python
2 |
3 | from sys import argv
4 | from colorama import init, Fore, Style
5 | from bs4 import BeautifulSoup
6 | from os import popen
7 | from random import choice
8 | import requests
9 | import textwrap
10 |
11 | def cli():
12 | argv.pop(0)
13 | init(autoreset=True)
14 | headers = (
15 | 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10.7; rv:11.0) Gecko/20100101 Firefox/11.0',
16 | 'Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:22.0) Gecko/20100 101 Firefox/22.0',
17 | 'Mozilla/5.0 (Windows NT 6.1; rv:11.0) Gecko/20100101 Firefox/11.0',
18 | 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_7_4) AppleWebKit/536.5 (KHTML, like Gecko)',
19 | 'Chrome/19.0.1084.46 Safari/536.5',
20 | 'Mozilla/5.0 (Windows; Windows NT 6.1) AppleWebKit/536.5 (KHTML, like Gecko)',
21 | 'Chrome/19.0.1084.46',
22 | 'Safari/536.5',
23 | 'Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.9.2.13) Gecko/20101206 Ubuntu/10.10 (maverick) Firefox/3.6.13',
24 | )
25 | header = {'User-agent': choice(headers)}
26 |
27 | if len(argv) == 0:
28 | print('Usage: askstackoverflow ')
29 | exit()
30 | query = (' '.join(argv)).replace(' ', '+')
31 |
32 | page = requests.get('https://duckduckgo.com/html/?q=' + query + ' site:stackoverflow.com', headers=header).text
33 | soup = BeautifulSoup(page, 'html.parser')
34 | possible_links = soup.find_all('a', {'class':'result__a'})
35 | #print possible_links
36 |
37 | width = int((popen('stty size', 'r').read().split())[1])
38 | links = []
39 | color = True
40 | numb = 1
41 |
42 | for x in possible_links[:10]:
43 | inner_link = 'https://duckduckgo.com' + x['href']
44 | page = requests.get(inner_link, headers=header).text
45 | soup = BeautifulSoup(page, 'html.parser')
46 | link = (soup.find('script').get_text()).replace('window.parent.location.replace("', '').replace('");', '')
47 | #if link.startswith('https://www.quora.com/') and not link.startswith('https://www.quora.com/topic/') and not link.startswith('https://www.quora.com/profile/'):
48 | if link.startswith('http://stackoverflow.com/questions'):
49 | if color:
50 | prefix = Fore.RED + Style.BRIGHT + '{0: <4}'.format(str(numb) + '.')
51 | else:
52 | prefix = Fore.MAGENTA + Style.BRIGHT + '{0: <4}'.format(str(numb) + '.')
53 | wrapper = textwrap.TextWrapper(initial_indent=prefix, width=width, subsequent_indent=' ')
54 | print wrapper.fill(link.split('/')[-1].replace('-', ' '))
55 | links.append(link)
56 |
57 | color = not color
58 | numb += 1
59 |
60 | print('')
61 | print('Choose a Question')
62 |
63 | while True:
64 | selection = int(raw_input('> '))
65 | if selection <= len(links) and selection >= 1:
66 | break
67 | else:
68 | print('Choose a valid number!')
69 |
70 | link = links[selection-1]
71 | ques_page = (requests.get(link, headers=header).text)
72 | ques_page = ques_page.replace('', Fore.YELLOW).replace('', Fore.RED)
73 | ques_page = ques_page.replace('', Fore.RED + '')
74 | ques_page = ques_page.replace('
', '\n')
75 | ques_page = ques_page.replace('', '\n\n')
76 |
77 | print('')
78 | soup = BeautifulSoup(ques_page, 'html.parser')
79 |
80 | try:
81 | answer = Fore.RED + Style.BRIGHT + soup.find('div',{'class': 'answer accepted-answer'}).find('td',{'class':'answercell'}).get_text()
82 | print answer.replace('\n\n\n','\n')
83 | except AttributeError:
84 | print 'Sorry, this question has not been answered yet..'
85 | exit()
86 |
87 | if __name__=='__main__':
88 | cli()
--------------------------------------------------------------------------------
/AskStackOverFlow/requirements.txt:
--------------------------------------------------------------------------------
1 | requests >= 2.9.1
2 | BeautifulSoup4 >= 4.5.3
3 | colorama >= 0.3.7
--------------------------------------------------------------------------------
/AskStackOverFlow/setup.py:
--------------------------------------------------------------------------------
1 | #!/usr/bin/python
2 |
3 | import sys
4 | import os
5 | import askquora
6 |
7 | if sys.version_info > (3,0):
8 | sys.exit("AskQuora requires python 2.")
9 |
10 | from setuptools import setup, find_packages
11 |
12 | setup(name='AskStackOverFlow',
13 | version='0.1',
14 | description='StackOverFlow Q&A right from the command line! Inspiration from Ritesh M',
15 | author='Vaulstein Rodrigues',
16 | author_email='vaulstein@gmail.com',
17 | packages = find_packages(),
18 | entry_points={
19 | 'console_scripts': [
20 | 'askstackoverflow = askstackoverflow.askstackoverflow:cli',
21 | ]
22 | },
23 | url='https://www.github.com/Vaulstein/7daysOfCode',
24 | keywords=['stackoverflow', 'terminal', 'command-line', 'question', 'python'],
25 | license='MIT',
26 | classifiers=[],
27 | install_requires=[
28 | 'requests',
29 | 'BeautifulSoup4',
30 | 'colorama',
31 | 'requests-cache'
32 | ]
33 | )
--------------------------------------------------------------------------------
/CarLoan Data Extractor/README.md:
--------------------------------------------------------------------------------
1 | ## Leaked Car Data Script
2 |
3 | Script to fetch data leaked by cars.indian.net.in
4 |
5 | ### Description
6 | Supposedly leaked User information by Infinite Loop Dev. downloader script
7 |
8 | ### Requirements
9 | Mongo installed locally
10 |
11 | [Download Mongodb](https://www.mongodb.com/download-center?jmp=nav)
12 |
13 | ### Usage
14 | 1. Install Python dependencies: Pymongo, requests, Beautifulsoup
15 | 2. Run "python getcardata.py".
16 | 3. Check Mongodb collection on local machine for data
17 |
18 | ### Disclaimer
19 | The coder(I) take no responsibility for the accuracy, completeness or
20 | quality of the information provided by cars.indian.net.in
21 |
22 | The coder is in no event liable for damages of any kind incurred or suffered
23 | as a result of the use or non-use of the information presented by running the script.
--------------------------------------------------------------------------------
/CarLoan Data Extractor/getcardata.py:
--------------------------------------------------------------------------------
1 | from bs4 import BeautifulSoup
2 | import requests
3 | from pymongo import MongoClient
4 | import time, math, random, string
5 |
6 | store_data = MongoClient('mongodb://localhost:27017')['cardata']['india_user']
7 |
8 | initial_link = 'http://cars.indian.net.in/'
9 |
10 | first_requests = requests.get(initial_link)
11 |
12 |
13 | def unique_id_gen(prefix='', more_entropy=False):
14 | m = time.time()
15 | unique_id = '%8x%05x' % (math.floor(m), (m - math.floor(m)) * 1000000)
16 | if more_entropy:
17 | valid_chars = list(set(string.hexdigits.lower()))
18 | entropy_string = ''
19 | for i in range(0, 10, 1):
20 | entropy_string += random.choice(valid_chars)
21 | unique_id = unique_id + entropy_string
22 | unique_id = prefix + unique_id
23 | return unique_id
24 |
25 | data = first_requests.text
26 | soup = BeautifulSoup(data, 'html.parser')
27 |
28 | product_url = soup.find_all('li', {'class', "list-group-item"})
29 |
30 | for url_data in product_url:
31 | car_url = 'http://cars.indian.net.in' + url_data.find('a')['href']
32 |
33 | try:
34 | first_requests = requests.get(car_url)
35 | data = first_requests.text
36 | soup = BeautifulSoup(data, 'html.parser')
37 | div = soup.find('table', {'id': "dgData"})
38 | ps = div.find_all('tr')
39 |
40 | count = 0
41 | dict_cars = {}
42 | header_dict = {}
43 | for p in ps:
44 | each_cell = p.find_all('td')
45 | for index, cell in enumerate(each_cell):
46 | if count == 0:
47 | header_dict[index] = cell.text
48 | dict_cars[cell.text] = {}
49 | else:
50 | dict_cars[header_dict[index]] = cell.text
51 | try:
52 | if count > 0:
53 | store_data.insert_one(dict_cars)
54 | except Exception as e:
55 | dict_cars['_id'] = unique_id_gen()
56 | inserted_data = store_data.insert_one(dict_cars)
57 | count += 1
58 | print(dict_cars)
59 | time.sleep(20)
60 | except Exception as e:
61 | pass
--------------------------------------------------------------------------------
/CollegeProjectFinder/README.md:
--------------------------------------------------------------------------------
1 | # COLLEGE PROJECT FINDER
2 |
3 | Finds you latest trending projects that can be used as your College Project.
4 | The aim of the project is to encourage students to learn from code rather than buy projects online.
5 |
6 | ## Installation
7 |
8 | git clone https://github.com/vaulstein/7daysOfCode.git
9 |
10 | pip install -r requirements.txt
11 |
12 | python finder.py
13 |
14 | ## Example
15 |
16 | [](https://postimg.org/image/df4s61jd7/)
17 |
18 | [](https://postimg.org/image/s9nzvxcxh/)
19 |
20 | ## TODO
21 |
22 | 1. Filter code libraries.
23 | 2. Create pip install-able library
24 |
--------------------------------------------------------------------------------
/CollegeProjectFinder/common.py:
--------------------------------------------------------------------------------
1 | import datetime
2 | import sys
3 |
4 | import pytz
5 |
6 | try:
7 | import tzlocal
8 |
9 | _DEFAULT_TIMEZONE = tzlocal.get_localzone().zone
10 | except:
11 | _DEFAULT_TIMEZONE = 'Asia/Calcutta'
12 |
13 | import six
14 |
15 | __version__ = "1.0.dev0"
16 |
17 | TWITTER_API_URL = 'https://api.twitter.com/1.1'
18 |
19 | # url for list of valid timezones
20 | _TZ_URL = 'http://en.wikipedia.org/wiki/List_of_tz_database_time_zones'
21 |
22 | CONF = {
23 | 'consumer_key': '',
24 | 'consumer_secret': '',
25 | 'api_key': '',
26 | 'api_secret': '',
27 | 'data_to_fetch': 1,
28 | 'query': '',
29 | 'geocode': '',
30 | 'lang': '',
31 | 'result_type': 'popular',
32 | 'count': 100,
33 | 'until': None,
34 | 'since_id': None,
35 | 'type_of_follow': '1'
36 | }
37 |
38 | RESULT_MAP = {
39 | '1': 'popular',
40 | '2': 'recent',
41 | '3': 'mixed'
42 | }
43 |
44 |
45 | def decoding_strings(f):
46 | def wrapper(*args, **kwargs):
47 | out = f(*args, **kwargs)
48 | if isinstance(out, six.string_types) and not six.PY3:
49 | # todo: make encoding configurable?
50 | if six.PY3:
51 | return out
52 | else:
53 | return out.decode(sys.stdin.encoding)
54 | return out
55 |
56 | return wrapper
57 |
58 |
59 | def _input_compat(prompt):
60 | if six.PY3:
61 | r = input(prompt)
62 | else:
63 | r = raw_input(prompt)
64 | return r
65 |
66 |
67 | if six.PY3:
68 | str_compat = str
69 | else:
70 | str_compat = unicode
71 |
72 | dateObject = 'YYYY-MM-DD'
73 |
74 |
75 | @decoding_strings
76 | def ask(question, answer=str_compat, default=None, l=None, options=None):
77 | if answer == str_compat:
78 | r = ''
79 | while True:
80 | if default:
81 | r = _input_compat('> {0} [{1}] '.format(question, default))
82 | else:
83 | r = _input_compat('> {0} '.format(question, default))
84 |
85 | r = r.strip()
86 |
87 | if len(r) <= 0:
88 | if default:
89 | r = default
90 | break
91 | else:
92 | print('You must enter something')
93 | else:
94 | if l and len(r) != l:
95 | print('You must enter a {0} letters long string'.format(l))
96 | else:
97 | break
98 |
99 | return r
100 |
101 | elif answer == bool:
102 | r = None
103 | while True:
104 | if default is True:
105 | r = _input_compat('> {0} (Y/n) '.format(question))
106 | elif default is False:
107 | r = _input_compat('> {0} (y/N) '.format(question))
108 | else:
109 | r = _input_compat('> {0} (y/n) '.format(question))
110 |
111 | r = r.strip().lower()
112 |
113 | if r in ('y', 'yes'):
114 | r = True
115 | break
116 | elif r in ('n', 'no'):
117 | r = False
118 | break
119 | elif not r:
120 | r = default
121 | break
122 | else:
123 | print("You must answer 'yes' or 'no'")
124 | return r
125 | elif answer == int:
126 | r = None
127 | while True:
128 | if default:
129 | r = _input_compat('> {0} [{1}] '.format(question, default))
130 | else:
131 | r = _input_compat('> {0} '.format(question))
132 |
133 | r = r.strip()
134 |
135 | if not r:
136 | r = default
137 | break
138 |
139 | try:
140 | r = int(r)
141 | break
142 | except:
143 | print('You must enter an integer')
144 | return r
145 | elif answer == list:
146 | # For checking multiple options
147 | r = None
148 | while True:
149 | if default:
150 | r = _input_compat('> {0} [{1}] '.format(question, default))
151 | else:
152 | r = _input_compat('> {0} '.format(question))
153 |
154 | r = r.strip()
155 |
156 | if not r:
157 | r = default
158 | break
159 |
160 | try:
161 | if int(r) in range(1, len(options) + 1):
162 | break
163 | else:
164 | print('Please select valid option: ' + ' or '.join('{}'.format(s) for _, s in enumerate(options)))
165 | except:
166 | print('Please select valid option: ' + ' or '.join('{}'.format(s) for _, s in enumerate(options)))
167 | return r
168 | if answer == dateObject:
169 | r = ''
170 | while True:
171 | if default:
172 | r = _input_compat('> {0} [{1}] '.format(question, default))
173 | else:
174 | r = _input_compat('> {0} '.format(question, default))
175 |
176 | r = r.strip()
177 |
178 | if not r:
179 | r = default
180 | break
181 |
182 | try:
183 | datetime.datetime.strptime(r, '%Y-%m-%d')
184 | break
185 | except ValueError:
186 | print("Incorrect data format, should be YYYY-MM-DD")
187 |
188 | return r
189 |
190 | else:
191 | raise NotImplemented(
192 | 'Argument `answer` must be str_compat, bool, or integer')
193 |
194 |
195 | def ask_timezone(question, default, tzurl):
196 | """Prompt for time zone and validate input"""
197 | lower_tz = [tz.lower() for tz in pytz.all_timezones]
198 | while True:
199 | r = ask(question, str_compat, default)
200 | r = r.strip().replace(' ', '_').lower()
201 | if r in lower_tz:
202 | r = pytz.all_timezones[lower_tz.index(r)]
203 | break
204 | else:
205 | print('Please enter a valid time zone:\n'
206 | ' (check [{0}])'.format(tzurl))
207 | return r
208 |
209 |
210 | def start():
211 | print(r'''Welcome to College Project Finder v{v}.
212 |
213 | _ \ _ \ _ \ | ____| ___| __ __| ____| _ _| \ | __ \ ____| _ \
214 | | | | | | | | __| | | | | \ | | | __| | |
215 | ___/ __ < | | \ | | | | __| | |\ | | | | __ <
216 | _| _| \_\ \___/ \___/ _____| \____| _| _| ___| _| \_| ____/ _____| _| \_\
217 |
218 |
219 |
220 | This script will help you find the coolest trending Open source projects that you can use as a project in college.
221 |
222 | Please answer the following questions so this script can generate your
223 | required output.
224 |
225 | '''.format(v=__version__))
226 |
227 |
--------------------------------------------------------------------------------
/CollegeProjectFinder/finder.py:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env python
2 | # -*- coding: utf-8 -*-
3 | import os
4 | import subprocess
5 | import textwrap
6 |
7 | import requests
8 | from colorama import init, Fore, Style
9 |
10 | import common
11 | import terminalsize
12 |
13 |
14 | def main():
15 | sizex, sizey = terminalsize.get_terminal_size()
16 | init(autoreset=True)
17 | color = True
18 | numb = 1
19 | common.start()
20 | parameters = {'sort': 'stars', 'order': 'desc'}
21 | topic = common.ask('What topic would you want your project in? Eg. AI, Machine Learning, Image Processing?',
22 | answer=common.str_compat, default="Machine Learning")
23 | language = common.ask('Any specific language?', answer=common.str_compat, default=" ")
24 | if topic:
25 | search_term = 'topic:' + topic
26 | if language.strip():
27 | search_term += ' language:' + language.strip()
28 | parameters['q'] = search_term
29 |
30 | project_request = requests.get('https://api.github.com/search/repositories', params=parameters).json()
31 | if 'items' in project_request:
32 | git_details = project_request['items']
33 | for project in git_details:
34 | if color:
35 | prefix = Fore.RED + Style.BRIGHT + '*' * (sizex / 4)
36 | else:
37 | prefix = Fore.MAGENTA + Style.BRIGHT + '*' * (sizex / 4)
38 | wrapper = textwrap.TextWrapper(initial_indent=prefix, width=sizex, subsequent_indent=' ')
39 | print wrapper.fill('*' * (sizex / 4))
40 | print('{} . Project Name: {}'.format(str(numb), project['name']))
41 | print('-' * (sizex / 8))
42 | print('Project Description: \n%s' % project['description'])
43 | print('-' * (sizex / 8))
44 | print('Project Url: %s' % project['html_url'])
45 |
46 | color = not color
47 | numb += 1
48 | print('\n\n')
49 | clone_index = common.ask('Select one of the Projects to clone. Enter index. Eg. 1 for first',
50 | answer=list, default="1", options=range(1, len(git_details)))
51 | clone_path = common.ask('Path to clone? Leave blank if same path.', answer=common.str_compat, default=' ')
52 | if subprocess.check_call('git --version', shell=True) != 0:
53 | print('git not installed installed, please read link ' +
54 | 'https://git-scm.com/book/en/v2/Getting-Started-Installing-Git.')
55 | exit()
56 | else:
57 | clone_url = git_details[int(clone_index)]['clone_url']
58 | command = 'git clone ' + clone_url
59 | if clone_path.strip():
60 | if os.path.isdir(clone_path):
61 | command += ' ' + clone_path
62 | print('Cloning..')
63 | subprocess.check_call(command, shell=True)
64 |
65 |
66 | if __name__ == "__main__":
67 | main()
--------------------------------------------------------------------------------
/CollegeProjectFinder/requirements.txt:
--------------------------------------------------------------------------------
1 | colorama==0.3.7
2 | Pillow==4.1.0
3 | pkg-resources==0.0.0
4 | python-dateutil==2.5.3
5 | pytz==2016.7
6 | requests==2.12.1
7 | six==1.10.0
8 | Unidecode==0.4.19
9 | update-checker==0.16
10 |
--------------------------------------------------------------------------------
/CollegeProjectFinder/terminalsize.py:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env python
2 | import os
3 | import platform
4 | import shlex
5 | import struct
6 | import subprocess
7 |
8 |
9 | def get_terminal_size():
10 | """ getTerminalSize()
11 | - get width and height of console
12 | - works on linux,os x,windows,cygwin(windows)
13 | originally retrieved from:
14 | http://stackoverflow.com/questions/566746/how-to-get-console-window-width-in-python
15 | """
16 | current_os = platform.system()
17 | tuple_xy = None
18 | if current_os == 'Windows':
19 | tuple_xy = _get_terminal_size_windows()
20 | if tuple_xy is None:
21 | tuple_xy = _get_terminal_size_tput()
22 | # needed for window's python in cygwin's xterm!
23 | if current_os in ['Linux', 'Darwin'] or current_os.startswith('CYGWIN'):
24 | tuple_xy = _get_terminal_size_linux()
25 | if tuple_xy is None:
26 | print "default"
27 | tuple_xy = (80, 25) # default value
28 | return tuple_xy
29 |
30 |
31 | def _get_terminal_size_windows():
32 | try:
33 | from ctypes import windll, create_string_buffer
34 | # stdin handle is -10
35 | # stdout handle is -11
36 | # stderr handle is -12
37 | h = windll.kernel32.GetStdHandle(-12)
38 | csbi = create_string_buffer(22)
39 | res = windll.kernel32.GetConsoleScreenBufferInfo(h, csbi)
40 | if res:
41 | (bufx, bufy, curx, cury, wattr,
42 | left, top, right, bottom,
43 | maxx, maxy) = struct.unpack("hhhhHhhhhhh", csbi.raw)
44 | sizex = right - left + 1
45 | sizey = bottom - top + 1
46 | return sizex, sizey
47 | except:
48 | pass
49 |
50 |
51 | def _get_terminal_size_tput():
52 | # get terminal width
53 | # src: http://stackoverflow.com/questions/263890/how-do-i-find-the-width-height-of-a-terminal-window
54 | try:
55 | cols = int(subprocess.check_call(shlex.split('tput cols')))
56 | rows = int(subprocess.check_call(shlex.split('tput lines')))
57 | return (cols, rows)
58 | except:
59 | pass
60 |
61 |
62 | def _get_terminal_size_linux():
63 | def ioctl_GWINSZ(fd):
64 | try:
65 | import fcntl
66 | import termios
67 | cr = struct.unpack('hh',
68 | fcntl.ioctl(fd, termios.TIOCGWINSZ, '1234'))
69 | return cr
70 | except:
71 | pass
72 |
73 | cr = ioctl_GWINSZ(0) or ioctl_GWINSZ(1) or ioctl_GWINSZ(2)
74 | if not cr:
75 | try:
76 | fd = os.open(os.ctermid(), os.O_RDONLY)
77 | cr = ioctl_GWINSZ(fd)
78 | os.close(fd)
79 | except:
80 | pass
81 | if not cr:
82 | try:
83 | cr = (os.environ['LINES'], os.environ['COLUMNS'])
84 | except:
85 | return None
86 | return int(cr[1]), int(cr[0])
87 |
88 |
89 | if __name__ == "__main__":
90 | sizex, sizey = get_terminal_size()
91 | print 'width =', sizex, 'height =', sizey
92 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # 7daysOfCode
2 | #7DaysOfCode Challenge. Next step #100DaysOfCode
3 |
--------------------------------------------------------------------------------
/WhatsHotReddit/README.md:
--------------------------------------------------------------------------------
1 | ## What's HOT Reddit?
2 |
3 | A cli script to fetch HOT topics on Reddit from subreddits
4 |
5 | # Requirements
6 |
7 | Requirements can be installed using:
8 |
9 | `pip install -r requirements.txt`
10 |
11 | # Run
12 |
13 | `cd WhatsHotReddit`
14 |
15 | `python whr.py`
16 |
17 | Enter the subreddit name, whose hot posts you need to fetch.
18 | Enter the number of posts to fetch
19 |
20 | [](https://postimg.org/image/z3d60xuqf/)
--------------------------------------------------------------------------------
/WhatsHotReddit/praw.ini:
--------------------------------------------------------------------------------
1 | [bot1]
2 | client_id=Tj-XYVuXvj4aJw
3 | client_secret=h5gkshlHGm63h338_2rEXR9oTSQ
4 | password=
5 | username=
6 | user_agent=RedditGetPost Bot 0.1
--------------------------------------------------------------------------------
/WhatsHotReddit/requirements.txt:
--------------------------------------------------------------------------------
1 | pkg-resources==0.0.0
2 | praw==4.4.0
3 | prawcore==0.8.0
--------------------------------------------------------------------------------
/WhatsHotReddit/whr.py:
--------------------------------------------------------------------------------
1 | import praw
2 |
3 | import six
4 | import sys
5 |
6 | from datetime import datetime
7 |
8 | __version__ = 0.1
9 |
10 | def decoding_strings(f):
11 | def wrapper(*args, **kwargs):
12 | out = f(*args, **kwargs)
13 | if isinstance(out, six.string_types) and not six.PY3:
14 | # todo: make encoding configurable?
15 | if six.PY3:
16 | return out
17 | else:
18 | return out.decode(sys.stdin.encoding)
19 | return out
20 |
21 | return wrapper
22 |
23 |
24 | def _input_compat(prompt):
25 | if six.PY3:
26 | r = input(prompt)
27 | else:
28 | r = raw_input(prompt)
29 | return r
30 |
31 |
32 | if six.PY3:
33 | str_compat = str
34 | else:
35 | str_compat = unicode
36 |
37 | dateObject = 'YYYY-MM-DD'
38 |
39 |
40 | @decoding_strings
41 | def ask(question, answer=str_compat, default=None, l=None, options=None):
42 | if answer == str_compat:
43 | r = ''
44 | while True:
45 | if default:
46 | r = _input_compat('> {0} [{1}] '.format(question, default))
47 | else:
48 | r = _input_compat('> {0} '.format(question, default))
49 |
50 | r = r.strip()
51 |
52 | if len(r) <= 0:
53 | if default:
54 | r = default
55 | break
56 | else:
57 | print('You must enter something')
58 | else:
59 | if l and len(r) != l:
60 | print('You must enter a {0} letters long string'.format(l))
61 | else:
62 | break
63 |
64 | return r
65 |
66 | elif answer == bool:
67 | r = None
68 | while True:
69 | if default is True:
70 | r = _input_compat('> {0} (Y/n) '.format(question))
71 | elif default is False:
72 | r = _input_compat('> {0} (y/N) '.format(question))
73 | else:
74 | r = _input_compat('> {0} (y/n) '.format(question))
75 |
76 | r = r.strip().lower()
77 |
78 | if r in ('y', 'yes'):
79 | r = True
80 | break
81 | elif r in ('n', 'no'):
82 | r = False
83 | break
84 | elif not r:
85 | r = default
86 | break
87 | else:
88 | print("You must answer 'yes' or 'no'")
89 | return r
90 | elif answer == int:
91 | r = None
92 | while True:
93 | if default:
94 | r = _input_compat('> {0} [{1}] '.format(question, default))
95 | else:
96 | r = _input_compat('> {0} '.format(question))
97 |
98 | r = r.strip()
99 |
100 | if not r:
101 | r = default
102 | break
103 |
104 | try:
105 | r = int(r)
106 | break
107 | except:
108 | print('You must enter an integer')
109 | return r
110 | elif answer == list:
111 | # For checking multiple options
112 | r = None
113 | while True:
114 | if default:
115 | r = _input_compat('> {0} [{1}] '.format(question, default))
116 | else:
117 | r = _input_compat('> {0} '.format(question))
118 |
119 | r = r.strip()
120 |
121 | if not r:
122 | r = default
123 | break
124 |
125 | try:
126 | if int(r) in range(1, len(options) + 1):
127 | break
128 | else:
129 | print('Please select valid option: ' + ' or '.join('{}'.format(s) for _, s in enumerate(options)))
130 | except:
131 | print('Please select valid option: ' + ' or '.join('{}'.format(s) for _, s in enumerate(options)))
132 | return r
133 | if answer == dateObject:
134 | r = ''
135 | while True:
136 | if default:
137 | r = _input_compat('> {0} [{1}] '.format(question, default))
138 | else:
139 | r = _input_compat('> {0} '.format(question, default))
140 |
141 | r = r.strip()
142 |
143 | if not r:
144 | r = default
145 | break
146 |
147 | try:
148 | datetime.datetime.strptime(r, '%Y-%m-%d')
149 | break
150 | except ValueError:
151 | print("Incorrect data format, should be YYYY-MM-DD")
152 |
153 | return r
154 |
155 | else:
156 | raise NotImplemented(
157 | 'Argument `answer` must be str_compat, bool, or integer')
158 |
159 |
160 | def main():
161 | print(r'''Welcome to
162 |
163 | / __ ___ __ _
164 | | ||_ _ |_ _ |__|/ \ | |__)_ _| _|.|_ )
165 | |/\|| )(_||_ _) | |\__/ | | \(-(_|(_|||_ .
166 |
167 |
168 | Get the hot topics on reddit, right on your terminal.
169 |
170 | '''.format(v=__version__))
171 |
172 | reddit = praw.Reddit('bot1')
173 | subreddit_name = ask("Enter subreddit name:",
174 | answer=str_compat)
175 | subreddit = reddit.subreddit(subreddit_name)
176 | count_to_fetch = ask('How many post would you want to see?', answer=int, default=5)
177 | if count_to_fetch > 10:
178 | print('Cannot fetch more than 10 posts.')
179 | sys.exit()
180 | identifiers = ask('Show Identifiers?', answer=bool, default=True)
181 | if identifiers:
182 | title = 'Title :: \n'
183 | body = 'Body :: \n'
184 | post_score = 'Score :: '
185 | else:
186 | title = ''
187 | body = ''
188 | post_score = ''
189 | for submission in subreddit.hot(limit=5):
190 | print('*'*20)
191 | print((u'{0}' + submission.title).format(title))
192 | print('-'*20)
193 | print((u'{0}' + submission.selftext).format(body))
194 | print('-'*20)
195 | print(('{0}' + str(submission.score)).format(post_score))
196 |
197 | if __name__ == "__main__":
198 | main()
199 |
200 |
--------------------------------------------------------------------------------
/movie-streamer/.gitignore:
--------------------------------------------------------------------------------
1 | .installed.cfg
2 | develop-eggs
3 | dist
4 | downloads
5 | eggs
6 | parts
7 | src/*.egg-info
8 | lib
9 | lib64
10 | .idea
11 | bin
--------------------------------------------------------------------------------
/movie-streamer/LICENSE.txt:
--------------------------------------------------------------------------------
1 | The MIT License
2 |
3 |
4 | Permission is hereby granted, free of charge, to any person obtaining a copy
5 | of this software and associated documentation files (the "Software"), to deal
6 | in the Software without restriction, including without limitation the rights
7 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
8 | copies of the Software, and to permit persons to whom the Software is
9 | furnished to do so, subject to the following conditions:
10 |
11 | The above copyright notice and this permission notice shall be included in
12 | all copies or substantial portions of the Software.
13 |
14 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
19 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
20 | THE SOFTWARE.
--------------------------------------------------------------------------------
/movie-streamer/README.md:
--------------------------------------------------------------------------------
1 | # Movie streamer
2 |
3 | Let's you choose the movies to stream
4 |
5 | # Installation
6 |
7 | ### Requirements
8 |
9 | Make sure you have [NPM](https://docs.npmjs.com/getting-started/installing-node) and [VLC media player](http://www.videolan.org) installed.
10 |
11 | The script requires following dependencies and downloads them automatically.
12 |
13 | 1. Requests
14 | 2. Beautiful Soup
15 | 3. Peerflix
16 |
17 | Install using pip globally:
18 |
19 | ```
20 | $ sudo pip install mstream
21 |
22 | ```
23 |
24 | Or build from Source:
25 |
26 | ```
27 | $ git clone https://github.com/vaulstein/7daysOfCode.git
28 | ```
29 | ```
30 | $ cd 7daysOfCode/movie-streamer
31 | ```
32 | ```
33 | $ python setup.py install
34 | ```
35 |
36 | ## RUN
37 |
38 | mstream
39 |
40 | Select the movie you want to watch:
41 |
42 | [](https://postimg.org/image/d2p22jtop/)
43 |
44 | ## TODO
45 |
46 | 1. Using Proxy server to scrape magnet links
47 | 2. Provide Advance search options to search movies/TV series
48 | [](https://postimg.org/image/lpto0gtu7/)
--------------------------------------------------------------------------------
/movie-streamer/bin/mstream:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env python
2 |
3 | import subprocess
4 | import sys
5 | import six
6 | from datetime import datetime
7 |
8 | import requests
9 | from bs4 import BeautifulSoup
10 |
11 | DEBUG = False
12 |
13 | def decoding_strings(f):
14 | def wrapper(*args, **kwargs):
15 | out = f(*args, **kwargs)
16 | if isinstance(out, six.string_types) and not six.PY3:
17 | # todo: make encoding configurable?
18 | if six.PY3:
19 | return out
20 | else:
21 | return out.decode(sys.stdin.encoding)
22 | return out
23 |
24 | return wrapper
25 |
26 |
27 | def _input_compat(prompt):
28 | if six.PY3:
29 | r = input(prompt)
30 | else:
31 | r = raw_input(prompt)
32 | return r
33 |
34 |
35 | if six.PY3:
36 | str_compat = str
37 | else:
38 | str_compat = unicode
39 |
40 | dateObject = 'YYYY-MM-DD'
41 |
42 |
43 | @decoding_strings
44 | def ask(question, answer=str_compat, default=None, l=None, options=None):
45 | if answer == str_compat:
46 | r = ''
47 | while True:
48 | if default:
49 | r = _input_compat('> {0} [{1}] '.format(question, default))
50 | else:
51 | r = _input_compat('> {0} '.format(question, default))
52 |
53 | r = r.strip()
54 |
55 | if len(r) <= 0:
56 | if default:
57 | r = default
58 | break
59 | else:
60 | print('You must enter something')
61 | else:
62 | if l and len(r) != l:
63 | print('You must enter a {0} letters long string'.format(l))
64 | else:
65 | break
66 |
67 | return r
68 |
69 | elif answer == bool:
70 | r = None
71 | while True:
72 | if default is True:
73 | r = _input_compat('> {0} (Y/n) '.format(question))
74 | elif default is False:
75 | r = _input_compat('> {0} (y/N) '.format(question))
76 | else:
77 | r = _input_compat('> {0} (y/n) '.format(question))
78 |
79 | r = r.strip().lower()
80 |
81 | if r in ('y', 'yes'):
82 | r = True
83 | break
84 | elif r in ('n', 'no'):
85 | r = False
86 | break
87 | elif not r:
88 | r = default
89 | break
90 | else:
91 | print("You must answer 'yes' or 'no'")
92 | return r
93 | elif answer == int:
94 | r = None
95 | while True:
96 | if default:
97 | r = _input_compat('> {0} [{1}] '.format(question, default))
98 | else:
99 | r = _input_compat('> {0} '.format(question))
100 |
101 | r = r.strip()
102 |
103 | if not r:
104 | r = default
105 | break
106 |
107 | try:
108 | r = int(r)
109 | break
110 | except:
111 | print('You must enter an integer')
112 | return r
113 | elif answer == list:
114 | # For checking multiple options
115 | r = None
116 | while True:
117 | if default:
118 | r = _input_compat('> {0} [{1}] '.format(question, default))
119 | else:
120 | r = _input_compat('> {0} '.format(question))
121 |
122 | r = r.strip()
123 |
124 | if not r:
125 | r = default
126 | break
127 |
128 | try:
129 | if int(r) in range(1, len(options) + 1):
130 | break
131 | else:
132 | print('Please select valid option: ' + ' or '.join('{}'.format(s) for _, s in enumerate(options)))
133 | except:
134 | print('Please select valid option: ' + ' or '.join('{}'.format(s) for _, s in enumerate(options)))
135 | return r
136 | if answer == dateObject:
137 | r = ''
138 | while True:
139 | if default:
140 | r = _input_compat('> {0} [{1}] '.format(question, default))
141 | else:
142 | r = _input_compat('> {0} '.format(question, default))
143 |
144 | r = r.strip()
145 |
146 | if not r:
147 | r = default
148 | break
149 |
150 | try:
151 | datetime.datetime.strptime(r, '%Y-%m-%d')
152 | break
153 | except ValueError:
154 | print("Incorrect data format, should be YYYY-MM-DD")
155 |
156 | return r
157 |
158 | else:
159 | raise NotImplemented(
160 | 'Argument `answer` must be str_compat, bool, or integer')
161 |
162 |
163 |
164 | def test_system():
165 | """Runs few tests to check if npm and peerflix is installed on the system."""
166 | if subprocess.check_call('npm --version', shell=True) != 0:
167 | print('NPM not installed installed, please read the Readme file for more information.')
168 | exit()
169 | if subprocess.check_call('peerflix --version', shell=True) != 0:
170 | print('Peerflix not installed, installing..')
171 | try:
172 | subprocess.check_call('npm install -g peerflix', shell=True)
173 | except subprocess.CalledProcessError as err:
174 | print('Installing as root user...')
175 | subprocess.check_call('sudo npm install -g peerflix', shell=True)
176 |
177 |
178 | def get_input():
179 | """Gets the input from user and formats it."""
180 | try:
181 | query = ' '.join(sys.argv[1:])
182 | movie_name = ' '.join(query.split()[0:])
183 | return movie_name
184 | except Exception as e:
185 | print(e)
186 | exit()
187 | return query
188 |
189 |
190 | def fetch_movie_names(movie_soup):
191 | movie_links = {}
192 | counter = 1
193 | movie_page = movie_soup.find_all("tr")
194 |
195 | for each in movie_page:
196 | all_links = each.find_all("a")
197 | title = None
198 | for each_link in all_links:
199 | if not title and each_link.get('title'):
200 | title = each_link.get('title')
201 | movie_links[counter] = {'title': title}
202 | if 'magnet:' in each_link.get('href'):
203 | movie_links[counter]['href'] = each_link.get('href')
204 | if title:
205 | counter += 1
206 | if counter > 20:
207 | break
208 | return movie_links
209 |
210 |
211 | def get_magnet_link(movie_name = 'harry potter'):
212 |
213 | URL = 'https://www.skytorrents.in/search/all/ed/1/?q='+movie_name.replace(' ', '+')
214 |
215 | resp = requests.get(URL)
216 | soup = BeautifulSoup(resp.text, 'html.parser')
217 | movie_list = fetch_movie_names(soup)
218 | print("Below are the Movies:")
219 | for index, movie in movie_list.items():
220 | print('%s: %s' % (index, movie['title']))
221 | selected_index = ask('Select one number from the above list',
222 | answer=list, default='1', options=range(1, 21))
223 | return movie_list[int(selected_index)]['href']
224 |
225 |
226 |
227 | def main():
228 | test_system()
229 | movie = get_input()
230 | try:
231 | print('Streaming Torrent')
232 | command = 'peerflix "'+get_magnet_link(movie)+'" --vlc'
233 | subprocess.check_call(command, shell=True)
234 | except Exception as e:
235 | print(e)
236 | exit()
237 |
238 | if __name__ == '__main__':
239 | main()
240 |
--------------------------------------------------------------------------------
/movie-streamer/mstream/__init__.py:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/vaulstein/7daysOfCode/e02b3a98a04753f0e60b8202f4a2f054837e57e0/movie-streamer/mstream/__init__.py
--------------------------------------------------------------------------------
/movie-streamer/requirements.txt:
--------------------------------------------------------------------------------
1 | appdirs==1.4.3
2 | beautifulsoup4==4.5.3
3 | packaging==16.8
4 | pkg-resources==0.0.0
5 | pyparsing==2.2.0
6 | requests==2.13.0
7 | six==1.10.0
8 |
--------------------------------------------------------------------------------
/movie-streamer/setup.py:
--------------------------------------------------------------------------------
1 |
2 | from setuptools import setup
3 |
4 | setup(name="mstream",
5 | version="0.2",
6 | description="Instantly stream movies/ tv episodes you want to watch",
7 | url="http://vaulstein.github.com",
8 | author="Vaulstein Rodrigues",
9 | author_email="vaulstein@gmail.com",
10 | license='MIT',
11 | packages=["mstream"],
12 | scripts=["bin/mstream"],
13 | install_requires=[
14 | 'BeautifulSoup4',
15 | 'requests'],
16 | zip_safe=False)
--------------------------------------------------------------------------------
/webcam-streamer/README.md:
--------------------------------------------------------------------------------
1 | ## Video Streaming with Flask Example
2 |
3 | Video Steaming using Webcam in Flask.
4 | Original code written by [log0](https://github.com/log0/video_streaming_with_flask_example)
5 |
6 | ### Description
7 | Modified to support streaming out with webcams, and not just raw JPEGs.
8 |
9 | ### Credits
10 | Original code written by log0 but the webcam streaming wasn't working with his code.
11 | As mentioned on this [subreddit](https://www.reddit.com/r/Python/comments/2xse4w/streaming_webcam_on_server_using_flask/)
12 |
13 | Most of the code credits to Miguel Grinberg.
14 | http://blog.miguelgrinberg.com/post/video-streaming-with-flask
15 |
16 | ### Usage
17 | 1. Install Python dependencies: cv2, flask. (wish that pip install works like a charm)
18 | 2. Run "python main.py".
19 | 3. Navigate the browser to the local webpage.
--------------------------------------------------------------------------------
/webcam-streamer/camera.py:
--------------------------------------------------------------------------------
1 | import cv2
2 |
3 | class VideoCamera(object):
4 | def __init__(self):
5 | # Using OpenCV to capture from device 0. If you have trouble capturing
6 | # from a webcam, comment the line below out and use a video file
7 | # instead.
8 | self.video = cv2.VideoCapture(0)
9 | # If you decide to use video.mp4, you must have this file in the folder
10 | # as the main.py.
11 | # self.video = cv2.VideoCapture('video.mp4')
12 |
13 | def __del__(self):
14 | self.video.release()
15 |
16 | def get_frame(self):
17 | success, image = self.video.read()
18 | # We are using Motion JPEG, but OpenCV defaults to capture raw images,
19 | # so we must encode it into JPEG in order to correctly display the
20 | # video stream.
21 | ret, jpeg = cv2.imencode('.jpg', image)
22 | return jpeg.tostring()
23 |
--------------------------------------------------------------------------------
/webcam-streamer/main.py:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env python
2 | from flask import Flask, render_template, Response
3 | from camera import VideoCamera
4 |
5 | app = Flask(__name__)
6 |
7 | @app.route('/')
8 | def index():
9 | return render_template('index.html')
10 |
11 | def gen(camera):
12 | while True:
13 | frame = camera.get_frame()
14 | yield ('--frame\r\n'
15 | 'Content-Type: image/jpeg\r\n\r\n' + frame + '\r\n\r\n')
16 |
17 | @app.route('/video_feed')
18 | def video_feed():
19 | return Response(gen(VideoCamera()),
20 | mimetype='multipart/x-mixed-replace; boundary=frame')
21 |
22 | if __name__ == '__main__':
23 | app.run(host='0.0.0.0', debug=True)
24 |
--------------------------------------------------------------------------------
/webcam-streamer/templates/index.html:
--------------------------------------------------------------------------------
1 |
2 |
3 | Video Streaming Demonstration
4 |
5 |
6 | Video Streaming Demonstration
7 |
8 |
9 |
--------------------------------------------------------------------------------