2016-11-25 12 views
0
Total number of EVENTS in BOX(planner + ondemand) : 54 
EVENT # :1 

actualEndTime= '20161121T11:34:00' allowCopyToPlanner= 'True' audioType= '2' audioTypeName= 'Simple stereo' baseType= '3' baseTypeName= 'Download' bookedAsOPPV= 'False' bookingActive= '1' bookingDeletedTime= 'None' bookingDiskQuotaName= 'user' bookingExpirationTime= '19700101T01:00:00' bookingKeep= 'False' bookingLock= 'False' bookingSource= '1' bookingTime= '20161121T11:27:00' bookingType= '4' bookingTypeName= 'Download' boxSetLocator= 'hecid://FFC6AE9C' boxSetName= 'Lost S1' boxSetNameSort= 'Lost S1' boxSetRating= '0' canonicalName= 'Lost' cgmsa= '0' channelID= 'None' channelIDType= 'None' channelName= 'abc studios' channelNr= '102' class= 'object.item.videoItem' cmdcMemberNumber= '1' description= 'A plane crash leaves survivors stranded on a jungle island. Contains violence.(S1, ep 1)' episodeNumber= '1' episodeTitle= 'Pilot (part 1 Of 2) Premiere' estimatedBitRate= '5767168' expireFromPlanner= 'False' extensionStartDur= '0' flagsAllowanalogtaping= 'True' flagsCopyprotected= 'False' flagsCurrentseries= 'False' flagsHasaudiodesc= 'False' flagsHasforeignsubtitles= 'False' flagsHd= 'False' flagsIppv= 'False' flagsIs3D= 'False' flagsIsadult= 'False' flagsIslinked= 'False' flagsOppv= 'False' flagsWidescreen= 'True' genre= '3' genreExtended= '3,772' genreId= 'nds.com_internal' genreName= 'Entertainment' groupID= '0' guardEndDur= 'None' guardStartDur= 'None' isBTO= 'False' isPdlTrailer= '0' isPlaying= 'False' isSeriesLinked= 'False' isShowLinked= '0' isSplitEvent= 'False' isViewed= 'False' itemId= 'BOOK:688045263' itemParentid= '3' itemRestricted= '0' lastPlaybackPosition= '0' lastViewedTime= '19700101T01:00:00' marketingMsg= 'None' oigProgId= '4291238560' parentServiceLocator= 'None' parentalRatingScheme= '1' pdlDownloadStatus= '5' pdlDownloadStatusName= 'ended' pdlPlaybackAvailable= 'True' pdlQueuePosition= '0' pinRating= '4' pinRatingScheme= '1' programID= 'oig://FFC71AA0' programIDType= 'nds.com_URI' purchaseType= '0' pushExpiryEnd= 'None' pushExpiryStart= 'None' pushHasValidTrailer= 'True' pushLocator= 'None' pushPublishTime= 'None' rating= '0' ratingName= 'Unrated' ratingType= 'nds.com_internal' recStatus= '0' recStatusContentstatus= '3' recStatusContentstatusName= 'All' recStatusException= '100' recStatusFailed= 'False' recStatusName= 'Not applicable' recStatusRecstate= '0' recordedDuration= 'P0D00:40:39' recordedStartDateTime= '20161121T11:27:50' recordingID= 'oig://FFC71AA0' reminderStatus= '1' reminderStatusIsvcrtimer= 'False' reminderStatusName= 'event is scheduled for a reminder' remoteCDSItemID= 'None' res= 'file://pvr/2902BCCF' resDuration= '0:40:39' resProtocolinfo= 'internal:10.10.8.89:*:*' resSize= '660887492.0' scheduledDuration= 'P0D00:40:39' scheduledEndTime= 'None' scheduledStartTime= 'None' seasonNumber= '1' seriesID= 'None' seriesInfo= '1/1' serviceType= '0' serviceTypeName= 'Undefined' srsRecordTaskID= 'RT:2902BCCF' subGroupID= '0' title= 'Lost' totalChildSize= '0.0' 

