mirror of
https://github.com/metafy-social/python-scripts.git
synced 2025-03-13 17:19:50 +00:00
Merge branch 'metafy-social:master' into master
This commit is contained in:
commit
5b793720be
157
README.md
157
README.md
@ -73,21 +73,28 @@ Thanks a lot for spending your time helping! Keep rocking 🍻
|
||||
<sub><b>Null</b></sub>
|
||||
</a>
|
||||
</td>
|
||||
<td align="center">
|
||||
<a href="https://github.com/agnxsh">
|
||||
<img src="https://avatars.githubusercontent.com/u/80243668?v=4" width="100;" alt="agnxsh"/>
|
||||
<br />
|
||||
<sub><b>Agnish Ghosh</b></sub>
|
||||
</a>
|
||||
</td>
|
||||
<td align="center">
|
||||
<a href="https://github.com/muratonuryildirim">
|
||||
<img src="https://avatars.githubusercontent.com/u/77264793?v=4" width="100;" alt="muratonuryildirim"/>
|
||||
<br />
|
||||
<sub><b>Murat Onur Yildirim</b></sub>
|
||||
</a>
|
||||
</td>
|
||||
</td></tr>
|
||||
<tr>
|
||||
<td align="center">
|
||||
<a href="https://github.com/Ayudh-65">
|
||||
<img src="https://avatars.githubusercontent.com/u/68161774?v=4" width="100;" alt="Ayudh-65"/>
|
||||
<br />
|
||||
<sub><b>Null</b></sub>
|
||||
</a>
|
||||
</td></tr>
|
||||
<tr>
|
||||
</td>
|
||||
<td align="center">
|
||||
<a href="https://github.com/Abbhiishek">
|
||||
<img src="https://avatars.githubusercontent.com/u/86338762?v=4" width="100;" alt="Abbhiishek"/>
|
||||
@ -95,13 +102,6 @@ Thanks a lot for spending your time helping! Keep rocking 🍻
|
||||
<sub><b>Abhishek Kushwaha</b></sub>
|
||||
</a>
|
||||
</td>
|
||||
<td align="center">
|
||||
<a href="https://github.com/agnxsh">
|
||||
<img src="https://avatars.githubusercontent.com/u/80243668?v=4" width="100;" alt="agnxsh"/>
|
||||
<br />
|
||||
<sub><b>Agnish Ghosh</b></sub>
|
||||
</a>
|
||||
</td>
|
||||
<td align="center">
|
||||
<a href="https://github.com/Farhan-2222">
|
||||
<img src="https://avatars.githubusercontent.com/u/87274221?v=4" width="100;" alt="Farhan-2222"/>
|
||||
@ -181,6 +181,13 @@ Thanks a lot for spending your time helping! Keep rocking 🍻
|
||||
<sub><b>Sawan Bhattacharya</b></sub>
|
||||
</a>
|
||||
</td>
|
||||
<td align="center">
|
||||
<a href="https://github.com/SiddheshKukade">
|
||||
<img src="https://avatars.githubusercontent.com/u/65951872?v=4" width="100;" alt="SiddheshKukade"/>
|
||||
<br />
|
||||
<sub><b>Siddhesh Bhupendra Kuakde</b></sub>
|
||||
</a>
|
||||
</td>
|
||||
<td align="center">
|
||||
<a href="https://github.com/Sourodip20kar">
|
||||
<img src="https://avatars.githubusercontent.com/u/104223444?v=4" width="100;" alt="Sourodip20kar"/>
|
||||
@ -208,6 +215,14 @@ Thanks a lot for spending your time helping! Keep rocking 🍻
|
||||
<br />
|
||||
<sub><b>Kunal Patil</b></sub>
|
||||
</a>
|
||||
</td></tr>
|
||||
<tr>
|
||||
<td align="center">
|
||||
<a href="https://github.com/Mysterious-Owl">
|
||||
<img src="https://avatars.githubusercontent.com/u/66870959?v=4" width="100;" alt="Mysterious-Owl"/>
|
||||
<br />
|
||||
<sub><b>Mysterious-Owl</b></sub>
|
||||
</a>
|
||||
</td>
|
||||
<td align="center">
|
||||
<a href="https://github.com/PritamP20">
|
||||
@ -215,8 +230,14 @@ Thanks a lot for spending your time helping! Keep rocking 🍻
|
||||
<br />
|
||||
<sub><b>Null</b></sub>
|
||||
</a>
|
||||
</td></tr>
|
||||
<tr>
|
||||
</td>
|
||||
<td align="center">
|
||||
<a href="https://github.com/rahulkarda">
|
||||
<img src="https://avatars.githubusercontent.com/u/76204863?v=4" width="100;" alt="rahulkarda"/>
|
||||
<br />
|
||||
<sub><b>Rahul Karda</b></sub>
|
||||
</a>
|
||||
</td>
|
||||
<td align="center">
|
||||
<a href="https://github.com/yunghog">
|
||||
<img src="https://avatars.githubusercontent.com/u/41548444?v=4" width="100;" alt="yunghog"/>
|
||||
@ -224,6 +245,21 @@ Thanks a lot for spending your time helping! Keep rocking 🍻
|
||||
<sub><b>YUNGH OG</b></sub>
|
||||
</a>
|
||||
</td>
|
||||
<td align="center">
|
||||
<a href="https://github.com/Tiagupt03">
|
||||
<img src="https://avatars.githubusercontent.com/u/98590820?v=4" width="100;" alt="Tiagupt03"/>
|
||||
<br />
|
||||
<sub><b>Tiya Gupta</b></sub>
|
||||
</a>
|
||||
</td>
|
||||
<td align="center">
|
||||
<a href="https://github.com/varunKT001">
|
||||
<img src="https://avatars.githubusercontent.com/u/83509023?v=4" width="100;" alt="varunKT001"/>
|
||||
<br />
|
||||
<sub><b>Varun Tiwari</b></sub>
|
||||
</a>
|
||||
</td></tr>
|
||||
<tr>
|
||||
<td align="center">
|
||||
<a href="https://github.com/avyayjain">
|
||||
<img src="https://avatars.githubusercontent.com/u/63355322?v=4" width="100;" alt="avyayjain"/>
|
||||
@ -231,6 +267,13 @@ Thanks a lot for spending your time helping! Keep rocking 🍻
|
||||
<sub><b>Avyay Jain</b></sub>
|
||||
</a>
|
||||
</td>
|
||||
<td align="center">
|
||||
<a href="https://github.com/drk1rd">
|
||||
<img src="https://avatars.githubusercontent.com/u/58465650?v=4" width="100;" alt="drk1rd"/>
|
||||
<br />
|
||||
<sub><b>Drk1rd</b></sub>
|
||||
</a>
|
||||
</td>
|
||||
<td align="center">
|
||||
<a href="https://github.com/lordvader501">
|
||||
<img src="https://avatars.githubusercontent.com/u/60027612?v=4" width="100;" alt="lordvader501"/>
|
||||
@ -238,13 +281,28 @@ Thanks a lot for spending your time helping! Keep rocking 🍻
|
||||
<sub><b>Null</b></sub>
|
||||
</a>
|
||||
</td>
|
||||
<td align="center">
|
||||
<a href="https://github.com/rohitgarud21">
|
||||
<img src="https://avatars.githubusercontent.com/u/115347445?v=4" width="100;" alt="rohitgarud21"/>
|
||||
<br />
|
||||
<sub><b>Null</b></sub>
|
||||
</a>
|
||||
</td>
|
||||
<td align="center">
|
||||
<a href="https://github.com/shreyan-naskar">
|
||||
<img src="https://avatars.githubusercontent.com/u/93477634?v=4" width="100;" alt="shreyan-naskar"/>
|
||||
<br />
|
||||
<sub><b>Shreyan Naskar</b></sub>
|
||||
</a>
|
||||
</td>
|
||||
<td align="center">
|
||||
<a href="https://github.com/tolgakurtuluss">
|
||||
<img src="https://avatars.githubusercontent.com/u/22731161?v=4" width="100;" alt="tolgakurtuluss"/>
|
||||
<br />
|
||||
<sub><b>Null</b></sub>
|
||||
</a>
|
||||
</td>
|
||||
</td></tr>
|
||||
<tr>
|
||||
<td align="center">
|
||||
<a href="https://github.com/srinjoy-26">
|
||||
<img src="https://avatars.githubusercontent.com/u/91176055?v=4" width="100;" alt="srinjoy-26"/>
|
||||
@ -258,8 +316,7 @@ Thanks a lot for spending your time helping! Keep rocking 🍻
|
||||
<br />
|
||||
<sub><b>Shradha</b></sub>
|
||||
</a>
|
||||
</td></tr>
|
||||
<tr>
|
||||
</td>
|
||||
<td align="center">
|
||||
<a href="https://github.com/NishantPacharne">
|
||||
<img src="https://avatars.githubusercontent.com/u/71060551?v=4" width="100;" alt="NishantPacharne"/>
|
||||
@ -287,12 +344,13 @@ Thanks a lot for spending your time helping! Keep rocking 🍻
|
||||
<br />
|
||||
<sub><b>Hemant</b></sub>
|
||||
</a>
|
||||
</td>
|
||||
</td></tr>
|
||||
<tr>
|
||||
<td align="center">
|
||||
<a href="https://github.com/Mysterious-Owl">
|
||||
<img src="https://avatars.githubusercontent.com/u/66870959?v=4" width="100;" alt="Mysterious-Owl"/>
|
||||
<a href="https://github.com/MayuriKolhe-2003">
|
||||
<img src="https://avatars.githubusercontent.com/u/77161474?v=4" width="100;" alt="MayuriKolhe-2003"/>
|
||||
<br />
|
||||
<sub><b>Mysterious-Owl</b></sub>
|
||||
<sub><b>Mayuri Kolhe</b></sub>
|
||||
</a>
|
||||
</td>
|
||||
<td align="center">
|
||||
@ -301,14 +359,6 @@ Thanks a lot for spending your time helping! Keep rocking 🍻
|
||||
<br />
|
||||
<sub><b>Parinthapat P.</b></sub>
|
||||
</a>
|
||||
</td></tr>
|
||||
<tr>
|
||||
<td align="center">
|
||||
<a href="https://github.com/rahulkarda">
|
||||
<img src="https://avatars.githubusercontent.com/u/76204863?v=4" width="100;" alt="rahulkarda"/>
|
||||
<br />
|
||||
<sub><b>Rahul Karda</b></sub>
|
||||
</a>
|
||||
</td>
|
||||
<td align="center">
|
||||
<a href="https://github.com/royninja">
|
||||
@ -318,10 +368,10 @@ Thanks a lot for spending your time helping! Keep rocking 🍻
|
||||
</a>
|
||||
</td>
|
||||
<td align="center">
|
||||
<a href="https://github.com/SiddheshKukade">
|
||||
<img src="https://avatars.githubusercontent.com/u/65951872?v=4" width="100;" alt="SiddheshKukade"/>
|
||||
<a href="https://github.com/ambushneupane">
|
||||
<img src="https://avatars.githubusercontent.com/u/56769633?v=4" width="100;" alt="ambushneupane"/>
|
||||
<br />
|
||||
<sub><b>Siddhesh Bhupendra Kuakde</b></sub>
|
||||
<sub><b>Ambush</b></sub>
|
||||
</a>
|
||||
</td>
|
||||
<td align="center">
|
||||
@ -337,21 +387,14 @@ Thanks a lot for spending your time helping! Keep rocking 🍻
|
||||
<br />
|
||||
<sub><b>Null</b></sub>
|
||||
</a>
|
||||
</td>
|
||||
</td></tr>
|
||||
<tr>
|
||||
<td align="center">
|
||||
<a href="https://github.com/noobyysauraj">
|
||||
<img src="https://avatars.githubusercontent.com/u/81681419?v=4" width="100;" alt="noobyysauraj"/>
|
||||
<br />
|
||||
<sub><b>Sauraj</b></sub>
|
||||
</a>
|
||||
</td></tr>
|
||||
<tr>
|
||||
<td align="center">
|
||||
<a href="https://github.com/shreyan-naskar">
|
||||
<img src="https://avatars.githubusercontent.com/u/93477634?v=4" width="100;" alt="shreyan-naskar"/>
|
||||
<br />
|
||||
<sub><b>Shreyan Naskar</b></sub>
|
||||
</a>
|
||||
</td>
|
||||
<td align="center">
|
||||
<a href="https://github.com/accodes21">
|
||||
@ -410,13 +453,6 @@ Thanks a lot for spending your time helping! Keep rocking 🍻
|
||||
<sub><b>Manice18</b></sub>
|
||||
</a>
|
||||
</td>
|
||||
<td align="center">
|
||||
<a href="https://github.com/MayuriKolhe-2003">
|
||||
<img src="https://avatars.githubusercontent.com/u/77161474?v=4" width="100;" alt="MayuriKolhe-2003"/>
|
||||
<br />
|
||||
<sub><b>Mayuri Kolhe</b></sub>
|
||||
</a>
|
||||
</td>
|
||||
<td align="center">
|
||||
<a href="https://github.com/LEO1612D">
|
||||
<img src="https://avatars.githubusercontent.com/u/46849277?v=4" width="100;" alt="LEO1612D"/>
|
||||
@ -430,14 +466,21 @@ Thanks a lot for spending your time helping! Keep rocking 🍻
|
||||
<br />
|
||||
<sub><b>Rahul Kumar</b></sub>
|
||||
</a>
|
||||
</td></tr>
|
||||
<tr>
|
||||
</td>
|
||||
<td align="center">
|
||||
<a href="https://github.com/Morbius00">
|
||||
<img src="https://avatars.githubusercontent.com/u/102956488?v=4" width="100;" alt="Morbius00"/>
|
||||
<br />
|
||||
<sub><b>Raj Saha </b></sub>
|
||||
</a>
|
||||
</td></tr>
|
||||
<tr>
|
||||
<td align="center">
|
||||
<a href="https://github.com/ramonsaraiva">
|
||||
<img src="https://avatars.githubusercontent.com/u/5559120?v=4" width="100;" alt="ramonsaraiva"/>
|
||||
<br />
|
||||
<sub><b>Ramon Saraiva</b></sub>
|
||||
</a>
|
||||
</td>
|
||||
<td align="center">
|
||||
<a href="https://github.com/riyajaiswal25">
|
||||
@ -467,21 +510,14 @@ Thanks a lot for spending your time helping! Keep rocking 🍻
|
||||
<sub><b>Tejaswi Kumar</b></sub>
|
||||
</a>
|
||||
</td>
|
||||
<td align="center">
|
||||
<a href="https://github.com/varunKT001">
|
||||
<img src="https://avatars.githubusercontent.com/u/83509023?v=4" width="100;" alt="varunKT001"/>
|
||||
<br />
|
||||
<sub><b>Varun Tiwari</b></sub>
|
||||
</a>
|
||||
</td></tr>
|
||||
<tr>
|
||||
<td align="center">
|
||||
<a href="https://github.com/anjali1102">
|
||||
<img src="https://avatars.githubusercontent.com/u/56559378?v=4" width="100;" alt="anjali1102"/>
|
||||
<br />
|
||||
<sub><b>Anjali Chauhan</b></sub>
|
||||
</a>
|
||||
</td>
|
||||
</td></tr>
|
||||
<tr>
|
||||
<td align="center">
|
||||
<a href="https://github.com/arpitbhardwaj">
|
||||
<img src="https://avatars.githubusercontent.com/u/23013825?v=4" width="100;" alt="arpitbhardwaj"/>
|
||||
@ -503,6 +539,13 @@ Thanks a lot for spending your time helping! Keep rocking 🍻
|
||||
<sub><b>Null</b></sub>
|
||||
</a>
|
||||
</td>
|
||||
<td align="center">
|
||||
<a href="https://github.com/codeswithroh">
|
||||
<img src="https://avatars.githubusercontent.com/u/77570394?v=4" width="100;" alt="codeswithroh"/>
|
||||
<br />
|
||||
<sub><b>Rohit Purkait</b></sub>
|
||||
</a>
|
||||
</td>
|
||||
<td align="center">
|
||||
<a href="https://github.com/devtayade">
|
||||
<img src="https://avatars.githubusercontent.com/u/84332795?v=4" width="100;" alt="devtayade"/>
|
||||
|
16
scripts/BMI/bmi.py
Normal file
16
scripts/BMI/bmi.py
Normal file
@ -0,0 +1,16 @@
|
||||
Height=float(input("Enter your height in centimeters: "))
|
||||
Weight=float(input("Enter your Weight in Kg: "))
|
||||
Height = Height/100
|
||||
BMI=Weight/(Height*Height)
|
||||
print("your Body Mass Index is: ",BMI)
|
||||
if(BMI>0):
|
||||
if(BMI<=16):
|
||||
print("you are severely underweight")
|
||||
elif(BMI<=18.5):
|
||||
print("you are underweight")
|
||||
elif(BMI<=25):
|
||||
print("you are Healthy")
|
||||
elif(BMI<=30):
|
||||
print("you are overweight")
|
||||
else: print("you are severely overweight")
|
||||
else:("enter valid details")
|
4
scripts/BMI/readme.md
Normal file
4
scripts/BMI/readme.md
Normal file
@ -0,0 +1,4 @@
|
||||
BMI calculator with PYTHON
|
||||
|
||||
#Steps :
|
||||
Run - python bmi.py
|
After Width: | Height: | Size: 57 B |
8
scripts/Base_Conversion/README.md
Normal file
8
scripts/Base_Conversion/README.md
Normal file
@ -0,0 +1,8 @@
|
||||
# BASE CONVERSION IN PYTHON
|
||||
- Various functions for interconversion of bases
|
||||
- Conversion of Binary to Decimal
|
||||
- Conversion of Octal to Decimal
|
||||
- Conversion of Hexadecimal to Decimal
|
||||
- Conversion of Decimal to Binary
|
||||
- Conversion of Decimal to Octal
|
||||
- Conversion of Decimal to Hexaecimal
|
162
scripts/Base_Conversion/main.py
Normal file
162
scripts/Base_Conversion/main.py
Normal file
@ -0,0 +1,162 @@
|
||||
|
||||
#Function to calculate x raised to the power y
|
||||
def Power( x , y ) :
|
||||
|
||||
if (y == 0) :
|
||||
return 1
|
||||
|
||||
else :
|
||||
|
||||
ans = x**y
|
||||
return ans
|
||||
|
||||
|
||||
#Function to convert Binary to Decimal
|
||||
def BinaryToDecimal( n ) :
|
||||
|
||||
ans = 0
|
||||
x = 1
|
||||
m = int(n)
|
||||
|
||||
while m > 0 :
|
||||
b = m%10
|
||||
ans += b*x
|
||||
x = x*2
|
||||
m = m//10
|
||||
|
||||
return ans
|
||||
|
||||
|
||||
#Function to convert Octal to Decimal
|
||||
def OctalToDecimal( n ) :
|
||||
|
||||
ans = 0
|
||||
x = 1
|
||||
m = int(n)
|
||||
|
||||
while m > 0 :
|
||||
b = m%10
|
||||
ans += b*x
|
||||
x = x*8
|
||||
m = m//10
|
||||
|
||||
return ans
|
||||
|
||||
|
||||
#Function to convert Hexadecimal to Decimal
|
||||
def HexadecimalToDecimal( n ):
|
||||
|
||||
ans = 0
|
||||
x = 1
|
||||
s = len( n )
|
||||
|
||||
for i in range( s-1 , -1 , -1 ) :
|
||||
if n[i] >= '0' and n[i] <= '9' :
|
||||
ans += x*(int(n[i]))
|
||||
|
||||
elif n[i] >= 'A' and n[i] <= 'F' :
|
||||
ans += x*(ord(n[i]) - ord('A') + 10)
|
||||
|
||||
x = x*16
|
||||
|
||||
return ans
|
||||
|
||||
|
||||
#Function to convert Decimal to Binary
|
||||
def DecimalToBinary( n ) :
|
||||
L = []
|
||||
while(n>0):
|
||||
rem = n%2
|
||||
L.append(rem)
|
||||
n = n//2
|
||||
#L = L[::-1]
|
||||
|
||||
dec = 0
|
||||
for i in range(0,len(L)):
|
||||
dec = dec + L[i]*(10**i)
|
||||
|
||||
return dec
|
||||
|
||||
#Function to convert Decimal to Octal
|
||||
def DecimalToOctal( n ) :
|
||||
|
||||
ans = 0
|
||||
count = 0
|
||||
|
||||
while (n > 0) :
|
||||
lastDigit = n%8
|
||||
ans += lastDigit*(10**(count))
|
||||
n = n//8
|
||||
|
||||
count += 1
|
||||
|
||||
return ans
|
||||
|
||||
|
||||
#Function to convert Decimal to Hexadecimal
|
||||
def DecimaltoHexadecimal( n ) :
|
||||
|
||||
ans = ''
|
||||
|
||||
while (n > 0) :
|
||||
lastDigit = n%16
|
||||
if (lastDigit >= 0 and lastDigit <=9 ) :
|
||||
ans = ans + str(lastDigit)
|
||||
|
||||
elif (lastDigit >= 10 and lastDigit <= 15) :
|
||||
a = chr(ord('A') + (lastDigit-10))
|
||||
ans = ans + a
|
||||
|
||||
n = n//16
|
||||
|
||||
return ans[::-1]
|
||||
|
||||
while True:
|
||||
print('1 -> Calculate Exponents')
|
||||
print('2 -> convert Binary to Decimal ')
|
||||
print('3 -> convert Octal to Decimal ')
|
||||
print('4 -> convert Hexadecimal to Decimal ')
|
||||
print('5 -> convert Decimal to Binary ')
|
||||
print('6 -> convert Decimal to Octal ')
|
||||
print('7 -> convert Decimal to Hexadecimal ')
|
||||
print('0 -> Exit')
|
||||
|
||||
|
||||
n = int(input('\nEnter: '))
|
||||
|
||||
if n == 1:
|
||||
a,b = int(input("Enter Base :\n")),int(input("Enter Superscript : \n"))
|
||||
print("The result is : ",Power(a,b), "\n")
|
||||
|
||||
elif n == 2:
|
||||
b = int(input("Enter Binary Number:\n"))
|
||||
print("Corresponding Decimal Number is : ", BinaryToDecimal(b), "\n")
|
||||
|
||||
elif n == 3:
|
||||
b = int(input("Enter Octal Number:\n"))
|
||||
print("Corresponding Decimal Number is : ", OctalToDecimal(b), "\n")
|
||||
|
||||
elif n == 4:
|
||||
b = (input("Enter Hexadecimal Number:\n"))
|
||||
print("Corresponding Decimal Number is : ", HexadecimalToDecimal(b), "\n")
|
||||
|
||||
elif n == 5:
|
||||
b = int(input("Enter Decimal Number:\n"))
|
||||
print("Corresponding Binary Number is : ", DecimalToBinary(b), "\n")
|
||||
|
||||
elif n == 6:
|
||||
b = int(input("Enter Decimal Number:\n"))
|
||||
print("Corresponding Octal Number is : ", DecimalToOctal(b), "\n")
|
||||
|
||||
elif n == 7:
|
||||
b = int(input("Enter Decimal Number:\n"))
|
||||
print("Corresponding Hexadecimal Number is : ", DecimaltoHexadecimal(b), "\n")
|
||||
|
||||
elif n == 0:
|
||||
|
||||
exit()
|
||||
|
||||
else:
|
||||
print("\nNo such option exists!! ")
|
||||
|
||||
|
16
scripts/GeoCode API/README.md
Normal file
16
scripts/GeoCode API/README.md
Normal file
@ -0,0 +1,16 @@
|
||||
# Google Maps API
|
||||
|
||||
This code will take the name of places from where.txt and then use *forward Geocode API* to get the coordinates of that location, then the coordinates are stored in javascript file and the webpage is opened automatically, to show the pin locations on map.<br>
|
||||
|
||||
### Prerequisites
|
||||
|
||||
To install configparser ```pip install configparser``` or check [here](https://pypi.org/project/configparser/)
|
||||
If you have [Google Geocode API](https://developers.google.com/maps/documentation/geocoding/overview), so use that, otherwise you can use
|
||||
[Open Cage API](https://opencagedata.com/api) (its free, 2500 requests/day).
|
||||
|
||||
### How to run the script
|
||||
|
||||
Enter the API key and service URL in config file (without qoutes) and the places to be marked in where.txt file, then run the script.
|
||||
|
||||
|
||||
|
61
scripts/GeoCode API/code.py
Normal file
61
scripts/GeoCode API/code.py
Normal file
@ -0,0 +1,61 @@
|
||||
import urllib.request
|
||||
import urllib.parse
|
||||
import urllib.error
|
||||
import json
|
||||
import os
|
||||
import webbrowser
|
||||
import ssl
|
||||
import configparser
|
||||
|
||||
config = configparser.ConfigParser()
|
||||
config.read('config.ini')
|
||||
|
||||
api_key = config['keys']['api_key']
|
||||
service_url = config['keys']['service_url']
|
||||
|
||||
# Ignore SSL certificate errors
|
||||
ctx = ssl.create_default_context()
|
||||
ctx.check_hostname = False
|
||||
ctx.verify_mode = ssl.CERT_NONE
|
||||
|
||||
with open("where.txt") as fh, open("where.js", "w", encoding="utf-8") as where:
|
||||
adrs = []
|
||||
parms = {}
|
||||
for line in fh:
|
||||
|
||||
address = line.strip()
|
||||
parms["address"] = address
|
||||
parms['key'] = api_key
|
||||
url = service_url + urllib.parse.urlencode(parms)
|
||||
|
||||
if url.lower().startswith('http'):
|
||||
req = urllib.request.Request(url)
|
||||
else:
|
||||
raise ValueError from None
|
||||
|
||||
with urllib.request.urlopen(req, context=ctx) as resp:
|
||||
|
||||
data = resp.read().decode()
|
||||
|
||||
try:
|
||||
js = json.loads(data)
|
||||
except Exception as e:
|
||||
print(f"{e}: {data}")
|
||||
continue
|
||||
|
||||
try:
|
||||
adrs.append([js['results'][0]['geometry']['lat'],
|
||||
js['results'][0]['geometry']['lng'],
|
||||
js['results'][0]['formatted']])
|
||||
print('Retrieved ', url)
|
||||
except Exception as e:
|
||||
print(f"Not Found: {e}: {line.strip()}")
|
||||
|
||||
print("\nOpening Webpage")
|
||||
|
||||
where.write("myData = [\n")
|
||||
for item in adrs:
|
||||
where.write(f"[{str(item[0])}, {str(item[1])}, '{str(item[2])}' ], \n")
|
||||
where.write("];\n")
|
||||
|
||||
webbrowser.open('file://' + os.path.realpath("index.html"))
|
3
scripts/GeoCode API/config.ini
Normal file
3
scripts/GeoCode API/config.ini
Normal file
@ -0,0 +1,3 @@
|
||||
[keys]
|
||||
service_url=https://api.opencagedata.com/geocode/v1/json?q=
|
||||
api_key=
|
48
scripts/GeoCode API/index.html
Normal file
48
scripts/GeoCode API/index.html
Normal file
@ -0,0 +1,48 @@
|
||||
<html>
|
||||
<head>
|
||||
<meta name="viewport" content="initial-scale=1.0, user-scalable=no">
|
||||
<meta charset="utf-8">
|
||||
<title>GOOGLE MAPS API</title>
|
||||
<link href="https://google-developers.appspot.com/maps/documentation/javascript/examples/default.css" rel="stylesheet">
|
||||
<script src="https://maps.googleapis.com/maps/api/js"></script>
|
||||
<script src="where.js"></script>
|
||||
<script>
|
||||
function initialize() {
|
||||
var myLatlng = new google.maps.LatLng(37.39361,-122.099263)
|
||||
var mapOptions = {
|
||||
zoom: 3,
|
||||
center: myLatlng,
|
||||
mapTypeId: google.maps.MapTypeId.ROADMAP
|
||||
}
|
||||
var map = new google.maps.Map(document.getElementById('map_canvas'), mapOptions);
|
||||
i = 0;
|
||||
var markers = [];
|
||||
for ( pos in myData ) {
|
||||
i = i + 1;
|
||||
var row = myData[pos];
|
||||
window.console && console.log(row);
|
||||
var newLatlng = new google.maps.LatLng(row[0], row[1]);
|
||||
var marker = new google.maps.Marker({
|
||||
position: newLatlng,
|
||||
map: map,
|
||||
title: row[2]
|
||||
});
|
||||
markers.push(marker);
|
||||
var options = {
|
||||
imagePath: 'http://rawgit.com/googlemaps/js-marker-clusterer/gh-pages/images/m'
|
||||
}
|
||||
}
|
||||
var markerCluster = new MarkerClusterer(map, markers, options);
|
||||
}
|
||||
</script>
|
||||
</head>
|
||||
<body onload="initialize()">
|
||||
<div id="map_canvas" style="height: 500px"></div>
|
||||
<p><b>About this Map</b></p>
|
||||
<p>
|
||||
This is a cool script by
|
||||
<a href="https://github.com/Mysterious-Owl">Mysterious-Owl</a> with the use of API.<br>
|
||||
To see the details of a marker, hover over the marker.
|
||||
</p>
|
||||
</body>
|
||||
</html>
|
2
scripts/GeoCode API/requirements.txt
Normal file
2
scripts/GeoCode API/requirements.txt
Normal file
@ -0,0 +1,2 @@
|
||||
configparser
|
||||
ssl
|
24
scripts/GeoCode API/where.js
Normal file
24
scripts/GeoCode API/where.js
Normal file
@ -0,0 +1,24 @@
|
||||
myData = [
|
||||
[41.89193, 12.51133, 'Rome, Italy' ],
|
||||
[12.937243, 77.6925796, 'The Address, Outer Ring Road, Kaadubeesanahalli, Bengaluru - 530103, Karnataka, India' ],
|
||||
[51.575646, -0.0986474, 'Address, Endymion Road, London, N4 1EQ, United Kingdom' ],
|
||||
[-33.86785, 151.20732, 'Sydney, Australia' ],
|
||||
[35.6718484, 139.7419907, 'Address Building, Sotobori-dori, Akasaka 2-chome, Minato, 100-8968, Japan' ],
|
||||
[55.75222, 37.61556, 'Moscow, Russia' ],
|
||||
[34.05223, -118.24368, 'Los Angeles, California, United States of America' ],
|
||||
[-23.582841, -46.6847335, 'Hotel Intercity Adress Faria Lima, Rua Amauri 513, Vila Olímpia, São Paulo - SP, 01453-020, Brazil' ],
|
||||
[-33.92584, 18.42322, 'Cape Town, City of Cape Town, South Africa' ],
|
||||
[22.28552, 114.15769, 'Hong Kong' ],
|
||||
[30.0439192, 30.9812426, 'District 12, Sheikh Zayed, Giza, Egypt' ],
|
||||
[43.6557254, -79.456573, 'The Address at High Park, 1638 Bloor Street West, Toronto, ON M6P 0A6, Canada' ],
|
||||
[-20.0, 47.0, 'Madagascar' ],
|
||||
[1.114186, 103.9852544, 'Manisee Syariah Homestay (actual address), Tiban Mc Dermoth, Batam City 29427, Riau Islands, Indonesia' ],
|
||||
[64.00028, -150.00028, 'Alaska, United States of America' ],
|
||||
[18.0, -2.0, 'Mali' ],
|
||||
[60.0, 100.0, 'Russia' ],
|
||||
[62.0, 10.0, 'Norway' ],
|
||||
[-23.2029627, -65.3474844, 'La Nueva Puerta Verde good (good address), Avenida General Belgrano, Humahuaca, Municipio de Humahuaca, Argentina' ],
|
||||
[20.75028, -156.50028, 'Hawaii, United States of America' ],
|
||||
[46.0, 105.0, 'Mongolia' ],
|
||||
[-37.9032307, 144.7585649, 'The Address, Point Cook VIC 3030, Australia' ],
|
||||
];
|
22
scripts/GeoCode API/where.txt
Normal file
22
scripts/GeoCode API/where.txt
Normal file
@ -0,0 +1,22 @@
|
||||
rome
|
||||
delhi
|
||||
london
|
||||
sydney
|
||||
japan
|
||||
moscow
|
||||
los angeles
|
||||
brazil
|
||||
cape town
|
||||
hong kong
|
||||
egypt
|
||||
canada
|
||||
madagascar
|
||||
indonesia
|
||||
alaska
|
||||
mali
|
||||
russia
|
||||
norway
|
||||
argentina
|
||||
hawaii
|
||||
mongolia
|
||||
australia
|
4
scripts/JSON-to-YAML Converter/README.md
Normal file
4
scripts/JSON-to-YAML Converter/README.md
Normal file
@ -0,0 +1,4 @@
|
||||
### JSON to YAML file converter
|
||||
Takes JSON data and converts it into YAML file by braking the JSON array and using the YAML library of python
|
||||
### To Execute the code
|
||||
`json2yaml.py input_file.json output_file.yaml`
|
35
scripts/JSON-to-YAML Converter/json2yaml.py
Normal file
35
scripts/JSON-to-YAML Converter/json2yaml.py
Normal file
@ -0,0 +1,35 @@
|
||||
import json
|
||||
import os
|
||||
import sys
|
||||
import yaml
|
||||
|
||||
# Checking there is a file name passed
|
||||
if len(sys.argv) > 1:
|
||||
# Opening the file
|
||||
if os.path.exists(sys.argv[1]):
|
||||
source_file = open(sys.argv[1], "r")
|
||||
source_content = json.load(source_file)
|
||||
source_file.close()
|
||||
# Failikng if the file isn't found
|
||||
else:
|
||||
print("ERROR: " + sys.argv[1] + " not found")
|
||||
exit(1)
|
||||
# No file, no usage
|
||||
else:
|
||||
print("Usage: json2yaml.py <source_file.json> [target_file.yaml]")
|
||||
|
||||
# Processing the conversion
|
||||
output = yaml.dump(source_content)
|
||||
|
||||
# If no target file send to stdout
|
||||
if len(sys.argv) < 3:
|
||||
print(output)
|
||||
# If the target file already exists exit
|
||||
elif os.path.exists(sys.argv[2]):
|
||||
print("ERROR: " + sys.argv[2] + " already exists")
|
||||
exit(1)
|
||||
# Otherwise write to the specified file
|
||||
else:
|
||||
target_file = open(sys.argv[2], "w")
|
||||
target_file.write(output)
|
||||
target_file.close()
|
3
scripts/Movie_Recommendation_API/README.md
Normal file
3
scripts/Movie_Recommendation_API/README.md
Normal file
@ -0,0 +1,3 @@
|
||||
# Mood based movie recommendation API
|
||||
|
||||
This is a simple api created with Python and IMDB api. This takes in mood as the input and returns back the recommended movie to watch.
|
@ -0,0 +1,72 @@
|
||||
from bs4 import BeautifulSoup as SOUP
|
||||
from fastapi.middleware.cors import CORSMiddleware
|
||||
from fastapi import FastAPI
|
||||
import requests as HTTP
|
||||
import json
|
||||
import re
|
||||
|
||||
app = FastAPI()
|
||||
|
||||
app.add_middleware(
|
||||
CORSMiddleware,
|
||||
allow_origins=["*"],
|
||||
allow_credentials=False,
|
||||
allow_methods=["*"],
|
||||
allow_headers=["*"],
|
||||
)
|
||||
|
||||
|
||||
@app.get("/")
|
||||
async def root():
|
||||
return {"message": "Hello World"}
|
||||
|
||||
@app.get("/movies/")
|
||||
async def read_item(emotion: str):
|
||||
urlhere=""
|
||||
if(emotion == "Sad"):
|
||||
urlhere = 'http://www.imdb.com/search/title?genres=drama&title_type=feature&sort=moviemeter, asc'
|
||||
|
||||
elif(emotion == "Disgust"):
|
||||
urlhere = 'http://www.imdb.com/search/title?genres=musical&title_type=feature&sort=moviemeter, asc'
|
||||
|
||||
elif(emotion == "Anger"):
|
||||
urlhere = 'http://www.imdb.com/search/title?genres=family&title_type=feature&sort=moviemeter, asc'
|
||||
|
||||
elif(emotion == "Anticipation"):
|
||||
urlhere = 'http://www.imdb.com/search/title?genres=thriller&title_type=feature&sort=moviemeter, asc'
|
||||
|
||||
elif(emotion == "Fear"):
|
||||
urlhere = 'http://www.imdb.com/search/title?genres=sport&title_type=feature&sort=moviemeter, asc'
|
||||
|
||||
elif(emotion == "Enjoyment"):
|
||||
urlhere = 'http://www.imdb.com/search/title?genres=thriller&title_type=feature&sort=moviemeter, asc'
|
||||
|
||||
elif(emotion == "Trust"):
|
||||
urlhere = 'http://www.imdb.com/search/title?genres=western&title_type=feature&sort=moviemeter, asc'
|
||||
|
||||
elif(emotion == "Surprise"):
|
||||
urlhere = 'http://www.imdb.com/search/title?genres=film_noir&title_type=feature&sort=moviemeter, asc'
|
||||
|
||||
|
||||
response = HTTP.get(urlhere)
|
||||
data = response.text
|
||||
|
||||
soup = SOUP(data, "lxml")
|
||||
|
||||
movie_title = soup.find_all("a", attrs = {"href" : re.compile(r'\/title\/tt+\d*\/')})
|
||||
movie = []
|
||||
title = []
|
||||
|
||||
for i in movie_title:
|
||||
tmp = str(i).split('>')
|
||||
|
||||
if(len(tmp) == 3):
|
||||
title.append(tmp[1][:-3])
|
||||
|
||||
for i in title[:4]:
|
||||
movie_url = f"https://www.omdbapi.com/?apikey=5677e549&t={i}&plot=full"
|
||||
response = HTTP.get(movie_url)
|
||||
movie_data = response.text
|
||||
movie.append(json.loads(movie_data))
|
||||
|
||||
return movie
|
2
scripts/Movie_Recommendation_API/requirements.txt
Normal file
2
scripts/Movie_Recommendation_API/requirements.txt
Normal file
@ -0,0 +1,2 @@
|
||||
bs4
|
||||
fastapi
|
25
scripts/Video_Merger/README.md
Normal file
25
scripts/Video_Merger/README.md
Normal file
@ -0,0 +1,25 @@
|
||||
### Video Merger
|
||||
Simple script that combines many videos into a single Video.
|
||||
## How to use
|
||||
1) Clone the Repo
|
||||
2) Install Packages mentioned inside requirements.txt
|
||||
3) python main.py
|
||||
|
||||
## NOTE
|
||||
As of now you can only merge videos that have extension (.mp4)
|
||||
|
||||
# Author
|
||||
Ambush Neupane
|
||||
### Video Merger
|
||||
Simple script that combines many videos into a single Video.
|
||||
## How to use
|
||||
1) Clone the Repo
|
||||
2) Install Packages mentioned inside requirements.txt
|
||||
* ```pip install moviepy```
|
||||
3) python main.py
|
||||
|
||||
## NOTE
|
||||
As of now you can only merge videos that have extension (.mp4)
|
||||
|
||||
# Author
|
||||
Ambush Neupane
|
17
scripts/Video_Merger/listvideos.py
Normal file
17
scripts/Video_Merger/listvideos.py
Normal file
@ -0,0 +1,17 @@
|
||||
|
||||
#this script returns the list of videos (.mp4) from the path you choose.
|
||||
import os
|
||||
pathOfVideo=input("Enter the full path where videos are located.")
|
||||
|
||||
def array_Of_Videos():
|
||||
fileExists= os.path.exists(pathOfVideo) #returns a boolen
|
||||
|
||||
if fileExists:
|
||||
dirList= sorted(os.listdir(pathOfVideo)) #returns list of files inside the path
|
||||
return [files for files in dirList if files.endswith(".mp4") ]
|
||||
|
||||
else:
|
||||
print(f"No such path as {pathOfVideo}")
|
||||
|
||||
videoslist= array_Of_Videos()
|
||||
print(f'If the sequence of the videos doesn\'t look like Following. You can press Control + C to kill the program.\n{videoslist}')
|
7
scripts/Video_Merger/main.py
Normal file
7
scripts/Video_Merger/main.py
Normal file
@ -0,0 +1,7 @@
|
||||
from renderVideo import renderFinalVideo
|
||||
|
||||
def main():
|
||||
renderFinalVideo()
|
||||
|
||||
if __name__ == '__main__':
|
||||
main()
|
20
scripts/Video_Merger/renderVideo.py
Normal file
20
scripts/Video_Merger/renderVideo.py
Normal file
@ -0,0 +1,20 @@
|
||||
from moviepy.editor import VideoFileClip,concatenate_videoclips
|
||||
from listvideos import videoslist,pathOfVideo
|
||||
import os
|
||||
|
||||
|
||||
def renderFinalVideo():
|
||||
videoNames=[VideoFileClip(os.path.join(pathOfVideo, video)) for video in videoslist]
|
||||
final_video = concatenate_videoclips(videoNames,method='compose')
|
||||
filePath= input("Enter location to save file:-")
|
||||
filePathExists= os.path.exists(filePath)
|
||||
if filePathExists:
|
||||
fileName= input("Enter file name;-")
|
||||
|
||||
if fileName.endswith(".mp4"):
|
||||
final_video.write_videofile(os.path.join(filePath,fileName))
|
||||
else:
|
||||
print("Sorry the extension must be .mp4")
|
||||
|
||||
else:
|
||||
print(f"Sorry Error Occured!!!Make sure this path exists:- {filePath}")
|
2
scripts/Video_Merger/requirements.txt
Normal file
2
scripts/Video_Merger/requirements.txt
Normal file
@ -0,0 +1,2 @@
|
||||
moviepy
|
||||
os
|
@ -1,5 +1,5 @@
|
||||
beautifulsoup4==4.4.1
|
||||
bs4==0.0.1
|
||||
lxml==4.6.3
|
||||
lxml==4.9.1
|
||||
requests==2.20.0
|
||||
tqdm==4.7.6
|
||||
|
7
scripts/YAML-to-JSON Converter/README.md
Normal file
7
scripts/YAML-to-JSON Converter/README.md
Normal file
@ -0,0 +1,7 @@
|
||||
### YAML to JSON file converter
|
||||
Takes YAML data and converts it into JSON by using `json ` and `yml` libraries of `python`.
|
||||
### To Execute the code
|
||||
```bash
|
||||
$ yaml2json.py input_file.yaml output_file.json
|
||||
```
|
||||
#### Created by : @SiddheshKukade
|
35
scripts/YAML-to-JSON Converter/yml2json.py
Normal file
35
scripts/YAML-to-JSON Converter/yml2json.py
Normal file
@ -0,0 +1,35 @@
|
||||
import json
|
||||
import os
|
||||
import sys
|
||||
import yaml
|
||||
|
||||
# Checking there is a file name passed
|
||||
if len(sys.argv) > 1:
|
||||
# Opening the file
|
||||
if os.path.exists(sys.argv[1]):
|
||||
source_file = open(sys.argv[1], "r")
|
||||
source_content = yaml.safe_load(source_file)
|
||||
source_file.close()
|
||||
# Failikng if the file isn't found
|
||||
else:
|
||||
print("ERROR: " + sys.argv[1] + " not found")
|
||||
exit(1)
|
||||
# No file, no usage
|
||||
else:
|
||||
print("Usage: yaml2json.py <source_file.yaml> [target_file.json]")
|
||||
|
||||
# Processing the conversion
|
||||
output = json.dumps(source_content)
|
||||
|
||||
# If no target file send to stdout
|
||||
if len(sys.argv) < 3:
|
||||
print(output)
|
||||
# If the target file already exists exit
|
||||
elif os.path.exists(sys.argv[2]):
|
||||
print("ERROR: " + sys.argv[2] + " already exists")
|
||||
exit(1)
|
||||
# Otherwise write to the specified file
|
||||
else:
|
||||
target_file = open(sys.argv[2], "w")
|
||||
target_file.write(output)
|
||||
target_file.close()
|
7
scripts/alarmclock/README.md
Normal file
7
scripts/alarmclock/README.md
Normal file
@ -0,0 +1,7 @@
|
||||
# Alarm clock using Python
|
||||
Simple GUI thats lets you set alarm.
|
||||
|
||||
## Guidelines to use the software on remote machine
|
||||
* Use pip install tkinter on command line (cmd)
|
||||
* Import modules like datetime, time, winsound from python
|
||||
* Save the file by the extension .py and run it in your python IDE
|
86
scripts/alarmclock/alarm.py
Normal file
86
scripts/alarmclock/alarm.py
Normal file
@ -0,0 +1,86 @@
|
||||
# Import Required Library
|
||||
from tkinter import *
|
||||
import datetime
|
||||
import time
|
||||
import winsound
|
||||
from threading import *
|
||||
|
||||
# Create Object
|
||||
root = Tk()
|
||||
|
||||
# Set geometry
|
||||
root.geometry("400x200")
|
||||
|
||||
# Use Threading
|
||||
def Threading():
|
||||
t1=Thread(target=alarm)
|
||||
t1.start()
|
||||
|
||||
def alarm():
|
||||
# Infinite Loop
|
||||
while True:
|
||||
# Set Alarm
|
||||
set_alarm_time = f"{hour.get()}:{minute.get()}:{second.get()}"
|
||||
|
||||
# Wait for one seconds
|
||||
time.sleep(1)
|
||||
|
||||
# Get current time
|
||||
current_time = datetime.datetime.now().strftime("%H:%M:%S")
|
||||
print(current_time,set_alarm_time)
|
||||
|
||||
# Check whether set alarm is equal to current time or not
|
||||
if current_time == set_alarm_time:
|
||||
print("Time to Wake up")
|
||||
# Playing sound
|
||||
winsound.PlaySound("sound.wav",winsound.SND_ASYNC)
|
||||
|
||||
# Add Labels, Frame, Button, Optionmenus
|
||||
Label(root,text="Alarm Clock",font=("Helvetica 20 bold"),fg="red").pack(pady=10)
|
||||
Label(root,text="Set Time",font=("Helvetica 15 bold")).pack()
|
||||
|
||||
frame = Frame(root)
|
||||
frame.pack()
|
||||
|
||||
hour = StringVar(root)
|
||||
hours = ('00', '01', '02', '03', '04', '05', '06', '07',
|
||||
'08', '09', '10', '11', '12', '13', '14', '15',
|
||||
'16', '17', '18', '19', '20', '21', '22', '23', '24'
|
||||
)
|
||||
hour.set(hours[0])
|
||||
|
||||
hrs = OptionMenu(frame, hour, *hours)
|
||||
hrs.pack(side=LEFT)
|
||||
|
||||
minute = StringVar(root)
|
||||
minutes = ('00', '01', '02', '03', '04', '05', '06', '07',
|
||||
'08', '09', '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')
|
||||
minute.set(minutes[0])
|
||||
|
||||
mins = OptionMenu(frame, minute, *minutes)
|
||||
mins.pack(side=LEFT)
|
||||
|
||||
second = StringVar(root)
|
||||
seconds = ('00', '01', '02', '03', '04', '05', '06', '07',
|
||||
'08', '09', '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')
|
||||
second.set(seconds[0])
|
||||
|
||||
secs = OptionMenu(frame, second, *seconds)
|
||||
secs.pack(side=LEFT)
|
||||
|
||||
Button(root,text="Set Alarm",font=("Helvetica 15"),command=Threading).pack(pady=20)
|
||||
|
||||
# Execute Tkinter
|
||||
root.mainloop()
|
17
scripts/encode-decode-images/README.md
Normal file
17
scripts/encode-decode-images/README.md
Normal file
@ -0,0 +1,17 @@
|
||||
# Encode/Decode Images
|
||||
|
||||
This is a Python script to encode/decode images. It uses base64 format to encode/decode images
|
||||
|
||||
## Usage
|
||||
|
||||
#### Encode
|
||||
|
||||
```bash
|
||||
python main.py -e <IMAGE_PATH>
|
||||
```
|
||||
|
||||
#### Decode
|
||||
|
||||
```bash
|
||||
python main.py -d <DESTINATION_PATH>
|
||||
```
|
26
scripts/encode-decode-images/main.py
Normal file
26
scripts/encode-decode-images/main.py
Normal file
@ -0,0 +1,26 @@
|
||||
import argparse
|
||||
import base64
|
||||
|
||||
|
||||
def encode(filepath):
|
||||
image = open(filepath, 'rb')
|
||||
img_encoded = base64.b64encode(image.read())
|
||||
dest = open('encoded.txt', 'wb')
|
||||
dest.write(img_encoded)
|
||||
|
||||
def decode(dest_path):
|
||||
img_encoded = open('encoded.txt', 'rb')
|
||||
img_decoded = base64.b64decode(img_encoded.read())
|
||||
dest = open(dest_path, 'wb')
|
||||
dest.write(img_decoded)
|
||||
|
||||
|
||||
parser = argparse.ArgumentParser()
|
||||
parser.add_argument("-e", "--encode", required=False, help="Encode image.")
|
||||
parser.add_argument("-d", "--decode", required=False, help="Decode image.")
|
||||
args = vars(parser.parse_args())
|
||||
|
||||
if args["encode"]:
|
||||
encode(args["encode"])
|
||||
else:
|
||||
decode(args["decode"])
|
13
scripts/json-to-excel/README.md
Normal file
13
scripts/json-to-excel/README.md
Normal file
@ -0,0 +1,13 @@
|
||||
# JSON to Excel converter
|
||||
|
||||
This is a simple Python script to convert a JSON file to an Excel file.
|
||||
|
||||
## Usage
|
||||
|
||||
```bash
|
||||
# install xlwt
|
||||
pip install xlwt
|
||||
|
||||
# run script
|
||||
python main.py <JSON_FILE_PATH>
|
||||
```
|
54
scripts/json-to-excel/main.py
Normal file
54
scripts/json-to-excel/main.py
Normal file
@ -0,0 +1,54 @@
|
||||
import json
|
||||
import xlwt
|
||||
import sys
|
||||
import os
|
||||
from collections import defaultdict
|
||||
|
||||
if sys.argv[1] == "help":
|
||||
print("Usage:\n\tjsonToExcel.py json_file.json")
|
||||
sys.exit(1)
|
||||
|
||||
if not os.path.exists(sys.argv[1]):
|
||||
print("Cannot open " + sys.argv[1])
|
||||
sys.exit(1)
|
||||
|
||||
file_name = sys.argv[1]
|
||||
file_extenstion = file_name.split(".")[-1]
|
||||
|
||||
if not file_extenstion in ("json"):
|
||||
print("The extension of JSON file is incorrect")
|
||||
sys.exit(1)
|
||||
|
||||
file = open(file_name)
|
||||
json_text = file.read()
|
||||
|
||||
try:
|
||||
imported_json = defaultdict(json.loads(json_text))
|
||||
except:
|
||||
print("The content of the JSON file is incorrect")
|
||||
sys.exit(1)
|
||||
|
||||
workbook = xlwt.Workbook()
|
||||
worksheet = workbook.add_sheet("json exported")
|
||||
|
||||
columns = list(imported_json[0].keys())
|
||||
|
||||
i = 0
|
||||
for column in columns:
|
||||
worksheet.write(0, i, column)
|
||||
i += 1
|
||||
|
||||
j = 1
|
||||
for row in imported_json:
|
||||
i = 0
|
||||
for column in columns:
|
||||
worksheet.write(j, i, row[column])
|
||||
i += 1
|
||||
j += 1
|
||||
|
||||
try:
|
||||
workbook.save(file_name.split(".")[0] + ".xls")
|
||||
sys.exit(0)
|
||||
except:
|
||||
print("Cannot create the xls file")
|
||||
sys.exit(1)
|
5
scripts/track_webpage_changes/README.md
Normal file
5
scripts/track_webpage_changes/README.md
Normal file
@ -0,0 +1,5 @@
|
||||
Tracking any change in a webpage using Python.
|
||||
|
||||
- Input the url with proper format(with https:// and so on).
|
||||
- The program checks the site periodically, so input an interval in seconds.
|
||||
- Look at your screen.
|
40
scripts/track_webpage_changes/main.py
Normal file
40
scripts/track_webpage_changes/main.py
Normal file
@ -0,0 +1,40 @@
|
||||
import requests
|
||||
from bs4 import BeautifulSoup
|
||||
import difflib
|
||||
import time
|
||||
from datetime import datetime
|
||||
|
||||
url = str(input("url: "))
|
||||
interval = int(input("interval(s): "))
|
||||
headers = {
|
||||
'User-Agent': 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_10_1) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/39.0.2171.95 Safari/537.36'}
|
||||
|
||||
PrevVersion = ""
|
||||
FirstRun = True
|
||||
while True:
|
||||
response = requests.get(url, headers=headers)
|
||||
soup = BeautifulSoup(response.text, "lxml")
|
||||
for script in soup(["script", "style"]):
|
||||
script.extract()
|
||||
soup = soup.get_text()
|
||||
|
||||
if PrevVersion != soup:
|
||||
if FirstRun == True:
|
||||
PrevVersion = soup
|
||||
FirstRun = False
|
||||
print("Started Monitoring " + url + " " + str(datetime.now()))
|
||||
else:
|
||||
print("Changes detected at: " + str(datetime.now()))
|
||||
OldPage = PrevVersion.splitlines()
|
||||
NewPage = soup.splitlines()
|
||||
d = difflib.Differ()
|
||||
diff = d.compare(OldPage, NewPage)
|
||||
out_text = "\n".join([ll.rstrip() for ll in '\n'.join(diff).splitlines() if ll.strip()])
|
||||
#print(out_text)
|
||||
OldPage = NewPage
|
||||
# print ('\n'.join(diff))
|
||||
PrevVersion = soup
|
||||
else:
|
||||
print("No Changes Detected " + str(datetime.now()))
|
||||
time.sleep(interval)
|
||||
continue
|
3
scripts/track_webpage_changes/requirements.txt
Normal file
3
scripts/track_webpage_changes/requirements.txt
Normal file
@ -0,0 +1,3 @@
|
||||
bs4==0.0.1
|
||||
lxml==4.9.1
|
||||
requests==2.28.1
|
11
scripts/youtube_playlist_downloader/README.md
Normal file
11
scripts/youtube_playlist_downloader/README.md
Normal file
@ -0,0 +1,11 @@
|
||||
# Youtube Playlist Downloader
|
||||
This is a simple script that lets you download each video in a youtbue playlist.
|
||||
|
||||
## Installations
|
||||
pip install python-youtube
|
||||
pip install pytube
|
||||
|
||||
## Usage
|
||||
1. Clone the repo
|
||||
2. Download the requirements
|
||||
3. Run python script.py
|
54
scripts/youtube_playlist_downloader/script.py
Normal file
54
scripts/youtube_playlist_downloader/script.py
Normal file
@ -0,0 +1,54 @@
|
||||
from tkinter import *
|
||||
from pyyoutube import Api
|
||||
from pytube import YouTube
|
||||
from threading import Thread
|
||||
from tkinter import messagebox
|
||||
|
||||
|
||||
def threading():
|
||||
t1 = Thread(target=download_videos)
|
||||
t1.start()
|
||||
|
||||
|
||||
def download_videos():
|
||||
api = Api(api_key='Enter API Key')
|
||||
|
||||
if "youtube" in playlistId.get():
|
||||
playlist_id = playlistId.get()[len(
|
||||
"https://www.youtube.com/playlist?list="):]
|
||||
else:
|
||||
playlist_id = playlistId.get()
|
||||
|
||||
playlist_item_by_id = api.get_playlist_items(
|
||||
playlist_id=playlist_id, count=None, return_json=True)
|
||||
|
||||
for index, videoid in enumerate(playlist_item_by_id['items']):
|
||||
|
||||
link = f"https://www.youtube.com/watch?v={videoid['contentDetails']['videoId']}"
|
||||
|
||||
yt_obj = YouTube(link)
|
||||
|
||||
filters = yt_obj.streams.filter(progressive=True, file_extension='mp4')
|
||||
|
||||
filters.get_highest_resolution().download()
|
||||
|
||||
print(f"Downloaded:- {link}")
|
||||
|
||||
messagebox.showinfo("Success", "Video Successfully downloaded")
|
||||
|
||||
|
||||
root = Tk()
|
||||
root.geometry('400x200')
|
||||
|
||||
Label(root, text="Youtube Playlist Downloader",
|
||||
font="italic 15 bold").pack(pady=10)
|
||||
Label(root, text="Enter Playlist URL:-", font="italic 10").pack()
|
||||
|
||||
|
||||
playlistId = Entry(root, width=60)
|
||||
playlistId.pack(pady=5)
|
||||
|
||||
download_start = Button(root, text="Download Start", command=threading)
|
||||
download_start.pack(pady=10)
|
||||
|
||||
root.mainloop()
|
Loading…
x
Reference in New Issue
Block a user