Kashirigi
5 years ago
2 changed files with 65 additions and 0 deletions
@ -0,0 +1,47 @@
@@ -0,0 +1,47 @@
|
||||
class TestThis(object): |
||||
'''Demonstrates how to use property() as a decorator |
||||
The power of this will be in declaring essentially private variables |
||||
Property has built in property.setter, property.getter, property.deleter''' |
||||
def __init__(self): |
||||
self.voltage = 0 |
||||
|
||||
@property |
||||
def voltage(self): |
||||
return self._voltage |
||||
|
||||
@voltage.setter |
||||
def voltage(self, value): |
||||
'''Variables inherit name of function, clearly. Can place tests on things here, if desired''' |
||||
if value < 0: |
||||
print('Voltage can not be negative') |
||||
self._voltage=0 |
||||
else: |
||||
self._voltage = value |
||||
|
||||
@voltage.deleter |
||||
def voltage(self): |
||||
print('Deleting voltage') |
||||
del self._voltage |
||||
|
||||
@property |
||||
def higher(self): |
||||
self._higher = self.voltage*3 |
||||
return self._higher |
||||
|
||||
@higher.deleter |
||||
def higher(self): |
||||
print('deleted higher') |
||||
del self._higher |
||||
|
||||
if __name__=='__main__': |
||||
x = TestThis() |
||||
x.voltage = -217 |
||||
print(x.voltage) |
||||
print(x.higher) |
||||
x.voltage = 3 |
||||
print(x.higher) |
||||
del x.higher |
||||
|
||||
|
||||
|
||||
|
@ -0,0 +1,18 @@
@@ -0,0 +1,18 @@
|
||||
import sys |
||||
from mutagen.mp4 import MP4 |
||||
#print(sys.argv[1:]) |
||||
# https://mutagen.readthedocs.io/en/latest/api/mp4.html#id1 |
||||
conv=sys.argv[1:] |
||||
for item in conv: |
||||
if item.endswith('m4a'): |
||||
names=item.split('-') |
||||
# File names have the metadata in this case: |
||||
# 00-Song Title-Artist-Album-otherinfo.m4a |
||||
audio=MP4(item) |
||||
audio['\xa9nam']=[names[1]] |
||||
audio['\xa9ART']=[names[2]] |
||||
audio['\xa9alb']=[names[3]] |
||||
audio['\xa9gen']=['Electronic'] |
||||
audio.save() |
||||
|
||||
|
Loading…
Reference in new issue