EVENT # :2 
actualEndTime= '20161121T11:41:00' allowCopyToPlanner= 'True' audioType= '2' audioTypeName= 'Simple stereo' baseType= '3' baseTypeName= 'Download' bookedAsOPPV= 'False' bookingActive= '1' bookingDeletedTime= 'None' bookingDiskQuotaName= 'user' bookingExpirationTime= '19700101T01:00:00' bookingKeep= 'False' bookingLock= 'False' bookingSource= '1' bookingTime= '20161121T11:27:00' bookingType= '4' bookingTypeName= 'Download' boxSetLocator= 'hecid://FFC6AE9C' boxSetName= 'Lost S1' boxSetNameSort= 'Lost S1' boxSetRating= '0' canonicalName= 'Lost' cgmsa= '0' channelID= 'None' channelIDType= 'None' channelName= 'abc studios' channelNr= '0' class= 'object.item.videoItem' cmdcMemberNumber= '2' description= 'Jack tends to a wounded man who reveals a secret about Kate. Contains strong language, violence.(S1, ep 2)' episodeNumber= '2' episodeTitle= 'Pilot (part 2 Of 2) Premiere' estimatedBitRate= '5767168' expireFromPlanner= 'False' extensionStartDur= '0' flagsAllowanalogtaping= 'True' flagsCopyprotected= 'False' flagsCurrentseries= 'False' flagsHasaudiodesc= 'False' flagsHasforeignsubtitles= 'False' flagsHd= 'False' flagsIppv= 'False' flagsIs3D= 'False' flagsIsadult= 'False' flagsIslinked= 'False' flagsOppv= 'False' flagsWidescreen= 'True' genre= '3' genreExtended= '3,772' genreId= 'nds.com_internal' genreName= 'Entertainment' groupID= '0' guardEndDur= 'None' guardStartDur= 'None' isBTO= 'False' isPdlTrailer= '0' isPlaying= 'False' isSeriesLinked= 'False' isShowLinked= '0' isSplitEvent= 'False' isViewed= 'False' itemId= 'BOOK:688045265' itemParentid= '3' itemRestricted= '0' lastPlaybackPosition= '0' lastViewedTime= '19700101T01:00:00' marketingMsg= 'None' oigProgId= '4291228354' parentServiceLocator= 'None' parentalRatingScheme= '1' pdlDownloadStatus= '5' pdlDownloadStatusName= 'ended' pdlPlaybackAvailable= 'True' pdlQueuePosition= '0' pinRating= '4' pinRatingScheme= '1' programID= 'oig://FFC6F2C2' programIDType= 'nds.com_URI' purchaseType= '0' pushExpiryEnd= 'None' pushExpiryStart= 'None' pushHasValidTrailer= 'True' pushLocator= 'None' pushPublishTime= 'None' rating= '0' ratingName= 'Unrated' ratingType= 'nds.com_internal' recStatus= '0' recStatusContentstatus= '3' recStatusContentstatusName= 'All' recStatusException= '100' recStatusFailed= 'False' recStatusName= 'Not applicable' recStatusRecstate= '0' recordedDuration= 'P0D00:38:48' recordedStartDateTime= '20161121T11:35:03' recordingID= 'oig://FFC6F2C2' reminderStatus= '1' reminderStatusIsvcrtimer= 'False' reminderStatusName= 'event is scheduled for a reminder' remoteCDSItemID= 'None' res= 'file://pvr/2902BCD1' resDuration= '0:38:48' resProtocolinfo= 'internal:10.10.8.89:*:*' resSize= '631299676.0' scheduledDuration= 'P0D00:38:48' scheduledEndTime= 'None' scheduledStartTime= 'None' seasonNumber= '1' seriesID= 'None' seriesInfo= '1/2' serviceType= '0' serviceTypeName= 'Undefined' srsRecordTaskID= 'RT:2902BCD1' subGroupID= '0' title= 'Lost' totalChildSize= '0.0' 

私はoutput.txtファイルを持っています。ユーザーがチャンネル番号を入力すると、その全体のイベントを削除したいと思います。Pythonで.txtファイルからデータを取得

たとえば、ユーザがChannelNr=102と入力した場合、'BOOK:688045263' 番を取得できたら、channelNrに関連するイベントを削除できます。

次の関数を使用してファイル内にchannelNrを取得できます。関連ChannelNr上:

だから、私の質問はどのように本の数(688045263のitemId =」BOOK)を得ることができるのですか?

+0

質問を書式設定してください。それに紛らわしいテキストがあり、混乱させてしまいます。 – Tom

+0

あなたの質問を再フォーマットしようとしましたが、結果を確認してください! –

+0

@KlausD。 – pydev

答えて

0

グーグルの最初の悔恨はhttps://www.tutorialspoint.com/python/string_find.htmです。それは良いリソースを持っています。

string.find()は、たとえば、インデックスを返します。

str1 = "this is string example....wow!!!"; 
str2 = "exam"; 

print str1.find(str2) 
15 

これは正規表現ではありません。それは正規表現ですか?

JSONにエクスポートできますか?それははるかに、はるかにクリーンなソリューションとなり、頭痛のトンを節約します。今、あなた

{ 
"channelNr": 602 
} 

を与えるあなたが戻ってデータを取得することができます

channel = ("channelNr= '%d'") % (user_channel_number)

としてこのテキストはあなたが

>>> import json 
>>> print json.dumps({'channelNr': user_channel_number}, separators=(',', ': ')) 

を試みることができる

あなた出力

jsonData = { "channelNr": 602  } 
dictionary = json.loads(jsonData)[0] 
channelNr = dictionary['channelNr'] 

、それは

return(channelNr == 602) 
True 
0

私はすでにchannelNrを取得しています検索します。私の質問は、どのように私はBOOK idsを得ることができる、私はイベントを削除することができますでした。

イベントはoutput.txtファイルにエクスポートされます。

def check_channel_number(self): 

    print "***************Channel Checker *********************" 

    user_channel_number = int(re.sub('\D', '', raw_input("Enter a channel number, (3digit): "))[:3]); 

    self.user_channel_number = user_channel_number 

    channel = ("channelNr= '%d'") % (user_channel_number) 


    # book = ("BOOK: '%d") %() 

    datafile = file('output.txt') 

    found = False 

    for line in datafile: 

     if channel in line: 
      found = True 
      return user_channel_number 

     print 'The channel number you entered is not on the planner' 
     break   



def delete_events(self): 


    self.ucn = self.user_channel_number 

    are_you_sure = raw_input('Channel number is correct. Are you sure to delete channel number? (y/n): ') 

    if are_you_sure == 'y' and self.ucn >0 : 

     print 'The selected program will be deleted' 

     action = 'DeleteEvent' 
     menu_action = 'all' 
     book = 'BOOK:688045265' 
     arg_list = [('C:\\Users\\yke01\\Documents\\StormTest\\Scripts\\Completed' 
         '\\Utils\\UPNP_Client_Cmd_Line.py')] 
     arg_list.append(' --action=') 
     arg_list.append(action) 
     arg_list.append(' --ip=') 
     arg_list.append('10.10.8.89') 
     arg_list.append(' --objectId=') 
     arg_list.append(book) 

     subprocess.call(["python", arg_list]) 

     print 'The program deleted successfully' 
    else: 
     print 'The program is NOT deleted!' 

book変数は、delete_events()関数でハードコードされています。私はトラフの本ID(9桁)を動的に渡す方法を見つけようとしています。

関連する問題